You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2015/09/08 18:39:35 UTC
[18/55] [abbrv] olingo-odata4 git commit: [OLINGO-659] Removed v4
from package and class names
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java
deleted file mode 100644
index fe41206..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java
+++ /dev/null
@@ -1,183 +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 org.apache.olingo.fit.v4;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.UUID;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.RandomStringUtils;
-import org.apache.olingo.client.api.ODataClient;
-import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
-import org.apache.olingo.client.api.communication.request.cud.UpdateType;
-import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
-import org.apache.olingo.client.api.communication.request.retrieve.ODataMediaRequest;
-import org.apache.olingo.client.api.communication.request.streamed.MediaEntityCreateStreamManager;
-import org.apache.olingo.client.api.communication.request.streamed.MediaEntityUpdateStreamManager;
-import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityCreateRequest;
-import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityUpdateRequest;
-import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
-import org.apache.olingo.client.api.communication.response.ODataMediaEntityCreateResponse;
-import org.apache.olingo.client.api.communication.response.ODataMediaEntityUpdateResponse;
-import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
-import org.apache.olingo.client.api.domain.ClientEntity;
-import org.apache.olingo.client.api.domain.ClientValuable;
-import org.apache.olingo.client.api.uri.URIBuilder;
-import org.apache.olingo.client.core.ODataClientFactory;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.http.HttpHeader;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.junit.Test;
-
-public class MediaEntityTestITCase extends AbstractTestITCase {
-
- private void read(final ODataClient client, final ContentType contentType) throws IOException {
- final URIBuilder builder = client.newURIBuilder(testDemoServiceRootURL).
- appendEntitySetSegment("Advertisements").
- appendKeySegment(UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7"));
- final ODataEntityRequest<ClientEntity> entityReq =
- client.getRetrieveRequestFactory().getEntityRequest(builder.build());
- entityReq.setFormat(contentType);
-
- final ClientEntity entity = entityReq.execute().getBody();
- assertNotNull(entity);
- assertTrue(entity.isMediaEntity());
- // cast to workaround JDK 6 bug, fixed in JDK 7
- assertEquals(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName().toString(),
- ((ClientValuable) entity.getProperty("AirDate")).getValue().getTypeName());
-
- final ODataMediaRequest streamReq = client.getRetrieveRequestFactory().
- getMediaRequest(entity.getMediaContentSource());
- final ODataRetrieveResponse<InputStream> streamRes = streamReq.execute();
- assertEquals(200, streamRes.getStatusCode());
-
- final byte[] actual = new byte[Integer.parseInt(streamRes.getHeader("Content-Length").iterator().next())];
- IOUtils.read(streamRes.getBody(), actual, 0, actual.length);
- }
-
- @Test
- public void readAsAtom() throws IOException {
- read(client, ContentType.APPLICATION_ATOM_XML);
- }
-
- @Test
- public void readAsJSON() throws IOException {
- read(ODataClientFactory.getEdmEnabledClient(testDemoServiceRootURL, ContentType.JSON), ContentType.JSON);
- }
-
- @Test
- public void readAsJSONFull() throws IOException {
- read(client, ContentType.JSON_FULL_METADATA);
- }
-
- private void create(final ContentType contentType) throws IOException {
- final String random = RandomStringUtils.random(110);
- final InputStream input = IOUtils.toInputStream(random);
-
- final URI uri = client.newURIBuilder(testDemoServiceRootURL).appendEntitySetSegment("Advertisements").build();
- final ODataMediaEntityCreateRequest<ClientEntity> createReq =
- client.getCUDRequestFactory().getMediaEntityCreateRequest(uri, input);
- final MediaEntityCreateStreamManager<ClientEntity> streamManager = createReq.payloadManager();
-
- final ODataMediaEntityCreateResponse<ClientEntity> createRes = streamManager.getResponse();
- assertEquals(201, createRes.getStatusCode());
-
- final Collection<String> location = createRes.getHeader(HttpHeader.LOCATION);
- assertNotNull(location);
- final URI createdLocation = URI.create(location.iterator().next());
-
- final ClientEntity changes = client.getObjectFactory().
- newEntity(new FullQualifiedName("ODataDemo.Advertisement"));
- changes.getProperties().add(client.getObjectFactory().newPrimitiveProperty("AirDate",
- getClient().getObjectFactory().newPrimitiveValueBuilder().
- setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(Calendar.getInstance()).build()));
-
- final ODataEntityUpdateRequest<ClientEntity> updateReq = getClient().getCUDRequestFactory().
- getEntityUpdateRequest(createdLocation, UpdateType.PATCH, changes);
- updateReq.setFormat(contentType);
-
- final ODataEntityUpdateResponse<ClientEntity> updateRes = updateReq.execute();
- assertEquals(204, updateRes.getStatusCode());
-
- final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().
- getMediaEntityRequest(client.newURIBuilder(createdLocation.toASCIIString()).build());
- 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);
- assertEquals(random, new String(actual));
- }
-
- @Test
- public void createAsAtom() throws IOException {
- create(ContentType.APPLICATION_ATOM_XML);
- }
-
- @Test
- public void createAsJSON() throws IOException {
- create(ContentType.JSON);
- }
-
- private void update(final ContentType contentType) throws IOException, EdmPrimitiveTypeException {
- final URI uri = client.newURIBuilder(testDemoServiceRootURL).
- appendEntitySetSegment("Advertisements").
- appendKeySegment(UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7")).build();
-
- final String random = RandomStringUtils.random(124);
-
- // 1. update providing media content
- final ODataMediaEntityUpdateRequest<ClientEntity> updateReq = client.getCUDRequestFactory().
- getMediaEntityUpdateRequest(uri, IOUtils.toInputStream(random));
- updateReq.setFormat(contentType);
-
- final MediaEntityUpdateStreamManager<ClientEntity> streamManager = updateReq.payloadManager();
- final ODataMediaEntityUpdateResponse<ClientEntity> createRes = streamManager.getResponse();
- assertEquals(204, createRes.getStatusCode());
-
- // 2. check that media content was effectively uploaded
- final ODataMediaRequest streamReq = client.getRetrieveRequestFactory().getMediaEntityRequest(uri);
- final ODataRetrieveResponse<InputStream> streamRes = streamReq.execute();
- assertEquals(200, streamRes.getStatusCode());
-
- final byte[] actual = new byte[Integer.parseInt(streamRes.getHeader("Content-Length").iterator().next())];
- IOUtils.read(streamRes.getBody(), actual, 0, actual.length);
- assertEquals(random, new String(actual));
- }
-
- @Test
- public void updateAsAtom() throws IOException, EdmPrimitiveTypeException {
- update(ContentType.APPLICATION_ATOM_XML);
- }
-
- @Test
- public void updateAsJSON() throws IOException, EdmPrimitiveTypeException {
- update(ContentType.JSON);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/v4/MetadataTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/MetadataTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/MetadataTestITCase.java
deleted file mode 100644
index 0993682..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/v4/MetadataTestITCase.java
+++ /dev/null
@@ -1,146 +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 org.apache.olingo.fit.v4;
-
-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 org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmAnnotation;
-import org.apache.olingo.commons.api.edm.EdmEntityContainer;
-import org.apache.olingo.commons.api.edm.EdmEntitySet;
-import org.apache.olingo.commons.api.edm.EdmEntityType;
-import org.apache.olingo.commons.api.edm.EdmEnumType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.EdmProperty;
-import org.apache.olingo.commons.api.edm.EdmSchema;
-import org.apache.olingo.commons.api.edm.EdmTerm;
-import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.annotation.EdmRecord;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmBoolean;
-import org.junit.Test;
-
-public class MetadataTestITCase extends AbstractTestITCase {
-
- @Test
- public void retrieve() throws EdmPrimitiveTypeException {
- final Edm edm = client.getRetrieveRequestFactory().getMetadataRequest(testStaticServiceRootURL).execute().getBody();
- assertNotNull(edm);
-
- final EdmEntityType order = edm.getEntityType(
- new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService", "Order"));
- assertNotNull(order);
-
- final EdmProperty orderDate = order.getStructuralProperty("OrderDate");
- assertNotNull(orderDate);
- assertEquals("Edm.DateTimeOffset", orderDate.getType().getFullQualifiedName().toString());
-
- final EdmTerm isBoss = edm.getTerm(new FullQualifiedName(edm.getSchemas().get(0).getNamespace(), "IsBoss"));
- assertNotNull(isBoss);
- assertEquals(EdmBoolean.getInstance(), isBoss.getType());
-
- final EdmEntitySet orders = edm.getSchemas().get(0).getEntityContainer().getEntitySet("Orders");
- assertNotNull(orders);
- assertFalse(orders.getAnnotations().isEmpty());
- assertTrue(orders.getAnnotations().get(0).getExpression().isDynamic());
- assertTrue(orders.getAnnotations().get(0).getExpression().asDynamic().isRecord());
- final EdmRecord record = orders.getAnnotations().get(0).getExpression().asDynamic().asRecord();
- assertNotNull(record);
- assertEquals(3, record.getPropertyValues().size());
- assertTrue(record.getPropertyValues().get(0).getValue().isConstant());
- assertTrue((Boolean) record.getPropertyValues().get(0).getValue().asConstant().getValue().asPrimitive());
- assertTrue(record.getPropertyValues().get(1).getValue().asDynamic().isCollection());
- assertEquals(1, record.getPropertyValues().get(1).getValue().asDynamic().asCollection().getItems().size());
- assertTrue(record.getPropertyValues().get(1).getValue().asDynamic().asCollection().getItems().get(0).isDynamic());
- assertEquals("OrderID", record.getPropertyValues().get(1).getValue().asDynamic().asCollection().
- getItems().get(0).asDynamic().asPropertyPath().getValue());
- }
-
- @Test
- public void include() {
- final Edm edm = client.getRetrieveRequestFactory().getMetadataRequest(testNorthwindRootURL).execute().getBody();
- assertNotNull(edm);
-
- final EdmEntityContainer container = edm.getEntityContainer(
- new FullQualifiedName("ODataWebExperimental.Northwind.Model", "NorthwindEntities"));
- assertNotNull(container);
-
- final EdmEntitySet categories = container.getEntitySet("Categories");
- assertNotNull(categories);
- assertEquals("NorthwindModel", categories.getEntityType().getNamespace());
- }
-
- @Test
- public void vocabularies() {
- final Edm edm = client.getRetrieveRequestFactory().
- getMetadataRequest(testVocabulariesServiceRootURL).execute().getBody();
- assertNotNull(edm);
-
- // 1. core
- final EdmSchema core = edm.getSchema("Org.OData.Core.V1");
- assertNotNull(core);
- final EdmSchema coreAlias = edm.getSchema("Core");
- assertEquals(core, coreAlias);
-
- final EdmTerm descriptionTerm = edm.getTerm(new FullQualifiedName("Core.Description"));
- assertNotNull(descriptionTerm);
- assertEquals(descriptionTerm.getFullQualifiedName(),
- edm.getTerm(new FullQualifiedName("Org.OData.Core.V1.Description")).getFullQualifiedName());
-
- final EdmAnnotation description = core.getAnnotation(descriptionTerm);
- assertNotNull(description);
- // assertEquals("Core terms needed to write vocabularies",
- // description.getExpression().asConstant().getValue().asPrimitive().getName());
- assertEquals("Core terms needed to write vocabularies",
- description.getExpression().asConstant().getValueAsString());
-
- final EdmTerm isLanguageDependent = edm.getTerm(new FullQualifiedName("Core.IsLanguageDependent"));
- assertNotNull(isLanguageDependent);
- assertTrue(isLanguageDependent.getAppliesTo().contains(EdmProperty.class));
- assertTrue(isLanguageDependent.getAppliesTo().contains(EdmTerm.class));
- assertEquals(edm.getTypeDefinition(new FullQualifiedName("Core.Tag")), isLanguageDependent.getType());
- assertEquals(EdmBoolean.getInstance(), ((EdmTypeDefinition) isLanguageDependent.getType()).getUnderlyingType());
- assertNotNull(isLanguageDependent.getAnnotation(descriptionTerm));
-
- final EdmTerm permissions = edm.getTerm(new FullQualifiedName("Core.Permissions"));
- assertNotNull(permissions);
- assertTrue(permissions.getType() instanceof EdmEnumType);
-
- // 2. measures
- final EdmSchema measures = edm.getSchema("UoM");
- assertNotNull(measures);
-
- final EdmTerm scale = edm.getTerm(new FullQualifiedName("UoM.Scale"));
- assertNotNull(scale);
-
- final EdmAnnotation requiresTypeInScale = edm.getAnnotation(
- scale.getFullQualifiedName(), edm.getTerm(new FullQualifiedName("Core.RequiresType")));
- assertNotNull(requiresTypeInScale);
- assertEquals("Edm.Decimal", requiresTypeInScale.getExpression().asConstant().getValueAsString());
-
- // 3. capabilities
- final EdmTerm deleteRestrictions = edm.getTerm(new FullQualifiedName("Capabilities.DeleteRestrictions"));
- assertNotNull(deleteRestrictions);
- assertEquals(deleteRestrictions.getType().getFullQualifiedName(),
- edm.getComplexType(new FullQualifiedName("Capabilities.DeleteRestrictionsType")).getFullQualifiedName());
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/v4/OAuth2TestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/OAuth2TestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/OAuth2TestITCase.java
deleted file mode 100644
index 1ca5f42..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/v4/OAuth2TestITCase.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 org.apache.olingo.fit.v4;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.net.URI;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.client.api.EdmEnabledODataClient;
-import org.apache.olingo.client.api.ODataClient;
-import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
-import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
-import org.apache.olingo.client.api.domain.ClientEntity;
-import org.apache.olingo.client.api.uri.URIBuilder;
-import org.apache.olingo.client.core.ODataClientFactory;
-import org.apache.olingo.client.core.http.DefaultHttpClientFactory;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.fit.CXFOAuth2HttpClientFactory;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class OAuth2TestITCase extends AbstractTestITCase {
-
- private static final URI OAUTH2_GRANT_SERVICE_URI =
- URI.create("http://localhost:9080/stub/StaticService/oauth2/authorize");
-
- private static final URI OAUTH2_TOKEN_SERVICE_URI =
- URI.create("http://localhost:9080/stub/StaticService/oauth2/token");
-
- private EdmEnabledODataClient _edmClient;
-
- @BeforeClass
- public static void enableOAuth2() {
- client.getConfiguration().setHttpClientFactory(
- new CXFOAuth2HttpClientFactory(OAUTH2_GRANT_SERVICE_URI, OAUTH2_TOKEN_SERVICE_URI));
- }
-
- @AfterClass
- public static void disableOAuth2() {
- client.getConfiguration().setHttpClientFactory(new DefaultHttpClientFactory());
- }
-
- protected ODataClient getLocalClient() {
- ODataClient localClient = ODataClientFactory.getClient();
- localClient.getConfiguration().setHttpClientFactory(
- new CXFOAuth2HttpClientFactory(OAUTH2_GRANT_SERVICE_URI, OAUTH2_TOKEN_SERVICE_URI));
- return localClient;
- }
-
- protected EdmEnabledODataClient getEdmClient() {
- if (_edmClient == null) {
- _edmClient = ODataClientFactory.getEdmEnabledClient(testOAuth2ServiceRootURL, ContentType.JSON);
- _edmClient.getConfiguration().setHttpClientFactory(
- new CXFOAuth2HttpClientFactory(OAUTH2_GRANT_SERVICE_URI, OAUTH2_TOKEN_SERVICE_URI));
- }
-
- return _edmClient;
- }
-
- private void read(final ODataClient client, final ContentType contentType) {
- final URIBuilder uriBuilder =
- client.newURIBuilder(testOAuth2ServiceRootURL).appendEntitySetSegment("Orders").appendKeySegment(8);
-
- final ODataEntityRequest<ClientEntity> req =
- client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(contentType);
-
- final ODataRetrieveResponse<ClientEntity> res = req.execute();
- assertEquals(200, res.getStatusCode());
-
- final String etag = res.getETag();
- assertTrue(StringUtils.isNotBlank(etag));
-
- final ClientEntity order = res.getBody();
- assertEquals(etag, order.getETag());
- assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Order", order.getTypeName().toString());
- assertEquals("Edm.Int32", order.getProperty("OrderID").getPrimitiveValue().getTypeName());
- assertEquals("Edm.DateTimeOffset", order.getProperty("OrderDate").getPrimitiveValue().getTypeName());
- assertEquals("Edm.Duration", order.getProperty("ShelfLife").getPrimitiveValue().getTypeName());
- assertEquals("Collection(Edm.Duration)", order.getProperty("OrderShelfLifes").getCollectionValue().getTypeName());
- }
-
- @Test
- public void testOAuth() {
- try {
- readAsAtom();
- } catch (Exception e) {
- System.out.println("failed for readAsAtom");
- }
-
- try {
- readAsFullJSON();
- } catch (Exception e) {
- System.out.println("failed for readAsFullJSON");
- }
-
- try {
- readAsJSON();
- } catch (Exception e) {
- System.out.println("failed for readAsJSON");
- }
-
- try {
- createAndDelete();
- } catch (Exception e) {
- System.out.println("failed for createAndDelete");
- }
- }
-
- public void readAsAtom() {
- read(getLocalClient(), ContentType.APPLICATION_ATOM_XML);
- }
-
- public void readAsFullJSON() {
- read(getLocalClient(), ContentType.JSON_FULL_METADATA);
- }
-
- public void readAsJSON() {
- read(getEdmClient(), ContentType.JSON);
- }
-
- public void createAndDelete() {
- createAndDeleteOrder(testOAuth2ServiceRootURL, ContentType.JSON, 1002);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/v4/OpenTypeTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/OpenTypeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/OpenTypeTestITCase.java
deleted file mode 100644
index c3b0337..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/v4/OpenTypeTestITCase.java
+++ /dev/null
@@ -1,190 +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 org.apache.olingo.fit.v4;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Calendar;
-import java.util.TimeZone;
-import java.util.UUID;
-
-import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
-import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
-import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
-import org.apache.olingo.client.api.domain.ClientComplexValue;
-import org.apache.olingo.client.api.domain.ClientEntity;
-import org.apache.olingo.client.api.uri.URIBuilder;
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.EdmSchema;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.junit.Test;
-
-public class OpenTypeTestITCase extends AbstractTestITCase {
-
- @Test
- public void checkOpenTypeEntityTypesExist() {
- final Edm metadata = getClient().getRetrieveRequestFactory().
- getMetadataRequest(testOpenTypeServiceRootURL).execute().getBody();
-
- final EdmSchema schema = metadata.getSchemas().get(0);
-
- assertTrue(metadata.getEntityType(new FullQualifiedName(schema.getNamespace(), "Row")).isOpenType());
- assertTrue(metadata.getEntityType(new FullQualifiedName(schema.getNamespace(), "IndexedRow")).isOpenType());
- assertTrue(metadata.getEntityType(new FullQualifiedName(schema.getNamespace(), "RowIndex")).isOpenType());
- }
-
- private ClientEntity readRow(final ContentType contentType, final String uuid) {
- final URIBuilder builder = getClient().newURIBuilder(testOpenTypeServiceRootURL).
- appendEntitySetSegment("Row").appendKeySegment(UUID.fromString(uuid));
- return read(contentType, builder.build());
- }
-
- private void read(final ContentType contentType) {
- ClientEntity row = readRow(contentType, "71f7d0dc-ede4-45eb-b421-555a2aa1e58f");
- assertEquals(EdmPrimitiveTypeKind.Double, row.getProperty("Double").getPrimitiveValue().getTypeKind());
- assertEquals(EdmPrimitiveTypeKind.Guid, row.getProperty("Id").getPrimitiveValue().getTypeKind());
-
- row = readRow(contentType, "672b8250-1e6e-4785-80cf-b94b572e42b3");
- assertEquals(EdmPrimitiveTypeKind.Decimal, row.getProperty("Decimal").getPrimitiveValue().getTypeKind());
- }
-
- @Test
- public void readAsAtom() {
- read(ContentType.APPLICATION_ATOM_XML);
- }
-
- @Test
- public void readAsJSON() {
- read(ContentType.JSON_FULL_METADATA);
- }
-
- private void cud(final ContentType contentType) {
- final Integer id = 1426;
-
- ClientEntity rowIndex = getClient().getObjectFactory().newEntity(
- new FullQualifiedName("Microsoft.Test.OData.Services.OpenTypesServiceV4.RowIndex"));
- getClient().getBinder().add(rowIndex,
- getClient().getObjectFactory().newPrimitiveProperty("Id",
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(id)));
- getClient().getBinder().add(rowIndex,
- getClient().getObjectFactory().newPrimitiveProperty("aString",
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("string")));
- getClient().getBinder().add(rowIndex,
- getClient().getObjectFactory().newPrimitiveProperty("aBoolean",
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildBoolean(true)));
- getClient().getBinder().add(rowIndex,
- getClient().getObjectFactory().newPrimitiveProperty("aDouble",
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildDouble(1.5D)));
- getClient().getBinder().add(rowIndex,
- getClient().getObjectFactory().newPrimitiveProperty("aByte",
- getClient().getObjectFactory().newPrimitiveValueBuilder().
- setType(EdmPrimitiveTypeKind.SByte).setValue(Byte.MAX_VALUE).
- build()));
- getClient().getBinder().add(rowIndex,
- getClient().getObjectFactory().newPrimitiveProperty("aDate",
- getClient().getObjectFactory().newPrimitiveValueBuilder().
- setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(Calendar.getInstance()).
- build()));
- getClient().getBinder().add(rowIndex,
- getClient().getObjectFactory().newPrimitiveProperty("aDate",
- getClient().getObjectFactory().newPrimitiveValueBuilder().
- setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(Calendar.getInstance()).
- build()));
- getClient().getBinder().add(rowIndex,
- getClient().getObjectFactory().newEnumProperty("aColor", getClient().getObjectFactory().
- newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.Color", "Blue")));
-
- final ClientComplexValue contactDetails = getClient().getObjectFactory().newComplexValue(
- "Microsoft.Test.OData.Services.OpenTypesServiceV4.ContactDetails");
- contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("FirstContacted",
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildBinary("text".getBytes())));
- Calendar dateTime = Calendar.getInstance(TimeZone.getTimeZone("GMT+00:01"));
- dateTime.set(2014, 3, 5, 5, 5, 5);
- dateTime.set(Calendar.MILLISECOND, 1);
- contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("LastContacted",
- getClient().getObjectFactory().newPrimitiveValueBuilder().
- setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(dateTime).build()));
- Calendar date = Calendar.getInstance();
- date.set(2001, 3, 5);
- contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("Contacted",
- getClient().getObjectFactory().newPrimitiveValueBuilder().
- setType(EdmPrimitiveTypeKind.Date).setValue(date).build()));
- contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("GUID",
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildGuid(UUID.randomUUID())));
- contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("PreferedContactTime",
- getClient().getObjectFactory().newPrimitiveValueBuilder().
- setType(EdmPrimitiveTypeKind.Duration).setValue(0).build()));
- contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("Byte",
- getClient().getObjectFactory().newPrimitiveValueBuilder().
- setType(EdmPrimitiveTypeKind.Byte).setValue(24).build()));
- contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("SignedByte",
- getClient().getObjectFactory().newPrimitiveValueBuilder().
- setType(EdmPrimitiveTypeKind.SByte).setValue(Byte.MAX_VALUE).build()));
- contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("Double",
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildDouble(Double.MAX_VALUE)));
- contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("Single",
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildSingle(Float.MAX_VALUE)));
- contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("Short",
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16(Short.MAX_VALUE)));
- contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("Int",
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(Integer.MAX_VALUE)));
- getClient().getBinder().add(rowIndex,
- getClient().getObjectFactory().newComplexProperty("aContact", contactDetails));
-
- final ODataEntityCreateRequest<ClientEntity> createReq = getClient().getCUDRequestFactory().
- getEntityCreateRequest(getClient().newURIBuilder(testOpenTypeServiceRootURL).
- appendEntitySetSegment("RowIndex").build(), rowIndex);
- createReq.setFormat(contentType);
- final ODataEntityCreateResponse<ClientEntity> createRes = createReq.execute();
- assertEquals(201, createRes.getStatusCode());
-
- final URIBuilder builder = getClient().newURIBuilder(testOpenTypeServiceRootURL).
- appendEntitySetSegment("RowIndex").appendKeySegment(id);
- rowIndex = read(contentType, builder.build());
- assertNotNull(rowIndex);
- assertEquals(EdmPrimitiveTypeKind.Int32, rowIndex.getProperty("Id").getPrimitiveValue().getTypeKind());
- assertEquals(EdmPrimitiveTypeKind.String, rowIndex.getProperty("aString").getPrimitiveValue().getTypeKind());
- assertEquals(EdmPrimitiveTypeKind.Boolean, rowIndex.getProperty("aBoolean").getPrimitiveValue().getTypeKind());
- assertTrue(rowIndex.getProperty("aDouble").hasPrimitiveValue());
- assertTrue(rowIndex.getProperty("aByte").hasPrimitiveValue());
- assertTrue(rowIndex.getProperty("aDate").hasPrimitiveValue());
- assertNotNull(rowIndex.getProperty("aColor"));
- assertTrue(rowIndex.getProperty("aContact").hasComplexValue());
- assertTrue(rowIndex.getProperty("aContact").getComplexValue().get("SignedByte").hasPrimitiveValue());
-
- final ODataDeleteResponse deleteRes = getClient().getCUDRequestFactory().
- getDeleteRequest(rowIndex.getEditLink()).execute();
- assertEquals(204, deleteRes.getStatusCode());
- }
-
- @Test
- public void cudAsAtom() {
- cud(ContentType.APPLICATION_ATOM_XML);
- }
-
- @Test
- public void cudAsJSON() {
- cud(ContentType.JSON_FULL_METADATA);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/v4/OperationImportInvokeTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/OperationImportInvokeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/OperationImportInvokeTestITCase.java
deleted file mode 100644
index d6d535b..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/v4/OperationImportInvokeTestITCase.java
+++ /dev/null
@@ -1,294 +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 org.apache.olingo.fit.v4;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.apache.olingo.client.api.communication.request.invoke.ClientNoContent;
-import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
-import org.apache.olingo.client.api.domain.ClientCollectionValue;
-import org.apache.olingo.client.api.domain.ClientComplexValue;
-import org.apache.olingo.client.api.domain.ClientEntity;
-import org.apache.olingo.client.api.domain.ClientEntitySet;
-import org.apache.olingo.client.api.domain.ClientEnumValue;
-import org.apache.olingo.client.api.domain.ClientPrimitiveValue;
-import org.apache.olingo.client.api.domain.ClientProperty;
-import org.apache.olingo.client.api.domain.ClientValue;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.junit.Test;
-
-public class OperationImportInvokeTestITCase extends AbstractTestITCase {
-
- private void functionImports(final ContentType contentType) throws EdmPrimitiveTypeException {
- // GetDefaultColor
- final ODataInvokeRequest<ClientProperty> defaultColorReq = getClient().getInvokeRequestFactory().
- getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
- appendOperationCallSegment("GetDefaultColor").build(), ClientProperty.class);
- defaultColorReq.setFormat(contentType);
- final ClientProperty defaultColor = defaultColorReq.execute().getBody();
- assertNotNull(defaultColor);
- assertTrue(defaultColor.hasEnumValue());
- assertEquals("Red", defaultColor.getEnumValue().getValue());
- assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Color", defaultColor.getEnumValue().getTypeName());
-
- // GetPerson2
- final ClientPrimitiveValue city = getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("London");
-
- final ODataInvokeRequest<ClientEntity> person2Req = getClient().getInvokeRequestFactory().
- getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
- appendOperationCallSegment("GetPerson2").build(), ClientEntity.class,
- Collections.<String, ClientValue> singletonMap("city", city));
- person2Req.setFormat(contentType);
- final ClientEntity person2 = person2Req.execute().getBody();
- assertNotNull(person2);
- assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", person2.getTypeName().toString());
- assertEquals(1, person2.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0);
-
- // GetPerson
- final ClientComplexValue address = getClient().getObjectFactory().
- newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
- address.add(client.getObjectFactory().newPrimitiveProperty("Street",
- client.getObjectFactory().newPrimitiveValueBuilder().buildString("1 Microsoft Way")));
- address.add(client.getObjectFactory().newPrimitiveProperty("City",
- client.getObjectFactory().newPrimitiveValueBuilder().buildString("London")));
- address.add(client.getObjectFactory().newPrimitiveProperty("PostalCode",
- client.getObjectFactory().newPrimitiveValueBuilder().buildString("98052")));
-
- final ODataInvokeRequest<ClientEntity> personReq = getClient().getInvokeRequestFactory().
- getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
- appendOperationCallSegment("GetPerson").build(), ClientEntity.class,
- Collections.<String, ClientValue> singletonMap("address", address));
- personReq.setFormat(contentType);
- final ClientEntity person = personReq.execute().getBody();
- assertNotNull(person);
- assertEquals(person2, person);
-
- // GetAllProducts
- final ODataInvokeRequest<ClientEntitySet> productsReq = getClient().getInvokeRequestFactory()
- .getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
- appendOperationCallSegment("GetAllProducts").build(), ClientEntitySet.class);
- productsReq.setFormat(contentType);
- final ClientEntitySet products = productsReq.execute().getBody();
- assertNotNull(products);
- assertEquals(5, products.getEntities().size());
-
- // GetProductsByAccessLevel
- final ClientEnumValue accessLevel = getClient().getObjectFactory().
- newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.AccessLevel", "None");
-
- final ODataInvokeRequest<ClientProperty> prodByALReq = getClient().getInvokeRequestFactory().
- getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
- appendOperationCallSegment("GetProductsByAccessLevel").build(), ClientProperty.class,
- Collections.<String, ClientValue> singletonMap("accessLevel", accessLevel));
- prodByALReq.setFormat(contentType);
- final ClientProperty prodByAL = prodByALReq.execute().getBody();
- assertNotNull(prodByAL);
- assertTrue(prodByAL.hasCollectionValue());
- assertEquals(5, prodByAL.getCollectionValue().size());
- assertTrue(prodByAL.getCollectionValue().asJavaCollection().contains("Car"));
- }
-
- @Test
- public void atomFunctionImports() throws EdmPrimitiveTypeException {
- functionImports(ContentType.APPLICATION_ATOM_XML);
- }
-
- @Test
- public void jsonFunctionImports() throws EdmPrimitiveTypeException {
- functionImports(ContentType.JSON_FULL_METADATA);
- }
-
- @Test
- public void edmEnabledFunctionImports() throws EdmPrimitiveTypeException {
- // GetDefaultColor
- final ODataInvokeRequest<ClientProperty> defaultColorReq = edmClient.getInvokeRequestFactory().
- getFunctionImportInvokeRequest("GetDefaultColor");
- final ClientProperty defaultColor = defaultColorReq.execute().getBody();
- assertNotNull(defaultColor);
- assertTrue(defaultColor.hasEnumValue());
- assertEquals("Red", defaultColor.getEnumValue().getValue());
- assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Color", defaultColor.getEnumValue().getTypeName());
-
- // GetPerson2
- final ClientPrimitiveValue city =
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("London");
- final ODataInvokeRequest<ClientEntity> person2Req = edmClient.getInvokeRequestFactory().
- getFunctionImportInvokeRequest(
- "GetPerson2", Collections.<String, ClientValue> singletonMap("city", city));
- final ClientEntity person2 = person2Req.execute().getBody();
- assertNotNull(person2);
- assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", person2.getTypeName().toString());
- assertEquals(1, person2.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0);
-
- // GetPerson
- final ClientComplexValue address = getClient().getObjectFactory().
- newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
- address.add(client.getObjectFactory().newPrimitiveProperty("Street",
- client.getObjectFactory().newPrimitiveValueBuilder().buildString("1 Microsoft Way")));
- address.add(client.getObjectFactory().newPrimitiveProperty("City",
- client.getObjectFactory().newPrimitiveValueBuilder().buildString("London")));
- address.add(client.getObjectFactory().newPrimitiveProperty("PostalCode",
- client.getObjectFactory().newPrimitiveValueBuilder().buildString("98052")));
-
- final ODataInvokeRequest<ClientEntity> personReq = edmClient.getInvokeRequestFactory().
- getFunctionImportInvokeRequest(
- "GetPerson", Collections.<String, ClientValue> singletonMap("address", address));
- final ClientEntity person = personReq.execute().getBody();
- assertNotNull(person);
- assertEquals(person2, person);
-
- // GetAllProducts
- final ODataInvokeRequest<ClientEntitySet> productsReq = edmClient.getInvokeRequestFactory().
- getFunctionImportInvokeRequest("GetAllProducts");
- final ClientEntitySet products = productsReq.execute().getBody();
- assertNotNull(products);
- assertEquals(5, products.getEntities().size());
-
- // GetProductsByAccessLevel
- final ClientEnumValue accessLevel = getClient().getObjectFactory().
- newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.AccessLevel", "None");
-
- final ODataInvokeRequest<ClientProperty> prodByALReq = edmClient.getInvokeRequestFactory().
- getFunctionImportInvokeRequest(
- "GetProductsByAccessLevel",
- Collections.<String, ClientValue> singletonMap("accessLevel", accessLevel));
- final ClientProperty prodByAL = prodByALReq.execute().getBody();
- assertNotNull(prodByAL);
- assertTrue(prodByAL.hasCollectionValue());
- assertEquals(5, prodByAL.getCollectionValue().size());
- assertTrue(prodByAL.getCollectionValue().asJavaCollection().contains("Car"));
- }
-
- private void actionImports(final ContentType contentType) {
- // Discount
- final ClientPrimitiveValue percentage = getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(22);
- final ODataInvokeRequest<ClientNoContent> discountReq = getClient().getInvokeRequestFactory().
- getActionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
- appendOperationCallSegment("Discount").build(), ClientNoContent.class,
- Collections.<String, ClientValue> singletonMap("percentage", percentage));
- discountReq.setFormat(contentType);
- final ClientNoContent discount = discountReq.execute().getBody();
- assertNotNull(discount);
-
- // ResetBossAddress
- final ClientComplexValue address = getClient().getObjectFactory().
- newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
- address.add(client.getObjectFactory().newPrimitiveProperty("Street",
- client.getObjectFactory().newPrimitiveValueBuilder().buildString("Via Le Mani Dal Naso, 123")));
- address.add(client.getObjectFactory().newPrimitiveProperty("City",
- client.getObjectFactory().newPrimitiveValueBuilder().buildString("Tollo")));
- address.add(client.getObjectFactory().newPrimitiveProperty("PostalCode",
- client.getObjectFactory().newPrimitiveValueBuilder().buildString("66010")));
-
- final ODataInvokeRequest<ClientProperty> resetBossAddressReq = getClient().getInvokeRequestFactory().
- getActionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
- appendOperationCallSegment("ResetBossAddress").build(), ClientProperty.class,
- Collections.<String, ClientValue> singletonMap("address", address));
- resetBossAddressReq.setFormat(contentType);
- final ClientProperty resetBossAddress = resetBossAddressReq.execute().getBody();
- assertNotNull(resetBossAddress);
- assertEquals(address, resetBossAddress.getComplexValue());
- }
-
- @Test
- public void atomActionImports() {
- actionImports(ContentType.APPLICATION_ATOM_XML);
- }
-
- @Test
- public void jsonActionImports() {
- actionImports(ContentType.JSON_FULL_METADATA);
- }
-
- @Test
- public void edmEnabledActionImports() {
- // Discount
- final ClientPrimitiveValue percentage = getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(22);
- final ODataInvokeRequest<ClientNoContent> discountReq = edmClient.getInvokeRequestFactory().
- getActionImportInvokeRequest(
- "Discount", Collections.<String, ClientValue> singletonMap("percentage", percentage));
- final ClientNoContent discount = discountReq.execute().getBody();
- assertNotNull(discount);
-
- // ResetBossAddress
- final ClientComplexValue address = getClient().getObjectFactory().
- newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
- address.add(client.getObjectFactory().newPrimitiveProperty("Street",
- client.getObjectFactory().newPrimitiveValueBuilder().buildString("Via Le Mani Dal Naso, 123")));
- address.add(client.getObjectFactory().newPrimitiveProperty("City",
- client.getObjectFactory().newPrimitiveValueBuilder().buildString("Tollo")));
- address.add(client.getObjectFactory().newPrimitiveProperty("PostalCode",
- client.getObjectFactory().newPrimitiveValueBuilder().buildString("66010")));
-
- final ODataInvokeRequest<ClientProperty> resetBossAddressReq = edmClient.getInvokeRequestFactory().
- getActionImportInvokeRequest(
- "ResetBossAddress", Collections.<String, ClientValue> singletonMap("address", address));
- final ClientProperty resetBossAddress = resetBossAddressReq.execute().getBody();
- assertNotNull(resetBossAddress);
- assertEquals(address.getTypeName(), resetBossAddress.getComplexValue().getTypeName());
- }
-
- private void bossEmails(final ContentType contentType) {
- // ResetBossEmail
- final ClientCollectionValue<ClientValue> emails =
- getClient().getObjectFactory().newCollectionValue("Collection(Edm.String)");
- emails.add(getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("first@olingo.apache.org"));
- emails.add(getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("second@olingo.apache.org"));
- ODataInvokeRequest<ClientProperty> bossEmailsReq = getClient().getInvokeRequestFactory().
- getActionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
- appendOperationCallSegment("ResetBossEmail").build(), ClientProperty.class,
- Collections.<String, ClientValue> singletonMap("emails", emails));
- bossEmailsReq.setFormat(contentType);
- final ClientProperty bossEmails = bossEmailsReq.execute().getBody();
- assertNotNull(bossEmails);
- assertTrue(bossEmails.hasCollectionValue());
- assertEquals(2, bossEmails.getCollectionValue().size());
-
- final Map<String, ClientValue> params = new LinkedHashMap<String, ClientValue>(2);
- params.put("start", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(0));
- params.put("count", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(100));
- bossEmailsReq = getClient().getInvokeRequestFactory().getFunctionInvokeRequest(
- getClient().newURIBuilder(testStaticServiceRootURL).
- appendOperationCallSegment("GetBossEmails").build(), ClientProperty.class, params);
- bossEmailsReq.setFormat(contentType);
- final ClientProperty bossEmailsViaGET = bossEmailsReq.execute().getBody();
- assertNotNull(bossEmailsViaGET);
- assertTrue(bossEmailsViaGET.hasCollectionValue());
- assertEquals(2, bossEmailsViaGET.getCollectionValue().size());
- assertEquals(bossEmails.getCollectionValue().asJavaCollection(),
- bossEmailsViaGET.getCollectionValue().asJavaCollection());
- }
-
- @Test
- public void atomBossEmails() throws EdmPrimitiveTypeException {
- bossEmails(ContentType.APPLICATION_ATOM_XML);
- }
-
- @Test
- public void jsonBossEmails() throws EdmPrimitiveTypeException {
- bossEmails(ContentType.JSON_FULL_METADATA);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/v4/PropertyTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/PropertyTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/PropertyTestITCase.java
deleted file mode 100644
index cb94f83..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/v4/PropertyTestITCase.java
+++ /dev/null
@@ -1,203 +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 org.apache.olingo.fit.v4;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.IOException;
-
-import org.apache.olingo.client.api.ODataClient;
-import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
-import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
-import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest;
-import org.apache.olingo.client.api.communication.request.cud.UpdateType;
-import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
-import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
-import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
-import org.apache.olingo.client.api.communication.response.ODataPropertyUpdateResponse;
-import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
-import org.apache.olingo.client.api.domain.ClientEntity;
-import org.apache.olingo.client.api.domain.ClientProperty;
-import org.apache.olingo.client.api.domain.ClientValuable;
-import org.apache.olingo.client.api.uri.URIBuilder;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.api.http.HttpMethod;
-import org.junit.Test;
-
-public class PropertyTestITCase extends AbstractTestITCase {
-
- private void _enum(final ODataClient client, final ContentType contentType) {
- final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("Products").appendKeySegment(5).appendPropertySegment("CoverColors");
- final ODataPropertyRequest<ClientProperty> req = client.getRetrieveRequestFactory().
- getPropertyRequest(uriBuilder.build());
- req.setFormat(contentType);
-
- final ClientProperty prop = req.execute().getBody();
- assertNotNull(prop);
- // cast to workaround JDK 6 bug, fixed in JDK 7
- assertEquals("Collection(Microsoft.Test.OData.Services.ODataWCFService.Color)",
- ((ClientValuable) prop).getValue().getTypeName());
- }
-
- @Test
- public void enumFromXML() {
- _enum(client, ContentType.APPLICATION_XML);
- }
-
- @Test
- public void enumFromJSON() {
- _enum(edmClient, ContentType.JSON);
- }
-
- @Test
- public void enumFromFullJSON() {
- _enum(client, ContentType.JSON_FULL_METADATA);
- }
-
- private void geospatial(final ODataClient client, final ContentType contentType) {
- final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Home");
- final ODataPropertyRequest<ClientProperty> req = client.getRetrieveRequestFactory().
- getPropertyRequest(uriBuilder.build());
- req.setFormat(contentType);
-
- final ClientProperty prop = req.execute().getBody();
- assertNotNull(prop);
- // cast to workaround JDK 6 bug, fixed in JDK 7
- assertEquals("Edm.GeographyPoint", ((ClientValuable) prop).getValue().getTypeName());
- }
-
- @Test
- public void geospatialFromXML() {
- geospatial(client, ContentType.APPLICATION_XML);
- }
-
- @Test
- public void geospatialFromJSON() {
- geospatial(edmClient, ContentType.JSON);
- }
-
- @Test
- public void geospatialFromFullJSON() {
- geospatial(client, ContentType.JSON_FULL_METADATA);
- }
-
- private void complex(final ODataClient client, final ContentType contentType) {
- final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("Customers").appendKeySegment(2).appendPropertySegment("HomeAddress");
- final ODataPropertyRequest<ClientProperty> req = client.getRetrieveRequestFactory().
- getPropertyRequest(uriBuilder.build());
- req.setFormat(contentType);
-
- final ClientProperty prop = req.execute().getBody();
- assertNotNull(prop);
- // cast to workaround JDK 6 bug, fixed in JDK 7
- assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Address",
- ((ClientValuable) prop).getValue().getTypeName());
- }
-
- @Test
- public void complexFromXML() {
- complex(client, ContentType.APPLICATION_XML);
- }
-
- @Test
- public void complexFromJSON() {
- complex(edmClient, ContentType.JSON);
- }
-
- @Test
- public void complexFromFullJSON() {
- complex(client, ContentType.JSON_FULL_METADATA);
- }
-
- private void updateComplexProperty(final ContentType contentType, final UpdateType type) throws IOException {
- final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("Customers").appendKeySegment(1).appendPropertySegment("HomeAddress");
-
- ODataPropertyRequest<ClientProperty> retrieveReq =
- client.getRetrieveRequestFactory().getPropertyRequest(uriBuilder.build());
- retrieveReq.setFormat(contentType);
-
- ODataRetrieveResponse<ClientProperty> retrieveRes = retrieveReq.execute();
- assertEquals(200, retrieveRes.getStatusCode());
-
- ClientProperty homeAddress = client.getObjectFactory().newComplexProperty("HomeAddress",
- client.getObjectFactory().newComplexValue(retrieveRes.getBody().getComplexValue().getTypeName()));
-
- homeAddress.getComplexValue().add(client.getObjectFactory().
- newPrimitiveProperty("City", client.getObjectFactory().newPrimitiveValueBuilder().buildString("Pescara")));
-
- final ODataPropertyUpdateRequest updateReq = client.getCUDRequestFactory().
- getPropertyComplexValueUpdateRequest(uriBuilder.build(), type, homeAddress);
- if (client.getConfiguration().isUseXHTTPMethod()) {
- assertEquals(HttpMethod.POST, updateReq.getMethod());
- } else {
- assertEquals(type.getMethod(), updateReq.getMethod());
- }
- updateReq.setFormat(contentType);
-
- final ODataPropertyUpdateResponse updateRes = updateReq.execute();
- assertEquals(204, updateRes.getStatusCode());
-
- retrieveReq = client.getRetrieveRequestFactory().getPropertyRequest(uriBuilder.build());
- retrieveReq.setFormat(contentType);
-
- retrieveRes = retrieveReq.execute();
- assertEquals(200, retrieveRes.getStatusCode());
-
- homeAddress = retrieveRes.getBody();
- assertEquals("Pescara", homeAddress.getComplexValue().get("City").getPrimitiveValue().toString());
- }
-
- @Test
- public void patchComplexPropertyAsJSON() throws IOException {
- updateComplexProperty(ContentType.JSON_FULL_METADATA, UpdateType.PATCH);
- }
-
- @Test
- public void createAndDelete() {
- // 1. create
- final ClientEntity category = client.getObjectFactory().newEntity(null);
- category.setId(client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("Categories").appendKeySegment(1).build());
-
- final URIBuilder createBuilder = client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("Products").appendKeySegment(0).appendNavigationSegment("Categories").
- appendRefSegment();
- final ODataEntityCreateRequest<ClientEntity> createReq = client.getCUDRequestFactory().
- getEntityCreateRequest(createBuilder.build(), category);
-
- final ODataEntityCreateResponse<ClientEntity> createRes = createReq.execute();
- assertEquals(204, createRes.getStatusCode());
-
- // 2. delete
- final URIBuilder deleteBuilder = client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("Products").appendKeySegment(0).appendNavigationSegment("Categories").
- appendKeySegment(1).appendRefSegment();
- final ODataDeleteRequest deleteReq = client.getCUDRequestFactory().
- getDeleteRequest(deleteBuilder.build());
-
- final ODataDeleteResponse deleteRes = deleteReq.execute();
- assertEquals(204, deleteRes.getStatusCode());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java
deleted file mode 100644
index c2eadc2..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java
+++ /dev/null
@@ -1,138 +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 org.apache.olingo.fit.v4;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.client.api.communication.ODataClientErrorException;
-import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
-import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
-import org.apache.olingo.client.api.domain.ClientPrimitiveValue;
-import org.apache.olingo.client.api.domain.ClientProperty;
-import org.apache.olingo.client.api.domain.ClientValuable;
-import org.apache.olingo.client.api.uri.URIBuilder;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.junit.Test;
-
-public class PropertyValueTestITCase extends AbstractTestITCase {
-
- @Test
- public void retrieveIntPropertyValueTest() throws EdmPrimitiveTypeException {
- final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PersonID");
- final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setFormat(ContentType.TEXT_PLAIN);
- assertEquals("5", req.execute().getBody().toString());
- }
-
- @Test
- public void retrieveBooleanPropertyValueTest() throws EdmPrimitiveTypeException {
- final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("IsRegistered");
- final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setFormat(ContentType.TEXT_PLAIN);
- assertEquals("true", req.execute().getBody().toString());
- }
-
- @Test
- public void retrieveStringPropertyValueTest() throws EdmPrimitiveTypeException {
- final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("FirstName");
- final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setFormat(ContentType.TEXT_PLAIN);
- assertEquals("Peter", req.execute().getBody().toString());
- }
-
- @Test
- public void retrieveDatePropertyValueTest() {
- final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("Orders").appendKeySegment(8).appendPropertySegment("OrderDate");
- final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setFormat(ContentType.TEXT_PLAIN);
- final ClientPrimitiveValue property = req.execute().getBody();
- assertEquals("2011-03-04T16:03:57Z", property.toString());
- }
-
- @Test
- public void retrieveDecimalPropertyValueTest() throws EdmPrimitiveTypeException {
- final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Height");
- final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setFormat(ContentType.TEXT_PLAIN);
- final ClientPrimitiveValue property = req.execute().getBody();
- assertEquals("179", property.toString());
- }
-
- @Test
- public void retrieveBinaryPropertyValueTest() throws IOException {
- final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC");
- final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setFormat(ContentType.TEXT_PLAIN);
- final ClientPrimitiveValue property = req.execute().getBody();
- assertEquals("fi653p3+MklA/LdoBlhWgnMTUUEo8tEgtbMXnF0a3CUNL9BZxXpSRiD9ebTnmNR0zWPjJ"
- + "VIDx4tdmCnq55XrJh+RW9aI/b34wAogK3kcORw=", property.toString());
- }
-
- @Test(expected = ODataClientErrorException.class)
- public void retrieveBinaryPropertyValueTestWithAtom() throws IOException {
- final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC");
- final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setAccept(ContentType.APPLICATION_ATOM_XML.toContentTypeString());
- req.execute().getBody();
- }
-
- @Test(expected = ODataClientErrorException.class)
- public void retrieveBinaryPropertyValueTestWithXML() throws IOException {
- final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC");
- final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setAccept(ContentType.APPLICATION_XML.toContentTypeString());
- req.execute().getBody();
- }
-
- @Test
- public void retrieveCollectionPropertyValueTest() {
- final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Numbers");
- final ODataPropertyRequest<ClientProperty> req = client.getRetrieveRequestFactory().
- getPropertyRequest(uriBuilder.build());
- req.setFormat(ContentType.APPLICATION_XML);
- final ClientProperty property = req.execute().getBody();
- // cast to workaround JDK 6 bug, fixed in JDK 7
- assertTrue(((ClientValuable) property).getValue().isCollection());
- assertEquals("555-555-5555", property.getCollectionValue().iterator().next().asPrimitive().toString());
- }
-
- @Test
- public void retrieveNullPropertyValueTest() {
- final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("HomeAddress");
- final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
- req.setFormat(ContentType.TEXT_PLAIN);
- final ClientPrimitiveValue property = req.execute().getBody();
- assertTrue(StringUtils.isBlank(property.toString()));
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/v4/QueryOptionsTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/QueryOptionsTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/QueryOptionsTestITCase.java
deleted file mode 100644
index b9119f8..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/v4/QueryOptionsTestITCase.java
+++ /dev/null
@@ -1,246 +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 org.apache.olingo.fit.v4;
-
-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.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
-import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
-import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
-import org.apache.olingo.client.api.domain.ClientEntity;
-import org.apache.olingo.client.api.domain.ClientEntitySet;
-import org.apache.olingo.client.api.domain.ClientInlineEntitySet;
-import org.apache.olingo.client.api.uri.QueryOption;
-import org.apache.olingo.client.api.uri.URIBuilder;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.junit.Test;
-
-/**
- * This is the unit test class to check for query options.
- */
-public class QueryOptionsTestITCase extends AbstractTestITCase {
-
- /**
- * Test <tt>$expand</tt>.
- */
- public void expand() {
- final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("Customers").appendKeySegment(1).expand("Orders");
-
- final ODataEntityRequest<ClientEntity> req =
- client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
-
- final ClientEntity customer = req.execute().getBody();
- assertTrue(customer.getNavigationLink("Orders") instanceof ClientInlineEntitySet);
- }
-
- @Test
- public void expandWithFilter() {
- final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("Customers").appendKeySegment(1).
- expandWithOptions("Orders", Collections.<QueryOption, Object> singletonMap(
- QueryOption.FILTER, getClient().getFilterFactory().gt("OrderID", 7).build()));
-
- final ODataEntityRequest<ClientEntity> req =
- client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
-
- final ClientEntity customer = req.execute().getBody();
- assertTrue(customer.getNavigationLink("Orders") instanceof ClientInlineEntitySet);
- }
-
- /**
- * Test <tt>$filter</tt> and <tt>$orderby</tt>.
- *
- * @see org.apache.olingo.fit.v4.FilterFactoryTestITCase for more tests.
- */
- @Test
- public void filterOrderby() throws EdmPrimitiveTypeException {
- final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").filter("(PersonID lt 3)");
-
- // 1. check that filtered entity set looks as expected
- ODataEntitySetRequest<ClientEntitySet> req =
- client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
-
- ClientEntitySet feed = req.execute().getBody();
- assertNotNull(feed);
- assertEquals(2, feed.getEntities().size());
-
- // 2. extract PersonID values - sorted ASC by default
- final List<Integer> former = new ArrayList<Integer>(2);
- for (ClientEntity entity : feed.getEntities()) {
- final Integer personID = entity.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class);
- assertTrue(personID < 3);
- former.add(personID);
- }
-
- // 3. add orderby clause to filter above
- req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.orderBy("PersonID desc").build());
-
- feed = req.execute().getBody();
- assertNotNull(feed);
- assertEquals(2, feed.getEntities().size());
-
- // 4. extract again VIN value - now they were required to be sorted DESC
- final List<Integer> latter = new ArrayList<Integer>(2);
- for (ClientEntity entity : feed.getEntities()) {
- final Integer personID = entity.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class);
- assertTrue(personID < 3);
- latter.add(personID);
- }
-
- // 5. reverse latter and expect to be equal to former
- Collections.reverse(latter);
- assertEquals(former, latter);
- }
-
- /**
- * Test <tt>$format</tt>.
- */
- @Test
- public void format() {
- final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("Customers").appendKeySegment(1).format("json");
-
- final ODataEntityRequest<ClientEntity> req =
- client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(ContentType.APPLICATION_ATOM_XML);
-
- final ODataRetrieveResponse<ClientEntity> res = req.execute();
- assertNotNull(res);
- assertTrue(res.getContentType().replaceAll(" ", "").
- startsWith(ContentType.JSON.toContentTypeString()));
- }
-
- /**
- * Test <tt>$skip</tt>.
- */
- public void skip() {
- final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
-
- // 1. check that filtered entity set looks as expected
- final ODataEntitySetRequest<ClientEntitySet> req =
- client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.skip(2).build());
-
- final ClientEntitySet feed = req.execute().getBody();
- assertEquals(3, feed.getEntities().size());
- }
-
- /**
- * Test <tt>$top</tt>.
- */
- public void top() {
- final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
-
- // 1. check that filtered entity set looks as expected
- final ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().
- getEntitySetRequest(uriBuilder.top(2).build());
-
- final ClientEntitySet feed = req.execute().getBody();
- assertEquals(2, feed.getEntities().size());
- }
-
- /**
- * Test <tt>$skiptoken</tt>.
- */
- @Test
- public void skiptoken() throws EdmPrimitiveTypeException {
- final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL);
- uriBuilder.appendEntitySetSegment("People").skipToken("5");
-
- final ODataEntitySetRequest<ClientEntitySet> req =
- client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
-
- final ClientEntitySet feed = req.execute().getBody();
- assertNotNull(feed);
- assertEquals(1, feed.getEntities().size());
-
- for (ClientEntity entity : feed.getEntities()) {
- assertTrue(entity.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class) > 5);
- }
- }
-
- /**
- * Test <tt>$inlinecount</tt>.
- */
- @Test
- public void count() {
- final URIBuilder uriBuilder =
- client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").count(true);
-
- final ODataEntitySetRequest<ClientEntitySet> req =
- client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
-
- final ClientEntitySet feed = req.execute().getBody();
- assertNotNull(feed);
- assertEquals(Integer.valueOf(feed.getEntities().size()), feed.getCount());
- }
-
- /**
- * Test <tt>$select</tt>.
- */
- @Test
- public void select() {
- final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("Customers").appendKeySegment(1).select("PersonID,Orders").expand("Orders");
-
- final ODataEntityRequest<ClientEntity> req =
- client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
-
- final ClientEntity customer = req.execute().getBody();
- assertEquals(1, customer.getProperties().size());
- assertEquals(1, customer.getNavigationLinks().size());
- assertTrue((customer.getNavigationLinks().get(0) instanceof ClientInlineEntitySet));
- }
-
- @Test
- public void issue253() {
- final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("relatedEntitySelect").appendEntitySetSegment("Customers").appendKeySegment(1).
- expandWithSelect("Orders", "OrderID", "OrderDetails");
-
- final ODataEntityRequest<ClientEntity> req =
- client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
-
- final ODataRetrieveResponse<ClientEntity> res = req.execute();
- assertEquals(200, res.getStatusCode());
- }
-
- @Test
- public void search() {
- final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").search(client.getSearchFactory().
- or(client.getSearchFactory().literal("Bob"), client.getSearchFactory().literal("Jill")));
-
- final ODataEntitySetRequest<ClientEntitySet> req =
- client.getRetrieveRequestFactory().getEntitySetRequest(builder.build());
-
- final ODataRetrieveResponse<ClientEntitySet> res = req.execute();
- assertEquals(200, res.getStatusCode());
- assertFalse(res.getBody().getEntities().isEmpty());
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/v4/ServiceDocumentTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/ServiceDocumentTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/ServiceDocumentTestITCase.java
deleted file mode 100644
index 69a869c..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/v4/ServiceDocumentTestITCase.java
+++ /dev/null
@@ -1,63 +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 org.apache.olingo.fit.v4;
-
-import static org.junit.Assert.assertEquals;
-
-import java.net.URI;
-
-import org.apache.olingo.client.api.communication.request.retrieve.ODataServiceDocumentRequest;
-import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
-import org.apache.olingo.client.api.domain.ClientServiceDocument;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.junit.Test;
-
-public class ServiceDocumentTestITCase extends AbstractTestITCase {
-
- private void retrieveServiceDocument(final ContentType contentType) {
- final ODataServiceDocumentRequest req =
- client.getRetrieveRequestFactory().getServiceDocumentRequest(testStaticServiceRootURL);
- req.setFormat(contentType);
-
- final ODataRetrieveResponse<ClientServiceDocument> res = req.execute();
- assertEquals(200, res.getStatusCode());
-
- final ClientServiceDocument serviceDocument = res.getBody();
- assertEquals(12, serviceDocument.getEntitySets().size());
- assertEquals(6, serviceDocument.getSingletons().size());
- assertEquals(6, serviceDocument.getFunctionImports().size());
-
- assertEquals(URI.create(testStaticServiceRootURL + "/ProductDetails"),
- serviceDocument.getEntitySetURI("ProductDetails"));
- assertEquals(URI.create(testStaticServiceRootURL + "/Boss"),
- serviceDocument.getSingletonURI("Boss"));
- assertEquals(URI.create(testStaticServiceRootURL + "/GetPerson"),
- serviceDocument.getFunctionImportURI("GetPerson"));
- }
-
- @Test
- public void retrieveServiceDocumentAsXML() {
- retrieveServiceDocument(ContentType.APPLICATION_XML);
- }
-
- @Test
- public void retrieveServiceDocumentAsJSON() {
- retrieveServiceDocument(ContentType.JSON);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/v4/SingletonTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/SingletonTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/SingletonTestITCase.java
deleted file mode 100644
index 7f4e2f8..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/v4/SingletonTestITCase.java
+++ /dev/null
@@ -1,135 +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 org.apache.olingo.fit.v4;
-
-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 org.apache.olingo.client.api.ODataClient;
-import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
-import org.apache.olingo.client.api.communication.request.cud.UpdateType;
-import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
-import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
-import org.apache.olingo.client.api.domain.ClientAnnotation;
-import org.apache.olingo.client.api.domain.ClientSingleton;
-import org.apache.olingo.client.api.domain.ClientValuable;
-import org.apache.olingo.client.api.uri.URIBuilder;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.junit.Test;
-
-public class SingletonTestITCase extends AbstractTestITCase {
-
- private void read(final ODataClient client, final ContentType contentType) throws EdmPrimitiveTypeException {
- final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company");
- final ODataEntityRequest<ClientSingleton> singleton =
- client.getRetrieveRequestFactory().getSingletonRequest(builder.build());
- singleton.setFormat(contentType);
- final ClientSingleton company = singleton.execute().getBody();
- assertNotNull(company);
-
- assertEquals(0, company.getProperty("CompanyID").getPrimitiveValue().toCastValue(Integer.class), 0);
- // cast to workaround JDK 6 bug, fixed in JDK 7
- assertEquals("Microsoft.Test.OData.Services.ODataWCFService.CompanyCategory",
- ((ClientValuable) company.getProperty("CompanyCategory")).getValue().getTypeName());
- assertTrue(company.getProperty("CompanyCategory").hasEnumValue());
- }
-
- @Test
- public void readFromAtom() throws EdmPrimitiveTypeException {
- read(client, ContentType.APPLICATION_ATOM_XML);
- }
-
- @Test
- public void readFromJSON() throws EdmPrimitiveTypeException {
- read(edmClient, ContentType.JSON);
- }
-
- @Test
- public void readfromJSONFull() throws EdmPrimitiveTypeException {
- read(client, ContentType.JSON_FULL_METADATA);
- }
-
- private void readWithAnnotations(final ODataClient client, final ContentType contentType)
- throws EdmPrimitiveTypeException {
-
- final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Boss");
- final ODataEntityRequest<ClientSingleton> singleton =
- client.getRetrieveRequestFactory().getSingletonRequest(builder.build());
- singleton.setFormat(contentType);
- singleton.setPrefer(client.newPreferences().includeAnnotations("*"));
- final ClientSingleton boss = singleton.execute().getBody();
- assertNotNull(boss);
-
- assertFalse(boss.getAnnotations().isEmpty());
- final ClientAnnotation isBoss = boss.getAnnotations().get(0);
- assertTrue(isBoss.getPrimitiveValue().toCastValue(Boolean.class));
- }
-
- @Test
- public void readWithAnnotationsFromAtom() throws EdmPrimitiveTypeException {
- readWithAnnotations(client, ContentType.APPLICATION_ATOM_XML);
- }
-
- @Test
- public void readWithAnnotationsFromJSON() throws EdmPrimitiveTypeException {
- readWithAnnotations(edmClient, ContentType.JSON);
- }
-
- @Test
- public void readWithAnnotationsFromJSONFull() throws EdmPrimitiveTypeException {
- readWithAnnotations(client, ContentType.JSON_FULL_METADATA);
- }
-
- private void update(final ContentType contentType) throws EdmPrimitiveTypeException {
- final ClientSingleton changes = getClient().getObjectFactory().newSingleton(
- new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Company"));
- changes.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("Revenue",
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt64(132520L)));
-
- final URI uri = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company").build();
- final ODataEntityUpdateRequest<ClientSingleton> req = getClient().getCUDRequestFactory().
- getSingletonUpdateRequest(uri, UpdateType.PATCH, changes);
- req.setFormat(contentType);
-
- final ODataEntityUpdateResponse<ClientSingleton> res = req.execute();
- assertEquals(204, res.getStatusCode());
-
- final ClientSingleton updated =
- getClient().getRetrieveRequestFactory().getSingletonRequest(uri).execute().getBody();
- assertNotNull(updated);
- assertEquals(132520, updated.getProperty("Revenue").getPrimitiveValue().toCastValue(Integer.class), 0);
- }
-
- @Test
- public void atomUpdate() throws EdmPrimitiveTypeException {
- update(ContentType.APPLICATION_ATOM_XML);
- }
-
- @Test
- public void jsonUpdate() throws EdmPrimitiveTypeException {
- update(ContentType.JSON);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 6d6afa8..6b2359b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -526,13 +526,9 @@
<failOnViolation>true</failOnViolation>
<violationSeverity>warning</violationSeverity>
<!-- fit autogenerated (via pojogen plugin) resources -->
- <excludes>**/fit/proxy/v4/staticservice/**/*.java,
- **/fit/proxy/v3/staticservice/**/*.java,
- **/fit/proxy/v3/actionoverloading/**/*.java,
- **/fit/proxy/v3/primitivekeys/**/*.java,
- **/fit/proxy/v3/opentype/**/*.java,
- **/fit/proxy/v4/opentype/**/*.java,
- **/fit/proxy/v4/demo/**/*.java</excludes>
+ <excludes>**/fit/proxy/staticservice/**/*.java,
+ **/fit/proxy/opentype/**/*.java,
+ **/fit/proxy/demo/**/*.java</excludes>
</configuration>
</plugin>
<plugin>