You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by sk...@apache.org on 2014/03/10 10:02:39 UTC
[23/51] [abbrv] [partial] [OLINGO-192] rename java packages
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/URIBuilderTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/URIBuilderTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/URIBuilderTest.java
new file mode 100644
index 0000000..29069b7
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/URIBuilderTest.java
@@ -0,0 +1,136 @@
+/*
+ * 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.client.core.v4;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.olingo.client.api.ODataV4Client;
+import org.apache.olingo.client.api.uri.V4URIBuilder;
+import org.apache.olingo.client.core.AbstractTest;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class URIBuilderTest extends AbstractTest {
+
+ private static final String SERVICE_ROOT = "http://host/service";
+
+ @Override
+ protected ODataV4Client getClient() {
+ return v4Client;
+ }
+
+ @Test
+ public void count() throws URISyntaxException {
+ URI uri = getClient().getURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").count().build();
+
+ assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Products/$count").build(), uri);
+
+ uri = getClient().getURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").count(true).build();
+
+ assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Products").
+ addParameter("$count", "true").build(), uri);
+ }
+
+ @Test
+ public void singleton() throws URISyntaxException {
+ final V4URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).
+ appendSingletonSegment("BestProductEverCreated");
+
+ assertEquals(new org.apache.http.client.utils.URIBuilder(
+ SERVICE_ROOT + "/BestProductEverCreated").build(), uriBuilder.build());
+ }
+
+ @Test
+ public void entityId() throws URISyntaxException {
+ final V4URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).
+ appendEntityIdSegment("Products(0)");
+
+ assertEquals(new org.apache.http.client.utils.URIBuilder(
+ SERVICE_ROOT + "/$entity").addParameter("$id", "Products(0)").build(), uriBuilder.build());
+ }
+
+ @Test
+ public void boundAction() throws URISyntaxException {
+ final V4URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).
+ appendEntitySetSegment("Categories").appendKeySegment(1).
+ appendNavigationSegment("Products").appendNavigationSegment("Model").
+ appendOperationCallSegment("AllOrders", null);
+
+ assertEquals(new org.apache.http.client.utils.URIBuilder(
+ SERVICE_ROOT + "/Categories(1)/Products/Model.AllOrders()").build(), uriBuilder.build());
+ }
+
+ @Test
+ public void ref() throws URISyntaxException {
+ V4URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).
+ appendEntitySetSegment("Categories").appendKeySegment(1).
+ appendNavigationSegment("Products").appendRefSegment();
+
+ assertEquals(new org.apache.http.client.utils.URIBuilder(
+ SERVICE_ROOT + "/Categories(1)/Products/$ref").build(), uriBuilder.build());
+
+ uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).
+ appendEntitySetSegment("Categories").appendKeySegment(1).
+ appendNavigationSegment("Products").appendRefSegment().id("../../Products(0)");
+
+ assertEquals(new org.apache.http.client.utils.URIBuilder(
+ SERVICE_ROOT + "/Categories(1)/Products/$ref").addParameter("$id", "../../Products(0)").build(),
+ uriBuilder.build());
+ }
+
+ @Test
+ public void derived() throws URISyntaxException {
+ final V4URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).
+ appendEntitySetSegment("Customers").appendNavigationSegment("Model").
+ appendDerivedEntityTypeSegment("VipCustomer").appendKeySegment(1);
+
+ assertEquals(new org.apache.http.client.utils.URIBuilder(
+ SERVICE_ROOT + "/Customers/Model.VipCustomer(1)").build(), uriBuilder.build());
+ }
+
+ @Test
+ public void crossjoin() throws URISyntaxException {
+ final V4URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).
+ appendCrossjoinSegment("Products", "Sales");
+
+ assertEquals(new org.apache.http.client.utils.URIBuilder(
+ SERVICE_ROOT + "/$crossjoin(Products,Sales)").build(), uriBuilder.build());
+ }
+
+ @Test
+ public void all() throws URISyntaxException {
+ final V4URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).appendAllSegment();
+
+ assertEquals(new org.apache.http.client.utils.URIBuilder(
+ SERVICE_ROOT + "/$all").build(), uriBuilder.build());
+ }
+
+ @Test
+ public void search() throws URISyntaxException {
+ final V4URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).
+ appendEntitySetSegment("Products").search("blue OR green");
+
+ assertEquals(new org.apache.http.client.utils.URIBuilder(
+ SERVICE_ROOT + "/Products").addParameter("$search", "blue OR green").build(), uriBuilder.build());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/AbstractTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/AbstractTest.java b/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/AbstractTest.java
deleted file mode 100644
index e5d76e5..0000000
--- a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/AbstractTest.java
+++ /dev/null
@@ -1,58 +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.odata4.client.core;
-
-import java.util.Locale;
-import org.apache.olingo.odata4.client.api.ODataClient;
-import org.apache.olingo.odata4.client.api.ODataV3Client;
-import org.apache.olingo.odata4.client.api.ODataV4Client;
-import org.apache.olingo.odata4.client.api.format.ODataFormat;
-import org.apache.olingo.odata4.client.api.format.ODataPubFormat;
-import org.junit.BeforeClass;
-
-public abstract class AbstractTest {
-
- protected static ODataV3Client v3Client;
-
- protected static ODataV4Client v4Client;
-
- protected abstract ODataClient getClient();
-
- /**
- * This is needed for correct number handling (Double, for example).
- */
- @BeforeClass
- public static void setEnglishLocale() {
- Locale.setDefault(Locale.ENGLISH);
- }
-
- @BeforeClass
- public static void setClientInstances() {
- v3Client = ODataClientFactory.getV3();
- v4Client = ODataClientFactory.getV4();
- }
-
- protected String getSuffix(final ODataPubFormat format) {
- return format == ODataPubFormat.ATOM ? "xml" : "json";
- }
-
- protected String getSuffix(final ODataFormat format) {
- return format == ODataFormat.XML ? "xml" : "json";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/ODataClientTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/ODataClientTest.java b/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/ODataClientTest.java
deleted file mode 100644
index 0dc7004..0000000
--- a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/ODataClientTest.java
+++ /dev/null
@@ -1,40 +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.odata4.client.core;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertEquals;
-
-import org.apache.olingo.odata4.client.api.ODataClient;
-import org.apache.olingo.odata4.commons.api.edm.constants.ODataServiceVersion;
-import org.junit.Test;
-
-public class ODataClientTest {
-
- @Test
- public void before() {
- ODataClient client = ODataClientFactory.getV3();
- assertNotNull(client);
- assertEquals(ODataServiceVersion.V30, client.getServiceVersion());
-
- client = ODataClientFactory.getV4();
- assertNotNull(client);
- assertEquals(ODataServiceVersion.V40, client.getServiceVersion());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/deserializer/JsonReaderPerformance.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/deserializer/JsonReaderPerformance.java b/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/deserializer/JsonReaderPerformance.java
deleted file mode 100644
index 12d1bca..0000000
--- a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/deserializer/JsonReaderPerformance.java
+++ /dev/null
@@ -1,75 +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.odata4.client.core.deserializer;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.InputStream;
-import org.apache.commons.io.IOUtils;
-
-import org.apache.olingo.odata4.client.api.deserializer.ComplexValue;
-import org.apache.olingo.odata4.client.api.deserializer.Property;
-import org.apache.olingo.odata4.client.api.deserializer.StructuralProperty;
-import org.apache.olingo.odata4.client.api.deserializer.Value;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class JsonReaderPerformance {
-
- private static final Logger LOG = LoggerFactory.getLogger(JsonReaderPerformance.class);
-
- @Test
- public void testComplexPropertyPerformance() throws Exception {
- JsonReader consumer = new JsonReader();
- int runs = 1000; // * 100;
-
- InputStream in = JsonReaderPerformance.class.getResourceAsStream("/complexProperty.json");
- String content = IOUtils.toString(in);
-
- LOG.debug("Started...");
- ComplexValue complex = null;
- long startTime = System.currentTimeMillis();
- for (int i = 0; i < runs; i++) {
- Property property = consumer.readProperty(IOUtils.toInputStream(content));
- complex = (ComplexValue) ((StructuralProperty) property).getValue();
- }
- long endTime = System.currentTimeMillis();
-
- long duration = endTime - startTime;
- LOG.debug("Duration: " + duration + " ms");
- LOG.debug("Duration per run: " + (duration / (float) runs) + " ms");
- testComplexProperty(complex);
- }
-
- private void testComplexProperty(final Value value) {
- assertNotNull(value);
- assertTrue(value.isComplex());
-
- ComplexValue complex = (ComplexValue) value;
-
- assertEquals("Obere Str. 57", complex.getValue("Street").getContent());
- assertEquals("Berlin", complex.getValue("City").getContent());
- assertNull(complex.getValue("Region").getContent());
- assertEquals("D-12209", complex.getValue("PostalCode").getContent());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/deserializer/JsonReaderTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/deserializer/JsonReaderTest.java b/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/deserializer/JsonReaderTest.java
deleted file mode 100644
index 353ee1a..0000000
--- a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/deserializer/JsonReaderTest.java
+++ /dev/null
@@ -1,371 +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.odata4.client.core.deserializer;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.olingo.odata4.client.api.deserializer.ComplexValue;
-import org.apache.olingo.odata4.client.api.deserializer.Entity;
-import org.apache.olingo.odata4.client.api.deserializer.EntitySet;
-import org.apache.olingo.odata4.client.api.deserializer.Property;
-import org.apache.olingo.odata4.client.api.deserializer.Reader;
-import org.apache.olingo.odata4.client.api.deserializer.StructuralProperty;
-import org.apache.olingo.odata4.client.api.deserializer.Value;
-import org.junit.Test;
-
-public class JsonReaderTest {
-
- @Test
- public void testEntitySet() throws Exception {
- Reader consumer = new JsonReader();
-
- EntitySet entitySet = consumer.readEntitySet(
- JsonReaderTest.class.getResourceAsStream("/fullEntitySet.json"));
-
- List<Entity> entities = entitySet.getEntities();
- validateEntitySet(entitySet);
- assertNotNull(entities);
- Entity entity = entities.get(0);
- assertNotNull(entity);
- validateEntityAlfki(entity);
-
- StructuralProperty structuralProperty = entity.getProperty("Address", StructuralProperty.class);
- assertEquals("Address", structuralProperty.getName());
-
- Value value = structuralProperty.getValue();
- assertTrue(value.isComplex());
- ComplexValue complexValue = (ComplexValue) value;
- validateAddressBerlin(complexValue);
- validateComplexValueNavigationLinks(complexValue);
- }
-
- @Test
- public void testEntitySetWithTwoEntities() throws Exception {
- Reader consumer = new JsonReader();
-
- EntitySet entitySet = consumer.readEntitySet(getJson("/fullEntitySetWithTwoEntities.json"));
-
- List<Entity> entities = entitySet.getEntities();
- validateEntitySet(entitySet);
- assertNotNull(entities);
- assertEquals(2, entities.size());
- //
- Entity firstEntity = entities.get(0);
- assertNotNull(firstEntity);
- validateEntityAlfki(firstEntity);
-
- StructuralProperty structuralProperty = firstEntity.getProperty("Address", StructuralProperty.class);
- assertEquals("Address", structuralProperty.getName());
-
- Value value = structuralProperty.getValue();
- assertTrue(value.isComplex());
- ComplexValue complexValue = (ComplexValue) value;
- validateAddressBerlin(complexValue);
- validateComplexValueNavigationLinks(complexValue);
-
- //
- Entity secondEntity = entities.get(1);
- assertNotNull(secondEntity);
- validateEntityMuski(secondEntity);
-
- StructuralProperty addressMuster = secondEntity.getProperty("Address", StructuralProperty.class);
- assertEquals("Address", addressMuster.getName());
- validateAddressMuster((ComplexValue) addressMuster.getValue());
- }
-
- @Test
- public void streamingTestForEntitySetWithTwoEntities() throws Exception {
- Reader consumer = new JsonReader();
-
- EntitySet entitySet = consumer.readEntitySet(getJson("/fullEntitySetWithTwoEntities.json"));
- validateEntitySet(entitySet, false);
-
- for (Entity entity : entitySet) {
- if ("Customers('ALFKI')".equals(entity.getODataId())) {
- validateEntityAlfki(entity);
-
- StructuralProperty structuralProperty = entity.getProperty("Address", StructuralProperty.class);
- assertEquals("Address", structuralProperty.getName());
-
- Value value = structuralProperty.getValue();
- assertTrue(value.isComplex());
- ComplexValue complexValue = (ComplexValue) value;
- validateAddressBerlin(complexValue);
- validateComplexValueNavigationLinks(complexValue);
- } else if ("Customers('MUSKI')".equals(entity.getODataId())) {
- validateEntityMuski(entity);
-
- StructuralProperty addressMuster = entity.getProperty("Address", StructuralProperty.class);
- assertEquals("Address", addressMuster.getName());
- validateAddressMuster((ComplexValue) addressMuster.getValue());
- } else {
- fail("Got unknown entity with id '" + entity.getODataId() + "'.");
- }
- }
-
- validateEntitySet(entitySet, true);
- }
-
- @Test
- public void iteratorTestForEntitySetWithTwoEntities() throws Exception {
- Reader consumer = new JsonReader();
-
- EntitySet entitySet = consumer.readEntitySet(getJson("/fullEntitySetWithTwoEntities.json"));
- assertEquals(2, entitySet.getEntities().size());
- validateEntitySet(entitySet, true);
-
- for (Entity entity : entitySet) {
- if ("Customers('ALFKI')".equals(entity.getODataId())) {
- validateEntityAlfki(entity);
-
- StructuralProperty structuralProperty = entity.getProperty("Address", StructuralProperty.class);
- assertEquals("Address", structuralProperty.getName());
-
- Value value = structuralProperty.getValue();
- assertTrue(value.isComplex());
- ComplexValue complexValue = (ComplexValue) value;
- validateAddressBerlin(complexValue);
- validateComplexValueNavigationLinks(complexValue);
- } else if ("Customers('MUSKI')".equals(entity.getODataId())) {
- validateEntityMuski(entity);
-
- StructuralProperty addressMuster = entity.getProperty("Address", StructuralProperty.class);
- assertEquals("Address", addressMuster.getName());
- validateAddressMuster((ComplexValue) addressMuster.getValue());
- } else {
- fail("Got unknown entity with id '" + entity.getODataId() + "'.");
- }
- }
- }
-
- @Test
- public void testEntity() throws Exception {
- Reader consumer = new JsonReader();
-
- Entity entity = consumer.readEntity(JsonReaderTest.class.getResourceAsStream("/fullEntity.json"));
- validateEntityAlfki(entity);
-
- StructuralProperty structuralProperty = entity.getProperty("Address", StructuralProperty.class);
- assertEquals("Address", structuralProperty.getName());
-
- Value value = structuralProperty.getValue();
- assertTrue(value.isComplex());
- ComplexValue complexValue = (ComplexValue) value;
- validateAddressBerlin(complexValue);
- validateComplexValueNavigationLinks(complexValue);
- }
-
- @Test
- public void testComplexProperty() throws Exception {
- Reader consumer = new JsonReader();
-
- Property property = consumer.readProperty(getJson("/complexProperty.json"));
- assertEquals("Address", property.getName());
-
- assertTrue(property instanceof StructuralProperty);
- StructuralProperty structuralProperty = (StructuralProperty) property;
- Value value = structuralProperty.getValue();
- assertTrue(value.isComplex());
- ComplexValue complexValue = (ComplexValue) value;
- validateAddressBerlin(complexValue);
- validateAddressBerlin(complexValue);
- }
-
- @Test
- public void testEntityWithCollectionOfComplexProperty() throws Exception {
- Reader consumer = new JsonReader();
-
- Entity entity = consumer.readEntity(getJson("/fullEntityWithCollectionOfComplexValues.json"));
- StructuralProperty address = entity.getProperty("Address", StructuralProperty.class);
- assertTrue(address.containsCollection());
- assertEquals("Address", address.getName());
-
- List<Value> values = address.getValues();
- assertEquals(2, values.size());
-
- Value value = values.get(0);
- assertTrue(value.isComplex());
- validateAddressBerlin((ComplexValue) value);
- //
- ComplexValue addressTwo = (ComplexValue) values.get(1);
- validateAddressMuster(addressTwo);
- }
-
- @Test
- public void testSetOfPrimitive() throws Exception {
- Reader consumer = new JsonReader();
-
- InputStream content = JsonReaderTest.class.getResourceAsStream("/setOfPrimitiveProperties.json");
- Property property = consumer.readProperty(content);
- assertEquals("EmailAddresses", property.getName());
-
- assertTrue(property instanceof StructuralProperty);
- StructuralProperty structuralProperty = (StructuralProperty) property;
-
- assertTrue(structuralProperty.containsCollection());
- Collection<Value> values = structuralProperty.getValues();
- Iterator<Value> valueIt = values.iterator();
- assertEquals("Julie@Swansworth.com", valueIt.next().getContent());
- assertEquals("Julie.Swansworth@work.com", valueIt.next().getContent());
- }
-
- @Test
- public void testSetOfComplex() throws Exception {
- Reader consumer = new JsonReader();
-
- InputStream content = JsonReaderTest.class.getResourceAsStream("/setOfComplexProperties.json");
- Property property = consumer.readProperty(content);
- assertEquals("PhoneNumbers", property.getName());
- assertTrue(property instanceof StructuralProperty);
-
- StructuralProperty structuralProperty = (StructuralProperty) property;
- assertTrue(structuralProperty.containsCollection());
- List<Value> values = structuralProperty.getValues();
- assertEquals(2, values.size());
-
- ComplexValue phoneNumberOne = (ComplexValue) values.get(0);
- assertEquals("425-555-1212", phoneNumberOne.getValue("Number").getContent());
- assertEquals("Home", phoneNumberOne.getValue("Type").getContent());
- assertEquals(null, phoneNumberOne.getValue("Carrier"));
- assertEquals(null, phoneNumberOne.getAnnotationProperties().get("odata.type"));
-
- ComplexValue phoneNumberTwo = (ComplexValue) values.get(1);
- assertEquals("425-555-0178", phoneNumberTwo.getValue("Number").getContent());
- assertEquals("Cell", phoneNumberTwo.getValue("Type").getContent());
- assertEquals("Sprint", phoneNumberTwo.getValue("Carrier").getContent());
- assertEquals("#Model.CellPhoneNumber",
- phoneNumberTwo.getAnnotationProperties().get("odata.type").getValue());
-
- // ComplexValue complex = consumer.parseComplexValue(content);
- //
- // Value value = complex.getValue("PhoneNumbers");
- // assertNotNull(value);
- // assertTrue(value.isComplex());
- // ComplexValue complexValue = (ComplexValue) value;
- }
-
- private void validateEntityAlfki(final Entity entity) {
- assertNotNull(entity);
-
- assertEquals("http://host/service/$metadata#Customers/$entity", entity.getODataContext());
- assertEquals("Customers('ALFKI')", entity.getODataId());
- assertEquals("W/\"MjAxMy0wNS0yN1QxMTo1OFo=\"", entity.getODataETag());
- assertEquals("Customers('ALFKI')", entity.getODataEditLink());
-
- assertNotNull(entity.getNavigationProperties());
- assertTrue(entity.getNavigationProperties().containsKey("Orders"));
- assertEquals("Customers('ALFKI')/Orders",
- entity.getNavigationProperties().get("Orders").getNavigationLink());
-
- assertNotNull(entity.getNavigationProperties());
- assertTrue(entity.getNavigationProperties().containsKey("Orders"));
- assertEquals("Customers('ALFKI')/Orders/$ref",
- entity.getNavigationProperties().get("Orders").getAssociationLink());
-
- assertNotNull(entity.getPropertyContent("ID"));
- assertEquals("ALFKI", entity.getPropertyContent("ID"));
- assertEquals("Alfreds Futterkiste", entity.getPropertyContent("CompanyName"));
- assertEquals("Maria Anders", entity.getPropertyContent("ContactName"));
- assertEquals("Sales Representative", entity.getPropertyContent("ContactTitle"));
- assertEquals("030-0074321", entity.getPropertyContent("Phone"));
- assertEquals("030-0076545", entity.getPropertyContent("Fax"));
- }
-
- private void validateEntityMuski(final Entity entity) {
- assertNotNull(entity);
-
- assertEquals("http://host/service/$metadata#Customers/$entity", entity.getODataContext());
- assertEquals("Customers('MUSKI')", entity.getODataId());
- assertEquals("W/\"MjAxMy0wNS0yN1QxMTo1OFo=\"", entity.getODataETag());
- assertEquals("Customers('MUSKI')", entity.getODataEditLink());
-
- assertNotNull(entity.getNavigationProperties());
- assertTrue(entity.getNavigationProperties().containsKey("Orders"));
- assertEquals("Customers('MUSKI')/Orders", entity.getNavigationProperties().get("Orders").getNavigationLink());
-
- assertNotNull(entity.getNavigationProperties());
- assertTrue(entity.getNavigationProperties().containsKey("Orders"));
- assertEquals("Customers('MUSKI')/Orders/$ref",
- entity.getNavigationProperties().get("Orders").getAssociationLink());
-
- assertNotNull(entity.getPropertyContent("ID"));
- assertEquals("MUSKI", entity.getPropertyContent("ID"));
- assertEquals("Mustermanns Futterkiste", entity.getPropertyContent("CompanyName"));
- assertEquals("Mustermann Max", entity.getPropertyContent("ContactName"));
- assertEquals("Some Guy", entity.getPropertyContent("ContactTitle"));
- assertEquals("030-002222", entity.getPropertyContent("Phone"));
- assertEquals("030-004444", entity.getPropertyContent("Fax"));
- }
-
- private void validateAddressMuster(final ComplexValue addressTwo) {
- assertEquals("Musterstrasse 42", addressTwo.getValue("Street").getContent());
- assertEquals("Musterstadt", addressTwo.getValue("City").getContent());
- assertEquals("SomeRegion", addressTwo.getValue("Region").getContent());
- assertEquals("D-42042", addressTwo.getValue("PostalCode").getContent());
- }
-
- private void validateAddressBerlin(final ComplexValue complex) {
- assertNotNull(complex);
-
- assertEquals("Obere Str. 57", complex.getValue("Street").getContent());
- assertEquals("Berlin", complex.getValue("City").getContent());
- assertNull(complex.getValue("Region").getContent());
- assertEquals("D-12209", complex.getValue("PostalCode").getContent());
- }
-
- private void validateComplexValueNavigationLinks(final ComplexValue complex) {
- assertNotNull(complex.getNavigationProperties());
- assertTrue(complex.getNavigationProperties().containsKey("Country"));
- assertEquals("Customers('ALFKI')/Address/Country",
- complex.getNavigationProperties().get("Country").getNavigationLink());
-
- assertNotNull(complex.getNavigationProperties());
- assertTrue(complex.getNavigationProperties().containsKey("Country"));
- assertEquals("Customers('ALFKI')/Address/Country/$ref",
- complex.getNavigationProperties().get("Country").getAssociationLink());
- }
-
- private void validateEntitySet(final EntitySet entitySet) {
- validateEntitySet(entitySet, true);
- }
-
- private void validateEntitySet(final EntitySet entitySet, final boolean validateLinks) {
- assertNotNull(entitySet);
-
- assertEquals("http://host/service/$metadata#Customers/$entity", entitySet.getODataContext());
- assertEquals(Long.valueOf(1), entitySet.getODataCount());
- if (validateLinks) {
- assertEquals("http://host/service/EntitySet?$skiptoken=342r89", entitySet.getODataNextLink());
- assertNull(entitySet.getODataDeltaLink());
- }
- }
-
- private InputStream getJson(final String filename) {
- return JsonReaderTest.class.getResourceAsStream(filename);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v3/FilterFactoryTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v3/FilterFactoryTest.java b/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v3/FilterFactoryTest.java
deleted file mode 100644
index cab82b1..0000000
--- a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v3/FilterFactoryTest.java
+++ /dev/null
@@ -1,166 +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.odata4.client.core.v3;
-
-import org.apache.olingo.odata4.client.api.ODataV3Client;
-import static org.junit.Assert.assertEquals;
-
-import org.apache.olingo.odata4.client.api.uri.filter.URIFilter;
-import org.apache.olingo.odata4.client.api.uri.filter.V3FilterArgFactory;
-import org.apache.olingo.odata4.client.api.uri.filter.V3FilterFactory;
-import org.apache.olingo.odata4.client.core.AbstractTest;
-import org.junit.Test;
-
-public class FilterFactoryTest extends AbstractTest {
-
- @Override
- protected ODataV3Client getClient() {
- return v3Client;
- }
-
- private V3FilterFactory getFilterFactory() {
- return getClient().getFilterFactory();
- }
-
- private V3FilterArgFactory getFilterArgFactory() {
- return getFilterFactory().getArgFactory();
- }
-
- @Test
- public void simple() {
- final URIFilter filter = getFilterFactory().lt("VIN", 16);
- assertEquals("(VIN lt 16)", filter.build());
- }
-
- @Test
- public void _null() {
- final URIFilter filter = getFilterFactory().eq(
- getFilterArgFactory().property("NullValue"), getFilterArgFactory()._null());
-
- assertEquals("(NullValue eq null)", filter.build());
- }
-
- @Test
- public void and() {
- final URIFilter filter = getFilterFactory().and(
- getFilterFactory().lt("VIN", 16),
- getFilterFactory().gt("VIN", 12));
-
- assertEquals("((VIN lt 16) and (VIN gt 12))", filter.build());
- }
-
- @Test
- public void not() {
- final URIFilter filter = getFilterFactory().not(
- getFilterFactory().or(
- getFilterFactory().ge("VIN", 16),
- getFilterFactory().le("VIN", 12)));
-
- assertEquals("not (((VIN ge 16) or (VIN le 12)))", filter.build());
- }
-
- @Test
- public void operator() {
- URIFilter filter = getFilterFactory().eq(
- getFilterArgFactory().add(
- getFilterArgFactory().property("VIN"),
- getFilterArgFactory().literal(1)),
- getFilterArgFactory().literal(16));
-
- assertEquals("((VIN add 1) eq 16)", filter.build());
-
- filter = getFilterFactory().eq(
- getFilterArgFactory().add(
- getFilterArgFactory().literal(1),
- getFilterArgFactory().property("VIN")),
- getFilterArgFactory().literal(16));
-
- assertEquals("((1 add VIN) eq 16)", filter.build());
-
- filter = getFilterFactory().eq(
- getFilterArgFactory().literal(16),
- getFilterArgFactory().add(
- getFilterArgFactory().literal(1),
- getFilterArgFactory().property("VIN")));
-
- assertEquals("(16 eq (1 add VIN))", filter.build());
- }
-
- @Test
- public void function() {
- final URIFilter filter = getFilterFactory().match(
- getFilterArgFactory().startswith(
- getFilterArgFactory().property("Description"),
- getFilterArgFactory().literal("cen")));
-
- assertEquals("startswith(Description,'cen')", filter.build());
- }
-
- @Test
- public void composed() {
- final URIFilter filter = getFilterFactory().gt(
- getFilterArgFactory().length(
- getFilterArgFactory().property("Description")),
- getFilterArgFactory().add(
- getFilterArgFactory().property("VIN"),
- getFilterArgFactory().literal(10)));
-
- assertEquals("(length(Description) gt (VIN add 10))", filter.build());
- }
-
- @Test
- public void propertyPath() {
- URIFilter filter = getFilterFactory().eq(
- getFilterArgFactory().indexof(
- getFilterArgFactory().property("PrimaryContactInfo/HomePhone/PhoneNumber"),
- getFilterArgFactory().literal("ODataJClient")),
- getFilterArgFactory().literal(1));
-
- assertEquals("(indexof(PrimaryContactInfo/HomePhone/PhoneNumber,'ODataJClient') eq 1)", filter.build());
-
- filter = getFilterFactory().ne(
- getFilterArgFactory().indexof(
- getFilterArgFactory().property("PrimaryContactInfo/HomePhone/PhoneNumber"),
- getFilterArgFactory().literal("lccvussrv")),
- getFilterArgFactory().literal(-1));
-
- assertEquals("(indexof(PrimaryContactInfo/HomePhone/PhoneNumber,'lccvussrv') ne -1)", filter.build());
- }
-
- @Test
- public void datetime() {
- final URIFilter filter = getFilterFactory().eq(
- getFilterArgFactory().month(
- getFilterArgFactory().property("PurchaseDate")),
- getFilterArgFactory().literal(12));
-
- assertEquals("(month(PurchaseDate) eq 12)", filter.build());
- }
-
- @Test
- public void isof() {
- final URIFilter filter = getFilterFactory().match(
- getFilterArgFactory().isof(
- getFilterArgFactory().literal(
- "Microsoft.Test.OData.Services.AstoriaDefaultService.SpecialEmployee")));
-
- assertEquals("isof('Microsoft.Test.OData.Services.AstoriaDefaultService.SpecialEmployee')", filter.build());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v3/MetadataTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v3/MetadataTest.java b/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v3/MetadataTest.java
deleted file mode 100644
index 96fb8ff..0000000
--- a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v3/MetadataTest.java
+++ /dev/null
@@ -1,223 +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.odata4.client.core.v3;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.apache.olingo.odata4.client.api.ODataV3Client;
-import org.apache.olingo.odata4.client.api.edm.xml.EntityContainer;
-import org.apache.olingo.odata4.client.api.edm.xml.EntityType;
-import org.apache.olingo.odata4.client.api.edm.xml.Schema;
-import org.apache.olingo.odata4.client.api.edm.xml.XMLMetadata;
-import org.apache.olingo.odata4.client.api.edm.xml.v3.FunctionImport;
-import org.apache.olingo.odata4.client.api.http.HttpMethod;
-import org.apache.olingo.odata4.client.core.AbstractTest;
-import org.apache.olingo.odata4.commons.api.edm.Edm;
-import org.apache.olingo.odata4.commons.api.edm.EdmAction;
-import org.apache.olingo.odata4.commons.api.edm.EdmActionImport;
-import org.apache.olingo.odata4.commons.api.edm.EdmActionImportInfo;
-import org.apache.olingo.odata4.commons.api.edm.EdmBindingTarget;
-import org.apache.olingo.odata4.commons.api.edm.EdmComplexType;
-import org.apache.olingo.odata4.commons.api.edm.EdmEntityContainer;
-import org.apache.olingo.odata4.commons.api.edm.EdmEntitySet;
-import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
-import org.apache.olingo.odata4.commons.api.edm.EdmFunction;
-import org.apache.olingo.odata4.commons.api.edm.EdmFunctionImport;
-import org.apache.olingo.odata4.commons.api.edm.EdmFunctionImportInfo;
-import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.odata4.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
-import org.junit.Test;
-
-public class MetadataTest extends AbstractTest {
-
- @Override
- protected ODataV3Client getClient() {
- return v3Client;
- }
-
- @Test
- public void parse() {
- final XMLMetadata metadata = getClient().getDeserializer().
- toMetadata(getClass().getResourceAsStream("metadata.xml"));
- assertNotNull(metadata);
-
- final EntityType order = metadata.getSchemas().get(0).getEntityType("Order");
- assertNotNull(order);
- assertEquals("Order", order.getName());
-
- @SuppressWarnings("unchecked")
- final List<FunctionImport> functionImports = (List<FunctionImport>) metadata.getSchemas().get(0).
- getDefaultEntityContainer().getFunctionImports();
- int legacyGetters = 0;
- int legacyPosters = 0;
- int actions = 0;
- int functions = 0;
- for (FunctionImport functionImport : functionImports) {
- if (HttpMethod.GET.name().equals(functionImport.getHttpMethod())) {
- legacyGetters++;
- } else if (HttpMethod.POST.name().equals(functionImport.getHttpMethod())) {
- legacyPosters++;
- } else if (functionImport.getHttpMethod() == null) {
- if (functionImport.isSideEffecting()) {
- actions++;
- } else {
- functions++;
- }
- }
- }
- assertEquals(6, legacyGetters);
- assertEquals(1, legacyPosters);
- assertEquals(5, actions);
- assertEquals(0, functions);
- }
-
- @Test
- public void multipleSchemas() {
- final XMLMetadata metadata = getClient().getDeserializer().
- toMetadata(getClass().getResourceAsStream("northwind-metadata.xml"));
- assertNotNull(metadata);
-
- final Schema first = metadata.getSchema("NorthwindModel");
- assertNotNull(first);
-
- final Schema second = metadata.getSchema("ODataWebV3.Northwind.Model");
- assertNotNull(second);
-
- final EntityContainer entityContainer = second.getDefaultEntityContainer();
- assertNotNull(entityContainer);
- assertEquals("NorthwindEntities", entityContainer.getName());
- }
-
- @Test
- public void complexAndEntityType() {
- final Edm metadata = getClient().getReader().
- readMetadata(getClass().getResourceAsStream("metadata.xml"));
- assertNotNull(metadata);
-
- final EdmEntityContainer container = metadata.getEntityContainer(
- new FullQualifiedName("Microsoft.Test.OData.Services.AstoriaDefaultService", "DefaultContainer"));
- assertNotNull(container);
-
- final EdmComplexType complex = metadata.getComplexType(
- new FullQualifiedName("Microsoft.Test.OData.Services.AstoriaDefaultService", "ContactDetails"));
- assertNotNull(complex);
- assertFalse(complex.getPropertyNames().isEmpty());
- assertTrue(complex.getProperty("EmailBag").isCollection());
-
- final EdmEntityType entity = metadata.getEntityType(
- new FullQualifiedName("Microsoft.Test.OData.Services.AstoriaDefaultService", "ProductReview"));
- assertNotNull(entity);
- assertFalse(entity.getPropertyNames().isEmpty());
- assertEquals(EdmPrimitiveTypeKind.Int32.getEdmPrimitiveTypeInstance(),
- entity.getProperty("ProductId").getType());
-
- assertFalse(entity.getKeyPropertyRefs().isEmpty());
- assertNotNull("ProductId", entity.getKeyPropertyRef("ProductId").getKeyPropertyName());
- }
-
- @Test
- public void functionImport() {
- final Edm metadata = getClient().getReader().
- readMetadata(getClass().getResourceAsStream("metadata.xml"));
- assertNotNull(metadata);
-
- final Set<String> actionImports = new HashSet<String>();
- for (EdmActionImportInfo info : metadata.getServiceMetadata().getActionImportInfos()) {
- actionImports.add(info.getActionImportName());
- }
- final Set<String> expectedAI = new HashSet<String>(Arrays.asList(new String[]{
- "ResetDataSource",
- "IncreaseSalaries",
- "Sack",
- "GetComputer",
- "ChangeProductDimensions",
- "ResetComputerDetailsSpecifications"}));
- assertEquals(expectedAI, actionImports);
- final Set<String> functionImports = new HashSet<String>();
- for (EdmFunctionImportInfo info : metadata.getServiceMetadata().getFunctionImportInfos()) {
- functionImports.add(info.getFunctionImportName());
- }
- final Set<String> expectedFI = new HashSet<String>(Arrays.asList(new String[]{
- "GetPrimitiveString",
- "GetSpecificCustomer",
- "GetCustomerCount",
- "GetArgumentPlusOne",
- "EntityProjectionReturnsCollectionOfComplexTypes",
- "InStreamErrorGetCustomer"}));
- assertEquals(expectedFI, functionImports);
-
- final EdmEntityContainer container = metadata.getEntityContainer(
- new FullQualifiedName("Microsoft.Test.OData.Services.AstoriaDefaultService", "DefaultContainer"));
- assertNotNull(container);
-
- final EdmFunctionImport getArgumentPlusOne = container.getFunctionImport("GetArgumentPlusOne");
- assertNotNull(getArgumentPlusOne);
- assertEquals(EdmPrimitiveTypeKind.Int32.getEdmPrimitiveTypeInstance(),
- getArgumentPlusOne.getFunction(null).getReturnType().getType());
-
- final EdmActionImport resetDataSource = container.getActionImport("ResetDataSource");
- assertNotNull(resetDataSource);
- assertTrue(resetDataSource.getAction().getParameterNames().isEmpty());
- assertNull(resetDataSource.getAction().getReturnType());
-
- final EdmEntityType computer = metadata.getEntityType(new FullQualifiedName(container.getNamespace(), "Computer"));
- assertNotNull(computer);
-
- final EdmFunction getComputer = metadata.getFunction(
- new FullQualifiedName(container.getNamespace(), "GetComputer"),
- new FullQualifiedName(container.getNamespace(), computer.getName()),
- Boolean.FALSE, Arrays.asList(new String[]{"computer"}));
- assertNotNull(getComputer);
- assertEquals(computer, getComputer.getParameter("computer").getType());
- assertEquals(computer, getComputer.getReturnType().getType());
-
- final EdmAction resetDataSource2 = metadata.getAction(
- new FullQualifiedName(container.getNamespace(), "ResetDataSource"), null, Boolean.FALSE);
- assertNotNull(resetDataSource2);
- }
-
- @Test
- public void navigation() {
- final Edm metadata = getClient().getReader().
- readMetadata(getClass().getResourceAsStream("metadata.xml"));
- assertNotNull(metadata);
-
- final EdmEntityContainer container = metadata.getEntityContainer(
- new FullQualifiedName("Microsoft.Test.OData.Services.AstoriaDefaultService", "DefaultContainer"));
- assertNotNull(container);
-
- final EdmEntitySet customer = container.getEntitySet("Customer");
- assertNotNull(customer);
-
- final EdmBindingTarget order = customer.getRelatedBindingTarget("Orders");
- assertNotNull(order);
- assertTrue(order instanceof EdmEntitySet);
-
- final EdmBindingTarget customerBindingTarget = ((EdmEntitySet) order).getRelatedBindingTarget("Customer");
- assertEquals(customer.getEntityType().getName(), customerBindingTarget.getEntityType().getName());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v3/ServiceDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v3/ServiceDocumentTest.java b/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v3/ServiceDocumentTest.java
deleted file mode 100644
index ebcc00a..0000000
--- a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v3/ServiceDocumentTest.java
+++ /dev/null
@@ -1,57 +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.odata4.client.core.v3;
-
-import org.apache.olingo.odata4.client.api.ODataV3Client;
-import org.apache.olingo.odata4.client.api.domain.ODataServiceDocument;
-import org.apache.olingo.odata4.client.api.format.ODataFormat;
-import org.apache.olingo.odata4.client.core.AbstractTest;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-
-public class ServiceDocumentTest extends AbstractTest {
-
- @Override
- protected ODataV3Client getClient() {
- return v3Client;
- }
-
- private String getFileExtension(final ODataFormat format) {
- return format == ODataFormat.XML ? "xml" : "json";
- }
-
- private void parse(final ODataFormat format) {
- final ODataServiceDocument serviceDocument = getClient().getReader().readServiceDocument(
- getClass().getResourceAsStream("serviceDocument." + getFileExtension(format)), format);
- assertNotNull(serviceDocument);
- assertTrue(serviceDocument.getEntitySetTitles().contains("Persons"));
- }
-
- @Test
- public void json() {
- parse(ODataFormat.JSON);
- }
-
- @Test
- public void xml() {
- parse(ODataFormat.XML);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v3/URIBuilderTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v3/URIBuilderTest.java b/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v3/URIBuilderTest.java
deleted file mode 100644
index 0e3c642..0000000
--- a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v3/URIBuilderTest.java
+++ /dev/null
@@ -1,130 +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.odata4.client.core.v3;
-
-import static org.junit.Assert.assertEquals;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.olingo.odata4.client.api.ODataV3Client;
-import org.apache.olingo.odata4.client.api.uri.V3URIBuilder;
-import org.apache.olingo.odata4.client.core.AbstractTest;
-import org.junit.Test;
-
-public class URIBuilderTest extends AbstractTest {
-
- private static final String SERVICE_ROOT = "http://host/service";
-
- @Override
- protected ODataV3Client getClient() {
- return v3Client;
- }
-
- @Test
- public void metadata() throws URISyntaxException {
- final URI uri = getClient().getURIBuilder(SERVICE_ROOT).appendMetadataSegment().build();
-
- assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/$metadata").build(), uri);
- }
-
- @Test
- public void entity() throws URISyntaxException {
- final URI uri = getClient().getURIBuilder(SERVICE_ROOT).appendEntitySetSegment("AnEntitySet").
- appendKeySegment(11).build();
-
- assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/AnEntitySet(11)").build(), uri);
-
- final Map<String, Object> multiKey = new HashMap<String, Object>();
- multiKey.put("OrderId", -10);
- multiKey.put("ProductId", -10);
- V3URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).
- appendEntitySetSegment("OrderLine").appendKeySegment(multiKey).
- appendPropertySegment("Quantity").appendValueSegment();
-
- assertEquals(new org.apache.http.client.utils.URIBuilder(
- SERVICE_ROOT + "/OrderLine(OrderId=-10,ProductId=-10)/Quantity/$value").build(), uriBuilder.build());
-
- uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).
- appendEntitySetSegment("Customer").appendKeySegment(-10).
- select("CustomerId", "Name", "Orders").expand("Orders");
- assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Customer(-10)").
- addParameter("$select", "CustomerId,Name,Orders").addParameter("$expand", "Orders").build(),
- uriBuilder.build());
-
- uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).
- appendEntitySetSegment("Customer").appendKeySegment(-10).appendLinksSegment("Orders");
- assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Customer(-10)/$links/Orders").build(),
- uriBuilder.build());
- }
-
- @Test
- public void count() throws URISyntaxException {
- URI uri = getClient().getURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").count().build();
-
- assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Products/$count").build(), uri);
-
- uri = getClient().getURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").
- inlineCount(V3URIBuilder.InlineCount.allpages).build();
-
- assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Products").
- addParameter("$inlinecount", "allpages").build(), uri);
- }
-
- @Test
- public void filter() throws URISyntaxException {
- final V3URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).appendEntitySetSegment("AnEntitySet").
- filter(getClient().getFilterFactory().lt("VIN", 16));
-
- assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/AnEntitySet").
- addParameter("$filter", "(VIN lt 16)").build(),
- uriBuilder.build());
- }
-
- @Test
- public void unboundAction() throws URISyntaxException {
- final V3URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).
- appendOperationCallSegment("ProductsByCategoryId",
- Collections.<String, Object>singletonMap("categoryId", 2));
-
- assertEquals(new org.apache.http.client.utils.URIBuilder(
- SERVICE_ROOT + "/ProductsByCategoryId(categoryId=2)").build(), uriBuilder.build());
- }
-
- @Test
- public void boundAction() throws URISyntaxException {
- final V3URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).
- appendEntitySetSegment("Products").appendOperationCallSegment("MostExpensive", null);
-
- assertEquals(new org.apache.http.client.utils.URIBuilder(
- SERVICE_ROOT + "/Products/MostExpensive").build(), uriBuilder.build());
- }
-
- @Test
- public void derived() throws URISyntaxException {
- final V3URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).
- appendEntitySetSegment("Customers").appendNavigationSegment("Model").
- appendDerivedEntityTypeSegment("Namespace.VipCustomer").appendKeySegment(1);
-
- assertEquals(new org.apache.http.client.utils.URIBuilder(
- SERVICE_ROOT + "/Customers/Model/Namespace.VipCustomer(1)").build(), uriBuilder.build());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v4/FilterFactoryTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v4/FilterFactoryTest.java b/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v4/FilterFactoryTest.java
deleted file mode 100644
index 72e6a7d..0000000
--- a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v4/FilterFactoryTest.java
+++ /dev/null
@@ -1,84 +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.odata4.client.core.v4;
-
-import org.apache.olingo.odata4.client.api.ODataV4Client;
-import static org.junit.Assert.assertEquals;
-
-import org.apache.olingo.odata4.client.api.uri.filter.URIFilter;
-import org.apache.olingo.odata4.client.api.uri.filter.V4FilterArgFactory;
-import org.apache.olingo.odata4.client.api.uri.filter.V4FilterFactory;
-import org.apache.olingo.odata4.client.core.AbstractTest;
-import org.apache.olingo.odata4.client.core.edm.EdmEnumTypeImpl;
-import org.apache.olingo.odata4.client.core.edm.xml.v4.EnumTypeImpl;
-import org.apache.olingo.odata4.commons.api.edm.EdmEnumType;
-import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
-import org.junit.Test;
-
-public class FilterFactoryTest extends AbstractTest {
-
- @Override
- protected ODataV4Client getClient() {
- return v4Client;
- }
-
- private V4FilterFactory getFilterFactory() {
- return getClient().getFilterFactory();
- }
-
- private V4FilterArgFactory getFilterArgFactory() {
- return getFilterFactory().getArgFactory();
- }
-
- @Test
- public void has() {
- final EdmEnumType pattern = new EdmEnumTypeImpl(
- null, new FullQualifiedName("Sales", "Pattern"), new EnumTypeImpl());
- final URIFilter filter = getFilterFactory().has(getFilterArgFactory().property("style"), pattern, "Yellow");
-
- assertEquals("(style has Sales.Pattern'Yellow')", filter.build());
- }
-
- @Test
- public void contains() {
- final URIFilter filter = getFilterFactory().match(
- getFilterArgFactory().contains(
- getFilterArgFactory().property("CompanyName"), getFilterArgFactory().literal("Alfreds")));
-
- assertEquals("contains(CompanyName,'Alfreds')", filter.build());
- }
-
- @Test
- public void maxdatetime() {
- final URIFilter filter = getFilterFactory().eq(
- getFilterArgFactory().property("EndTime"),
- getFilterArgFactory().maxdatetime());
-
- assertEquals("(EndTime eq maxdatetime())", filter.build());
- }
-
- @Test
- public void any() {
- final URIFilter filter = getFilterFactory().match(
- getFilterArgFactory().any(getFilterArgFactory().property("Items"),
- getFilterFactory().gt("d:d/Quantity", 100)));
-
- assertEquals("Items/any(d:d/Quantity gt 100)", filter.build());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v4/MetadataTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v4/MetadataTest.java b/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v4/MetadataTest.java
deleted file mode 100644
index 2f9f4e7..0000000
--- a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v4/MetadataTest.java
+++ /dev/null
@@ -1,286 +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.odata4.client.core.v4;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.apache.olingo.odata4.client.api.ODataV4Client;
-import org.apache.olingo.odata4.client.api.edm.xml.v4.Annotation;
-import org.apache.olingo.odata4.client.api.edm.xml.v4.Annotations;
-import org.apache.olingo.odata4.client.api.edm.xml.v4.ComplexType;
-import org.apache.olingo.odata4.client.api.edm.xml.v4.EntityContainer;
-import org.apache.olingo.odata4.client.api.edm.xml.v4.EntityType;
-import org.apache.olingo.odata4.client.api.edm.xml.v4.Function;
-import org.apache.olingo.odata4.client.api.edm.xml.v4.FunctionImport;
-import org.apache.olingo.odata4.client.api.edm.xml.v4.Schema;
-import org.apache.olingo.odata4.client.api.edm.xml.v4.Singleton;
-import org.apache.olingo.odata4.client.api.edm.xml.v4.XMLMetadata;
-import org.apache.olingo.odata4.client.core.AbstractTest;
-import org.apache.olingo.odata4.client.core.edm.xml.v4.annotation.Apply;
-import org.apache.olingo.odata4.client.core.edm.xml.v4.annotation.Collection;
-import org.apache.olingo.odata4.client.core.edm.xml.v4.annotation.ConstExprConstructImpl;
-import org.apache.olingo.odata4.client.core.edm.xml.v4.annotation.Path;
-import org.apache.olingo.odata4.commons.api.edm.Edm;
-import org.apache.olingo.odata4.commons.api.edm.EdmAction;
-import org.apache.olingo.odata4.commons.api.edm.EdmComplexType;
-import org.apache.olingo.odata4.commons.api.edm.EdmEntityContainer;
-import org.apache.olingo.odata4.commons.api.edm.EdmEntitySet;
-import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
-import org.apache.olingo.odata4.commons.api.edm.EdmEnumType;
-import org.apache.olingo.odata4.commons.api.edm.EdmFunction;
-import org.apache.olingo.odata4.commons.api.edm.EdmFunctionImport;
-import org.apache.olingo.odata4.commons.api.edm.EdmFunctionImportInfo;
-import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.odata4.commons.api.edm.constants.EdmTypeKind;
-import org.apache.olingo.odata4.commons.api.edm.constants.StoreGeneratedPattern;
-import org.apache.olingo.odata4.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
-import org.junit.Test;
-
-public class MetadataTest extends AbstractTest {
-
- @Override
- protected ODataV4Client getClient() {
- return v4Client;
- }
-
- @Test
- public void parse() {
- final Edm edm = getClient().getReader().
- readMetadata(getClass().getResourceAsStream("metadata.xml"));
- assertNotNull(edm);
-
- // 1. Enum
- final EdmEnumType responseEnumType = edm.getEnumType(
- new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "ResponseType"));
- assertNotNull(responseEnumType);
- assertEquals(6, responseEnumType.getMemberNames().size());
- assertEquals("3", responseEnumType.getMember("Accepted").getValue());
- assertEquals(EdmTypeKind.ENUM, responseEnumType.getKind());
-
- // 2. Complex
- final EdmComplexType responseStatus = edm.getComplexType(
- new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "ResponseStatus"));
- assertNotNull(responseStatus);
- assertTrue(responseStatus.getNavigationPropertyNames().isEmpty());
- assertEquals("Recipient", responseStatus.getBaseType().getName());
- assertEquals(EdmPrimitiveTypeKind.DateTimeOffset.getEdmPrimitiveTypeInstance(),
- responseStatus.getProperty("Time").getType());
-
- // 3. Entity
- final EdmEntityType user = edm.getEntityType(
- new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "User"));
- assertNotNull(user);
- final EdmEntityType entity = edm.getEntityType(
- new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "Entity"));
- assertEquals(entity, user.getBaseType());
- assertFalse(user.getPropertyNames().isEmpty());
- assertFalse(user.getNavigationPropertyNames().isEmpty());
- final EdmEntityType folder = edm.getEntityType(
- new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "Folder"));
- assertEquals(folder, user.getNavigationProperty("Inbox").getType());
-
- // 4. Action
- final EdmAction move = edm.getAction(
- new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "Move"),
- new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "Folder"),
- false);
- assertNotNull(move);
- assertTrue(move.isBound());
- assertEquals(2, move.getParameterNames().size());
- assertEquals(
- EdmPrimitiveTypeKind.String.getEdmPrimitiveTypeInstance(), move.getParameter("DestinationId").getType());
-
- // 5. EntityContainer
- final EdmEntityContainer container = edm.getEntityContainer(
- new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "EntityContainer"));
- assertNotNull(container);
- final EdmEntitySet users = container.getEntitySet("Users");
- assertNotNull(users);
- assertEquals(edm.getEntityType(new FullQualifiedName(container.getNamespace(), "User")),
- users.getEntityType());
- assertEquals(container.getEntitySet("Folders"), users.getRelatedBindingTarget("Folders"));
- }
-
- @Test
- public void demo() {
- final XMLMetadata metadata = getClient().getDeserializer().
- toMetadata(getClass().getResourceAsStream("demo-metadata.xml"));
- assertNotNull(metadata);
-
- assertFalse(metadata.getSchema(0).getAnnotationsList().isEmpty());
- final Annotations annots = metadata.getSchema(0).getAnnotationsList("ODataDemo.DemoService/Suppliers");
- assertNotNull(annots);
- assertFalse(annots.getAnnotations().isEmpty());
- assertEquals(ConstExprConstructImpl.Type.String,
- annots.getAnnotation("Org.OData.Publication.V1.PrivacyPolicyUrl").getConstExpr().getType());
- assertEquals("http://www.odata.org/",
- annots.getAnnotation("Org.OData.Publication.V1.PrivacyPolicyUrl").getConstExpr().getValue());
- }
-
- @Test
- public void multipleSchemas() {
- final XMLMetadata metadata = getClient().getDeserializer().
- toMetadata(getClass().getResourceAsStream("northwind-metadata.xml"));
- assertNotNull(metadata);
-
- final Schema first = metadata.getSchema("NorthwindModel");
- assertNotNull(first);
-
- final Schema second = metadata.getSchema("ODataWebExperimental.Northwind.Model");
- assertNotNull(second);
-
- assertEquals(StoreGeneratedPattern.Identity,
- first.getEntityType("Category").getProperty("CategoryID").getStoreGeneratedPattern());
-
- final EntityContainer entityContainer = second.getEntityContainer();
- assertNotNull(entityContainer);
- assertEquals("NorthwindEntities", entityContainer.getName());
- assertTrue(entityContainer.isLazyLoadingEnabled());
- }
-
- /**
- * Tests Example 85 from CSDL specification.
- */
- @Test
- public void fromdoc1() {
- final XMLMetadata metadata = getClient().getDeserializer().
- toMetadata(getClass().getResourceAsStream("fromdoc1-metadata.xml"));
- assertNotNull(metadata);
-
- assertFalse(metadata.getReferences().isEmpty());
- assertEquals("Org.OData.Measures.V1", metadata.getReferences().get(1).getIncludes().get(0).getNamespace());
-
- final EntityType product = metadata.getSchema(0).getEntityType("Product");
- assertTrue(product.isHasStream());
- assertEquals("UoM.ISOCurrency", product.getProperty("Price").getAnnotation().getTerm());
- assertEquals("Products", product.getNavigationProperty("Supplier").getPartner());
-
- final EntityType category = metadata.getSchema(0).getEntityType("Category");
- assertNotNull(category);
-
- final ComplexType address = metadata.getSchema(0).getComplexType("Address");
- assertFalse(address.getNavigationProperty("Country").getReferentialConstraints().isEmpty());
- assertEquals("Name",
- address.getNavigationProperty("Country").getReferentialConstraints().get(0).getReferencedProperty());
-
- final Function productsByRating = metadata.getSchema(0).getFunctions("ProductsByRating").get(0);
- assertNotNull(productsByRating.getParameter("Rating"));
- assertEquals("Edm.Int32", productsByRating.getParameter("Rating").getType());
- assertEquals("Collection(ODataDemo.Product)", productsByRating.getReturnType().getType());
-
- final Singleton contoso = metadata.getSchema(0).getEntityContainer().getSingleton("Contoso");
- assertNotNull(contoso);
- assertFalse(contoso.getNavigationPropertyBindings().isEmpty());
- assertEquals("Products", contoso.getNavigationPropertyBindings().get(0).getPath());
-
- final FunctionImport functionImport = metadata.getSchema(0).getEntityContainer().
- getFunctionImport("ProductsByRating");
- assertNotNull(functionImport);
- assertEquals(metadata.getSchema(0).getNamespace() + "." + productsByRating.getName(),
- functionImport.getFunction());
-
- // Now let's go high-level
- final Edm edm = getClient().getReader().
- readMetadata(getClass().getResourceAsStream("fromdoc1-metadata.xml"));
- assertNotNull(edm);
-
- final EdmFunctionImportInfo fiInfo = edm.getServiceMetadata().getFunctionImportInfos().get(0);
- final EdmEntityContainer demoService = edm.getEntityContainer(
- new FullQualifiedName(metadata.getSchema(0).getNamespace(), fiInfo.getEntityContainerName()));
- assertNotNull(demoService);
- final EdmFunctionImport fi = demoService.getFunctionImport(fiInfo.getFunctionImportName());
- assertNotNull(fi);
- assertEquals(demoService.getEntitySet("Products"), fi.getReturnedEntitySet());
-
- final EdmFunction function = edm.getFunction(
- new FullQualifiedName(metadata.getSchema(0).getNamespace(), "ProductsByRating"),
- null, Boolean.FALSE, null);
- assertNotNull(function);
- assertEquals(function.getName(), fi.getFunction(null).getName());
- assertEquals(function.getNamespace(), fi.getFunction(null).getNamespace());
- assertEquals(function.getParameterNames(), fi.getFunction(null).getParameterNames());
- assertEquals(function.getReturnType().getType().getName(),
- fi.getFunction(null).getReturnType().getType().getName());
- assertEquals(function.getReturnType().getType().getNamespace(),
- fi.getFunction(null).getReturnType().getType().getNamespace());
- }
-
- /**
- * Tests Example 86 from CSDL specification.
- */
- @Test
- public void fromdoc2() {
- final XMLMetadata metadata = getClient().getDeserializer().
- toMetadata(getClass().getResourceAsStream("fromdoc2-metadata.xml"));
- assertNotNull(metadata);
-
- // Check displayName
- final Annotation displayName = metadata.getSchema(0).getAnnotationsList("ODataDemo.Supplier").
- getAnnotation("Vocabulary1.DisplayName");
- assertNotNull(displayName);
- assertNull(displayName.getConstExpr());
- assertNotNull(displayName.getDynExpr());
-
- assertTrue(displayName.getDynExpr() instanceof Apply);
- final Apply apply = (Apply) displayName.getDynExpr();
- assertEquals(Apply.CANONICAL_FUNCTION_CONCAT, apply.getFunction());
- assertEquals(3, apply.getParameters().size());
-
- final Path firstArg = new Path();
- firstArg.setValue("Name");
- assertEquals(firstArg, apply.getParameters().get(0));
-
- final ConstExprConstructImpl secondArg = new ConstExprConstructImpl();
- secondArg.setType(ConstExprConstructImpl.Type.String);
- secondArg.setValue(" in ");
- assertEquals(secondArg, apply.getParameters().get(1));
-
- final Path thirdArg = new Path();
- thirdArg.setValue("Address/CountryName");
- assertEquals(thirdArg, apply.getParameters().get(2));
-
- // Check Tags
- final Annotation tags = metadata.getSchema(0).getAnnotationsList("ODataDemo.Product").
- getAnnotation("Vocabulary1.Tags");
- assertNotNull(tags);
- assertNull(tags.getConstExpr());
- assertNotNull(tags.getDynExpr());
-
- assertTrue(tags.getDynExpr() instanceof Collection);
- final Collection collection = (Collection) tags.getDynExpr();
- assertEquals(1, collection.getItems().size());
- assertEquals(ConstExprConstructImpl.Type.String, ((ConstExprConstructImpl) collection.getItems().get(0)).getType());
- assertEquals("MasterData", ((ConstExprConstructImpl) collection.getItems().get(0)).getValue());
- }
-
- /**
- * Various annotation examples taken from CSDL specification.
- */
- @Test
- public void fromdoc3() {
- final Edm metadata = getClient().getReader().
- readMetadata(getClass().getResourceAsStream("fromdoc3-metadata.xml"));
- assertNotNull(metadata);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v4/ServiceDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v4/ServiceDocumentTest.java b/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v4/ServiceDocumentTest.java
deleted file mode 100644
index fbc251c..0000000
--- a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v4/ServiceDocumentTest.java
+++ /dev/null
@@ -1,67 +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.odata4.client.core.v4;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.net.URI;
-import org.apache.olingo.odata4.client.api.ODataV4Client;
-import org.apache.olingo.odata4.client.api.domain.ODataServiceDocument;
-import org.apache.olingo.odata4.client.api.format.ODataFormat;
-import org.apache.olingo.odata4.client.core.AbstractTest;
-import org.junit.Test;
-
-public class ServiceDocumentTest extends AbstractTest {
-
- @Override
- protected ODataV4Client getClient() {
- return v4Client;
- }
-
- private String getFileExtension(final ODataFormat format) {
- return format == ODataFormat.XML ? "xml" : "json";
- }
-
- private ODataServiceDocument parse(final ODataFormat format) {
- final ODataServiceDocument serviceDocument = getClient().getReader().readServiceDocument(
- getClass().getResourceAsStream("serviceDocument." + getFileExtension(format)), format);
- assertNotNull(serviceDocument);
- assertEquals(URI.create("http://host/service/$metadata"), serviceDocument.getMetadataContext());
- assertTrue(serviceDocument.getEntitySetTitles().contains("Order Details"));
- assertEquals(URI.create("http://host/service/TopProducts"),
- serviceDocument.getFunctionImportURI("Best-Selling Products"));
- assertEquals(URI.create("http://host/HR/"),
- serviceDocument.getRelatedServiceDocumentsURIs().iterator().next());
-
- return serviceDocument;
- }
-
- @Test
- public void json() {
- parse(ODataFormat.JSON);
- }
-
- @Test
- public void xml() {
- final ODataServiceDocument serviceDocument = parse(ODataFormat.XML);
- assertEquals("W/\"MjAxMy0wNS0xM1QxNDo1NFo=\"", serviceDocument.getMetadataETag());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v4/URIBuilderTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v4/URIBuilderTest.java b/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v4/URIBuilderTest.java
deleted file mode 100644
index b632e6d..0000000
--- a/lib/client-core/src/test/java/org/apache/olingo/odata4/client/core/v4/URIBuilderTest.java
+++ /dev/null
@@ -1,133 +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.odata4.client.core.v4;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import org.apache.olingo.odata4.client.api.ODataV4Client;
-import org.apache.olingo.odata4.client.api.uri.V4URIBuilder;
-import org.apache.olingo.odata4.client.core.AbstractTest;
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-
-public class URIBuilderTest extends AbstractTest {
-
- private static final String SERVICE_ROOT = "http://host/service";
-
- @Override
- protected ODataV4Client getClient() {
- return v4Client;
- }
-
- @Test
- public void count() throws URISyntaxException {
- URI uri = getClient().getURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").count().build();
-
- assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Products/$count").build(), uri);
-
- uri = getClient().getURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").count(true).build();
-
- assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Products").
- addParameter("$count", "true").build(), uri);
- }
-
- @Test
- public void singleton() throws URISyntaxException {
- final V4URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).
- appendSingletonSegment("BestProductEverCreated");
-
- assertEquals(new org.apache.http.client.utils.URIBuilder(
- SERVICE_ROOT + "/BestProductEverCreated").build(), uriBuilder.build());
- }
-
- @Test
- public void entityId() throws URISyntaxException {
- final V4URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).
- appendEntityIdSegment("Products(0)");
-
- assertEquals(new org.apache.http.client.utils.URIBuilder(
- SERVICE_ROOT + "/$entity").addParameter("$id", "Products(0)").build(), uriBuilder.build());
- }
-
- @Test
- public void boundAction() throws URISyntaxException {
- final V4URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).
- appendEntitySetSegment("Categories").appendKeySegment(1).
- appendNavigationSegment("Products").appendNavigationSegment("Model").
- appendOperationCallSegment("AllOrders", null);
-
- assertEquals(new org.apache.http.client.utils.URIBuilder(
- SERVICE_ROOT + "/Categories(1)/Products/Model.AllOrders()").build(), uriBuilder.build());
- }
-
- @Test
- public void ref() throws URISyntaxException {
- V4URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).
- appendEntitySetSegment("Categories").appendKeySegment(1).
- appendNavigationSegment("Products").appendRefSegment();
-
- assertEquals(new org.apache.http.client.utils.URIBuilder(
- SERVICE_ROOT + "/Categories(1)/Products/$ref").build(), uriBuilder.build());
-
- uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).
- appendEntitySetSegment("Categories").appendKeySegment(1).
- appendNavigationSegment("Products").appendRefSegment().id("../../Products(0)");
-
- assertEquals(new org.apache.http.client.utils.URIBuilder(
- SERVICE_ROOT + "/Categories(1)/Products/$ref").addParameter("$id", "../../Products(0)").build(),
- uriBuilder.build());
- }
-
- @Test
- public void derived() throws URISyntaxException {
- final V4URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).
- appendEntitySetSegment("Customers").appendNavigationSegment("Model").
- appendDerivedEntityTypeSegment("VipCustomer").appendKeySegment(1);
-
- assertEquals(new org.apache.http.client.utils.URIBuilder(
- SERVICE_ROOT + "/Customers/Model.VipCustomer(1)").build(), uriBuilder.build());
- }
-
- @Test
- public void crossjoin() throws URISyntaxException {
- final V4URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).
- appendCrossjoinSegment("Products", "Sales");
-
- assertEquals(new org.apache.http.client.utils.URIBuilder(
- SERVICE_ROOT + "/$crossjoin(Products,Sales)").build(), uriBuilder.build());
- }
-
- @Test
- public void all() throws URISyntaxException {
- final V4URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).appendAllSegment();
-
- assertEquals(new org.apache.http.client.utils.URIBuilder(
- SERVICE_ROOT + "/$all").build(), uriBuilder.build());
- }
-
- @Test
- public void search() throws URISyntaxException {
- final V4URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).
- appendEntitySetSegment("Products").search("blue OR green");
-
- assertEquals(new org.apache.http.client.utils.URIBuilder(
- SERVICE_ROOT + "/Products").addParameter("$search", "blue OR green").build(), uriBuilder.build());
- }
-
-}