You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ar...@apache.org on 2018/11/19 09:05:35 UTC
[2/2] olingo-odata4 git commit: [OLINGO-1191]Code Improvements
[OLINGO-1191]Code Improvements
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/c37d40f1
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/c37d40f1
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/c37d40f1
Branch: refs/heads/master
Commit: c37d40f154d1147a11a97a85c00326adc30e7e92
Parents: f564c4a
Author: Archana Rai <ar...@sap.com>
Authored: Mon Nov 19 14:35:19 2018 +0530
Committer: Archana Rai <ar...@sap.com>
Committed: Mon Nov 19 14:35:19 2018 +0530
----------------------------------------------------------------------
.../request/AsyncRequestWrapperTest.java | 89 +++++++
.../request/batch/ODataBatchControllerTest.java | 57 +++++
.../request/batch/ODataBatchUtilitiesTest.java | 133 ++++++++++
.../request/cud/ODataRequestImplTest.java | 156 ++++++++++++
.../request/invoke/ODataInvokeRequestTest.java | 65 +++++
.../request/retrieve/RetrieveRequestTest.java | 186 ++++++++++++++
.../response/batch/ODataBatchResponseTest.java | 153 ++++++++++++
.../client/core/data/ServiceDocumentTest.java | 58 +++++
.../core/domain/ClientObjectImplTest.java | 249 +++++++++++++++++++
.../request/batch/batchResponse.batch | 37 +++
.../response/batch/batchResponse.batch | 37 +++
.../olingo/server/api/ODataResponseTest.java | 52 ++++
.../olingo/server/core/ErrorHandlerTest.java | 131 ++++++++++
.../core/RequestUrlHierarchyVisitorTest.java | 101 ++++++++
14 files changed, 1504 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d40f1/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/AsyncRequestWrapperTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/AsyncRequestWrapperTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/AsyncRequestWrapperTest.java
new file mode 100644
index 0000000..f61ecf3
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/AsyncRequestWrapperTest.java
@@ -0,0 +1,89 @@
+/*
+ * 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.communication.request;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
+import org.apache.olingo.client.api.domain.ClientInvokeResult;
+import org.apache.olingo.client.core.ODataClientFactory;
+import org.apache.olingo.client.core.communication.request.AsyncRequestWrapperImpl.AsyncResponseWrapperImpl;
+import org.apache.olingo.client.core.communication.request.batch.ODataBatchRequestImpl;
+import org.apache.olingo.client.core.communication.request.invoke.ODataInvokeRequestImpl;
+import org.apache.olingo.commons.api.http.HttpMethod;
+import org.junit.Test;
+
+public class AsyncRequestWrapperTest {
+
+ @Test
+ public void testBatchReq() throws URISyntaxException {
+
+ ODataClient client = ODataClientFactory.getClient();
+ URI uri = new URI("localhost:8080");
+ AsyncBatchRequestWrapperImpl req = new AsyncBatchRequestWrapperImpl(client,
+ client.getBatchRequestFactory().getBatchRequest("root"));
+ assertNotNull(req.addChangeset());
+ ODataBatchableRequest request = new ODataInvokeRequestImpl<ClientInvokeResult>(
+ client, ClientInvokeResult.class, HttpMethod.GET, uri);
+ req.addRetrieve(request );
+ req.addOutsideUpdate(request);
+ assertNotNull(client.getAsyncRequestFactory().getAsyncRequestWrapper(request));
+ ODataBatchRequestImpl batchRequest = new ODataBatchRequestImpl(client, uri);
+ assertNotNull(client.getAsyncRequestFactory().getAsyncBatchRequestWrapper(batchRequest ));
+ assertNotNull(req.wait(10));
+ }
+
+ @Test
+ public void testReq() throws URISyntaxException {
+
+ ODataClient client = ODataClientFactory.getClient();
+ URI uri = new URI("localhost:8080");
+ AsyncRequestWrapperImpl req = new AsyncRequestWrapperImpl(client,
+ client.getBatchRequestFactory().getBatchRequest("root"));
+ assertNotNull(req);
+ ODataBatchableRequest request = new ODataInvokeRequestImpl<ClientInvokeResult>(
+ client, ClientInvokeResult.class, HttpMethod.GET, uri);
+ req.checkRequest(client, null);
+ assertNotNull(req.callback(uri));
+ req.extendHeader("header", "value");
+ AsyncResponseWrapperImpl res = req.new AsyncResponseWrapperImpl();
+ res.forceNextMonitorCheck(uri);
+ }
+
+ @Test
+ public void testWrapper(){
+
+ Wrapper wrap = new Wrapper();
+ wrap.setWrapped("test");
+ assertEquals("test", wrap.getWrapped());
+ }
+
+ @Test
+ public void testException(){
+
+ AsyncRequestException ex = new AsyncRequestException ("Exception");
+ assertEquals("Exception", ex.getMessage());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d40f1/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchControllerTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchControllerTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchControllerTest.java
new file mode 100644
index 0000000..cc9c25d
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchControllerTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.communication.request.batch;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+import org.apache.commons.io.LineIterator;
+import org.apache.olingo.client.api.communication.request.batch.ODataBatchLineIterator;
+import org.junit.Test;
+
+public class ODataBatchControllerTest {
+
+ @Test
+ public void testController(){
+ final InputStream input = getClass().getResourceAsStream("batchResponse.batch");
+ Reader reader = new InputStreamReader(input);
+ ODataBatchLineIterator iterator = new ODataBatchLineIteratorImpl(new LineIterator(reader ));
+ ODataBatchController controller = new ODataBatchController(iterator , "changeset_12ks93js84d");
+ assertNotNull(controller.getBatchLineIterator());
+ assertNotNull(controller.getBoundary());
+ controller.setValidBatch(true);
+ assertTrue(controller.isValidBatch());
+ assertTrue(iterator.hasNext());
+ assertNotNull(iterator.next());
+ assertNotNull(iterator.nextLine());
+ assertNotNull(iterator.getCurrent());
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testControllerNeg(){
+ final InputStream input = getClass().getResourceAsStream("batchResponse.batch");
+ Reader reader = new InputStreamReader(input);
+ ODataBatchLineIterator iterator = new ODataBatchLineIteratorImpl(new LineIterator(reader ));
+ iterator.remove();
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d40f1/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchUtilitiesTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchUtilitiesTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchUtilitiesTest.java
new file mode 100644
index 0000000..1fae3e1
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchUtilitiesTest.java
@@ -0,0 +1,133 @@
+/*
+ * 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.communication.request.batch;
+
+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.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.io.LineIterator;
+import org.apache.olingo.client.api.ODataBatchConstants;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.ODataClientBuilder;
+import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
+import org.apache.olingo.client.api.communication.request.batch.ODataBatchLineIterator;
+import org.apache.olingo.client.api.communication.request.batch.ODataBatchRequest;
+import org.apache.olingo.client.api.domain.ClientInvokeResult;
+import org.apache.olingo.client.core.communication.request.invoke.ODataInvokeRequestImpl;
+import org.apache.olingo.commons.api.http.HttpMethod;
+import org.junit.Test;
+
+public class ODataBatchUtilitiesTest {
+
+ @Test
+ public void testBatchRequest(){
+ ODataBatchUtilities util = new ODataBatchUtilities();
+ Map<String, Collection<String>> value = new HashMap<String, Collection<String>>();
+ util.addHeaderLine("header:name", value );
+ value.put("header:name", null);
+ util.addHeaderLine("header:name", value );
+ }
+
+ @Test
+ public void testBatchConstants(){
+ assertEquals("boundary", ODataBatchConstants.BOUNDARY);
+ assertEquals("application/http", ODataBatchConstants.ITEM_CONTENT_TYPE );
+ assertEquals("Content-Type: application/http", ODataBatchConstants.ITEM_CONTENT_TYPE_LINE );
+ assertEquals("Content-Transfer-Encoding: binary",
+ ODataBatchConstants.ITEM_TRANSFER_ENCODING_LINE );
+ assertEquals("Content-ID", ODataBatchConstants.CHANGESET_CONTENT_ID_NAME );
+ }
+
+
+ @Test
+ public void testChangeSet() throws URISyntaxException{
+ ODataClient client = ODataClientBuilder.createClient();
+ URI uri = new URI("test");
+ final InputStream input = getClass().getResourceAsStream("batchResponse.batch");
+ Reader reader = new InputStreamReader(input);
+ ODataBatchLineIterator iterator = new ODataBatchLineIteratorImpl(new LineIterator(reader ));
+ ODataBatchRequest req = new ODataBatchRequestImpl(client, uri);;
+ ODataChangesetResponseItem expectedResItem = new ODataChangesetResponseItem(true);
+ ODataChangesetImpl change = new ODataChangesetImpl(req , expectedResItem );
+ assertNotNull(change);
+ ODataBatchableRequest request = new ODataInvokeRequestImpl<ClientInvokeResult>(
+ client, ClientInvokeResult.class, HttpMethod.POST, uri);
+ change.addRequest(request);
+ assertNotNull(change.getBodyStreamWriter());
+ change.close();
+ change.closeItem();
+ assertNotNull(change.getLastContentId());
+ assertTrue(change.hasStreamedSomething());
+ assertFalse(change.isOpen());
+ change.streamRequestHeader(request);
+ change.streamRequestHeader("1");
+
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testChangeSetNeg() throws URISyntaxException{
+ ODataClient client = ODataClientBuilder.createClient();
+ URI uri = new URI("test");
+ ODataBatchRequest req = new ODataBatchRequestImpl(client, uri);;
+ ODataChangesetResponseItem expectedResItem = new ODataChangesetResponseItem(true);
+ ODataChangesetImpl change = new ODataChangesetImpl(req , expectedResItem );
+ assertNotNull(change);
+ ODataBatchableRequest request = new ODataInvokeRequestImpl<ClientInvokeResult>(
+ client, ClientInvokeResult.class, HttpMethod.GET, uri);
+ change.addRequest(request);
+ assertNotNull(change.getBodyStreamWriter());
+ change.close();
+ change.closeItem();
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testChangeSetCloseNeg() throws URISyntaxException{
+ ODataClient client = ODataClientBuilder.createClient();
+ URI uri = new URI("test");
+ ODataBatchRequest req = new ODataBatchRequestImpl(client, uri);;
+ ODataChangesetResponseItem expectedResItem = new ODataChangesetResponseItem(true);
+ ODataChangesetImpl change = new ODataChangesetImpl(req , expectedResItem );
+ assertNotNull(change);
+ assertNotNull(change.getBodyStreamWriter());
+ change.close();
+ change.closeItem();
+ ODataBatchableRequest request = new ODataInvokeRequestImpl<ClientInvokeResult>(
+ client, ClientInvokeResult.class, HttpMethod.POST, uri);
+ change.addRequest(request);
+ }
+
+ @Test
+ public void testChangeSetResponse() throws URISyntaxException{
+ ODataChangesetResponseItem expectedResItem = new ODataChangesetResponseItem(true);
+ expectedResItem.setUnexpected();
+ assertNotNull(expectedResItem);
+ expectedResItem.close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d40f1/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/cud/ODataRequestImplTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/cud/ODataRequestImplTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/cud/ODataRequestImplTest.java
new file mode 100644
index 0000000..c12a778
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/cud/ODataRequestImplTest.java
@@ -0,0 +1,156 @@
+/*
+ * 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.communication.request.cud;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.olingo.client.api.communication.request.cud.CUDRequestFactory;
+import org.apache.olingo.client.api.communication.request.cud.UpdateType;
+import org.apache.olingo.client.api.domain.ClientEntity;
+import org.apache.olingo.client.api.domain.ClientProperty;
+import org.apache.olingo.client.api.domain.ClientValue;
+import org.apache.olingo.client.core.ODataClientFactory;
+import org.apache.olingo.client.core.ODataClientImpl;
+import org.apache.olingo.client.core.domain.ClientCollectionValueImpl;
+import org.apache.olingo.client.core.domain.ClientComplexValueImpl;
+import org.apache.olingo.client.core.domain.ClientEntityImpl;
+import org.apache.olingo.client.core.domain.ClientPropertyImpl;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.junit.Test;
+
+public class ODataRequestImplTest {
+
+ @Test
+ public void testdel() throws URISyntaxException{
+ ODataClientImpl client = (ODataClientImpl) ODataClientFactory.getClient();
+ URI uri = new URI("test");
+ assertNotNull(client);
+ CUDRequestFactory factory = client.getCUDRequestFactory();
+ assertNotNull(factory);
+ ODataDeleteRequestImpl del = (ODataDeleteRequestImpl) factory.getDeleteRequest(uri);
+ assertNotNull(del);
+ assertNotNull(del.getDefaultFormat());
+ assertNull(del.getPayload());
+
+ }
+
+ @Test
+ public void testcreate() throws URISyntaxException{
+ ODataClientImpl client = (ODataClientImpl) ODataClientFactory.getClient();
+ URI uri = new URI("test");
+ assertNotNull(client);
+ CUDRequestFactory factory = client.getCUDRequestFactory();
+ assertNotNull(factory);
+ FullQualifiedName fqn = new FullQualifiedName("test.entity");
+ ClientEntity entity = new ClientEntityImpl(fqn );
+ ODataEntityCreateRequestImpl create = (ODataEntityCreateRequestImpl) factory
+ .getEntityCreateRequest(uri, entity);
+ assertNotNull(create);
+ assertNotNull(create.getDefaultFormat());
+ assertNotNull(create.getPayload());
+ }
+
+ @Test
+ public void testUpdate() throws URISyntaxException{
+ ODataClientImpl client = (ODataClientImpl) ODataClientFactory.getClient();
+ URI uri = new URI("test");
+ assertNotNull(client);
+ CUDRequestFactory factory = client.getCUDRequestFactory();
+ assertNotNull(factory);
+ FullQualifiedName fqn = new FullQualifiedName("test.entity");
+ ClientEntity entity = new ClientEntityImpl(fqn );
+ entity.setEditLink(uri);
+ ODataEntityUpdateRequestImpl update = (ODataEntityUpdateRequestImpl) factory
+ .getEntityUpdateRequest(UpdateType.PATCH, entity);
+ assertNotNull(update);
+ assertNotNull(update.getDefaultFormat());
+ assertNotNull(update.getPayload());
+ }
+
+ @Test
+ public void testUpdatePropColl() throws URISyntaxException{
+ ODataClientImpl client = (ODataClientImpl) ODataClientFactory.getClient();
+ URI uri = new URI("test");
+ assertNotNull(client);
+ CUDRequestFactory factory = client.getCUDRequestFactory();
+ assertNotNull(factory);
+ ClientValue value = new ClientCollectionValueImpl("properties");
+ ClientProperty prop = new ClientPropertyImpl("property", value );
+ ODataPropertyUpdateRequestImpl update = (ODataPropertyUpdateRequestImpl) factory
+ .getPropertyCollectionValueUpdateRequest(uri, prop);
+ assertNotNull(update);
+ assertNotNull(update.getDefaultFormat());
+ assertNotNull(update.getPayload());
+ }
+
+ @Test
+ public void testUpdatePropComplex() throws URISyntaxException{
+ ODataClientImpl client = (ODataClientImpl) ODataClientFactory.getClient();
+ URI uri = new URI("test");
+ assertNotNull(client);
+ CUDRequestFactory factory = client.getCUDRequestFactory();
+ assertNotNull(factory);
+ ClientValue value = new ClientComplexValueImpl("complex");
+ ClientProperty prop = new ClientPropertyImpl("property", value );
+ ODataPropertyUpdateRequestImpl update = (ODataPropertyUpdateRequestImpl) factory
+ .getPropertyComplexValueUpdateRequest(uri, UpdateType.PATCH, prop);
+ assertNotNull(update);
+ assertNotNull(update.getDefaultFormat());
+ assertNotNull(update.getPayload());
+ }
+
+ @Test
+ public void testUpdate2() throws URISyntaxException{
+ ODataClientImpl client = (ODataClientImpl) ODataClientFactory.getClient();
+ URI uri = new URI("test");
+ assertNotNull(client);
+ CUDRequestFactory factory = client.getCUDRequestFactory();
+ assertNotNull(factory);
+ FullQualifiedName fqn = new FullQualifiedName("test.entity");
+ ClientEntity entity = new ClientEntityImpl(fqn );
+ entity.setEditLink(uri);
+ ODataEntityUpdateRequestImpl update = (ODataEntityUpdateRequestImpl) factory
+ .getEntityUpdateRequest(uri, UpdateType.PATCH, entity);
+ assertNotNull(update);
+ assertNotNull(update.getDefaultFormat());
+ assertNotNull(update.getPayload());
+ }
+
+ @Test
+ public void testRef() throws URISyntaxException{
+ ODataClientImpl client = (ODataClientImpl) ODataClientFactory.getClient();
+ URI uri = new URI("test");
+ assertNotNull(client);
+ CUDRequestFactory factory = client.getCUDRequestFactory();
+ assertNotNull(factory);
+ FullQualifiedName fqn = new FullQualifiedName("test.entity");
+ ClientEntity entity = new ClientEntityImpl(fqn );
+ entity.setEditLink(uri);
+ ODataReferenceAddingRequestImpl ref = (ODataReferenceAddingRequestImpl) factory
+ .getReferenceAddingRequest(uri, uri, null);
+ assertNotNull(ref);
+ assertNotNull(ref.getDefaultFormat());
+ assertNotNull(ref.getPayload());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d40f1/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/invoke/ODataInvokeRequestTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/invoke/ODataInvokeRequestTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/invoke/ODataInvokeRequestTest.java
new file mode 100644
index 0000000..31cbc88
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/invoke/ODataInvokeRequestTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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.communication.request.invoke;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.domain.ClientInvokeResult;
+import org.apache.olingo.client.core.ODataClientFactory;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.api.http.HttpMethod;
+import org.junit.Test;
+
+public class ODataInvokeRequestTest {
+
+
+ @Test
+ public void testRequest() throws URISyntaxException {
+ ODataClient client = ODataClientFactory.getClient();
+ Class<ClientInvokeResult> reference = ClientInvokeResult.class;
+ HttpMethod method = HttpMethod.GET;
+ URI uri = new URI("test");
+ ODataInvokeRequestImpl req = new ODataInvokeRequestImpl<ClientInvokeResult>(client, reference, method, uri);
+ assertNotNull(req);
+ assertNotNull(req.getAccept());
+ assertNotNull(req.getContentType());
+ assertNotNull(req.getDefaultFormat());
+ assertNotNull(req.getHeader());
+ assertNotNull(req.getHeaderNames());
+ assertNull(req.getIfMatch());
+ assertNull(req.getIfNoneMatch());
+ assertNotNull(req.getHttpRequest());
+ assertNotNull(req.getMethod());
+ assertNull(req.getPayload());
+ assertNotNull(req.getPOSTParameterFormat());
+ assertNotNull(req.getPOSTParameterFormat());
+ assertNull(req.getPrefer());
+ assertNotNull(req.getResponseTemplate());
+ assertNotNull(req.getURI());
+ assertNotNull(req.addCustomHeader("custom", "header"));
+ assertNotNull(req.setAccept("json"));
+ assertNotNull(req.setContentType("json"));
+ req.setFormat(ContentType.APPLICATION_ATOM_XML);
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d40f1/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/retrieve/RetrieveRequestTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/retrieve/RetrieveRequestTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/retrieve/RetrieveRequestTest.java
new file mode 100644
index 0000000..976f139
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/request/retrieve/RetrieveRequestTest.java
@@ -0,0 +1,186 @@
+/*
+ * 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.communication.request.retrieve;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.olingo.client.core.ODataClientFactory;
+import org.apache.olingo.client.core.ODataClientImpl;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.junit.Test;
+
+public class RetrieveRequestTest {
+
+ @Test
+ public void testEdmMetadata() throws URISyntaxException {
+
+ ODataClientImpl client = (ODataClientImpl) ODataClientFactory.getClient();
+ RetrieveRequestFactoryImpl factory = (RetrieveRequestFactoryImpl) client
+ .getRetrieveRequestFactory();
+ assertNotNull(factory);
+ EdmMetadataRequestImpl edmMetadata = (EdmMetadataRequestImpl) factory
+ .getMetadataRequest("metadata");
+ assertNotNull(edmMetadata);
+ assertNotNull(edmMetadata.addCustomHeader("name", "value"));
+ assertNotNull(edmMetadata.getDefaultFormat());
+ assertNotNull(edmMetadata.setAccept(ContentType.VALUE_ODATA_METADATA_FULL));
+ assertNotNull(edmMetadata.setContentType(ContentType.VALUE_ODATA_METADATA_FULL));
+ }
+
+ @Test
+ public void testXmlMetadata() throws URISyntaxException {
+
+ ODataClientImpl client = (ODataClientImpl) ODataClientFactory.getClient();
+ RetrieveRequestFactoryImpl factory = (RetrieveRequestFactoryImpl) client
+ .getRetrieveRequestFactory();
+ assertNotNull(factory);
+ XMLMetadataRequestImpl metadata = (XMLMetadataRequestImpl) factory
+ .getXMLMetadataRequest("test");
+ assertNotNull(metadata);
+ }
+
+ @Test
+ public void testDeltaRequest() throws URISyntaxException {
+
+ ODataClientImpl client = (ODataClientImpl) ODataClientFactory.getClient();
+ URI uri = new URI("localhost:8080");
+ RetrieveRequestFactoryImpl factory = (RetrieveRequestFactoryImpl) client
+ .getRetrieveRequestFactory();
+ assertNotNull(factory);
+ ODataDeltaRequestImpl delta = (ODataDeltaRequestImpl) factory
+ .getDeltaRequest(uri);
+ assertNotNull(delta);
+ assertNotNull(delta.getDefaultFormat());
+ }
+
+ @Test
+ public void testEntityRequest() throws URISyntaxException {
+
+ ODataClientImpl client = (ODataClientImpl) ODataClientFactory.getClient();
+ URI uri = new URI("localhost:8080");
+ RetrieveRequestFactoryImpl factory = (RetrieveRequestFactoryImpl) client
+ .getRetrieveRequestFactory();
+ assertNotNull(factory);
+ ODataEntityRequestImpl req = (ODataEntityRequestImpl) factory
+ .getEntityRequest(uri);
+ assertNotNull(req);
+ assertNotNull(req.getDefaultFormat());
+ }
+
+ @Test
+ public void testEntitySetIteratorRequest() throws URISyntaxException {
+
+ ODataClientImpl client = (ODataClientImpl) ODataClientFactory.getClient();
+ URI uri = new URI("localhost:8080");
+ RetrieveRequestFactoryImpl factory = (RetrieveRequestFactoryImpl) client
+ .getRetrieveRequestFactory();
+ assertNotNull(factory);
+ ODataEntitySetIteratorRequestImpl req = (ODataEntitySetIteratorRequestImpl) factory
+ .getEntitySetIteratorRequest(uri);
+ assertNotNull(req);
+ assertNotNull(req.getDefaultFormat());
+ }
+
+ @Test
+ public void testEntitySetRequest() throws URISyntaxException {
+
+ ODataClientImpl client = (ODataClientImpl) ODataClientFactory.getClient();
+ URI uri = new URI("localhost:8080");
+ RetrieveRequestFactoryImpl factory = (RetrieveRequestFactoryImpl) client
+ .getRetrieveRequestFactory();
+ assertNotNull(factory);
+ ODataEntitySetRequestImpl req = (ODataEntitySetRequestImpl) factory
+ .getEntitySetRequest(uri);
+ assertNotNull(req);
+ assertNotNull(req.getDefaultFormat());
+ }
+
+ @Test
+ public void testMediaRequest() throws URISyntaxException {
+
+ ODataClientImpl client = (ODataClientImpl) ODataClientFactory.getClient();
+ URI uri = new URI("localhost","8080","","","$value");
+ RetrieveRequestFactoryImpl factory = (RetrieveRequestFactoryImpl) client
+ .getRetrieveRequestFactory();
+ assertNotNull(factory);
+ ODataMediaRequestImpl req = (ODataMediaRequestImpl) factory
+ .getMediaEntityRequest(uri);
+ assertNotNull(req);
+ assertNotNull(req.getDefaultFormat());
+ }
+
+ @Test
+ public void testPropertyRequest() throws URISyntaxException {
+
+ ODataClientImpl client = (ODataClientImpl) ODataClientFactory.getClient();
+ URI uri = new URI("localhost:8080");
+ RetrieveRequestFactoryImpl factory = (RetrieveRequestFactoryImpl) client
+ .getRetrieveRequestFactory();
+ assertNotNull(factory);
+ ODataPropertyRequestImpl req = (ODataPropertyRequestImpl) factory
+ .getPropertyRequest(uri);
+ assertNotNull(req);
+ assertNotNull(req.getDefaultFormat());
+ }
+
+ @Test
+ public void testRawRequest() throws URISyntaxException {
+
+ ODataClientImpl client = (ODataClientImpl) ODataClientFactory.getClient();
+ URI uri = new URI("localhost:8080");
+ RetrieveRequestFactoryImpl factory = (RetrieveRequestFactoryImpl) client
+ .getRetrieveRequestFactory();
+ assertNotNull(factory);
+ ODataRawRequestImpl req = (ODataRawRequestImpl) factory
+ .getRawRequest(uri);
+ assertNotNull(req);
+ assertNotNull(req.getDefaultFormat());
+ }
+
+ @Test
+ public void testServiceDocumentRequest() throws URISyntaxException {
+
+ ODataClientImpl client = (ODataClientImpl) ODataClientFactory.getClient();
+ RetrieveRequestFactoryImpl factory = (RetrieveRequestFactoryImpl) client
+ .getRetrieveRequestFactory();
+ assertNotNull(factory);
+ ODataServiceDocumentRequestImpl req = (ODataServiceDocumentRequestImpl) factory
+ .getServiceDocumentRequest("doc");
+ assertNotNull(req);
+ assertNotNull(req.getDefaultFormat());
+ }
+
+ @Test
+ public void testValueRequest() throws URISyntaxException {
+
+ ODataClientImpl client = (ODataClientImpl) ODataClientFactory.getClient();
+ URI uri = new URI("localhost:8080");
+ RetrieveRequestFactoryImpl factory = (RetrieveRequestFactoryImpl) client
+ .getRetrieveRequestFactory();
+ assertNotNull(factory);
+ ODataValueRequestImpl req = (ODataValueRequestImpl) factory
+ .getValueRequest(uri);
+ assertNotNull(req);
+ assertNotNull(req.getDefaultFormat());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d40f1/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/response/batch/ODataBatchResponseTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/response/batch/ODataBatchResponseTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/response/batch/ODataBatchResponseTest.java
new file mode 100644
index 0000000..5ed52f2
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/communication/response/batch/ODataBatchResponseTest.java
@@ -0,0 +1,153 @@
+/*
+ * 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.communication.response.batch;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.commons.io.LineIterator;
+import org.apache.http.HttpResponse;
+import org.apache.olingo.client.api.communication.request.batch.ODataBatchLineIterator;
+import org.apache.olingo.client.api.communication.request.batch.ODataBatchResponseItem;
+import org.apache.olingo.client.api.communication.response.ODataBatchResponse;
+import org.apache.olingo.client.api.communication.response.ODataResponse;
+import org.apache.olingo.client.core.communication.request.batch.ODataBatchLineIteratorImpl;
+import org.apache.olingo.client.core.communication.request.batch.ODataBatchUtilities;
+import org.apache.olingo.client.core.communication.request.batch.ODataChangesetResponseItem;
+import org.junit.Test;
+
+public class ODataBatchResponseTest {
+
+ @Test
+ public void testBatchResponse() throws URISyntaxException {
+
+ ODataChangesetResponseItem expectedResItem = new ODataChangesetResponseItem(true);
+ List<ODataBatchResponseItem> resList = new ArrayList<ODataBatchResponseItem>();
+ resList.add(expectedResItem);
+ ODataBatchResponseManager manager = new ODataBatchResponseManager(new BatchResponse(), resList );
+ assertNotNull(manager);
+ assertNotNull(manager.next());
+ assertNotNull(manager.hasNext());
+ }
+
+ @Test
+ public void testErrorBatchResponse() throws URISyntaxException {
+ Map<String, Collection<String>> header = new HashMap<String, Collection<String>>();
+ List<String> list = new ArrayList<String>();
+ list.add("multipart/mixed;boundary=changeset_12ks93js84d");
+ header.put("content-type", list);
+ final InputStream input = getClass().getResourceAsStream("batchResponse.batch");
+ Reader reader = new InputStreamReader(input);
+ ODataBatchLineIterator iterator = new ODataBatchLineIteratorImpl(new LineIterator(reader ));
+ String boundary = "changeset_12ks93js84d";
+ iterator.next();
+ iterator.next();
+ iterator.next();
+ iterator.next();
+ iterator.next();
+ iterator.next();
+ iterator.next();
+ iterator.next();
+ Entry<Integer, String> line = ODataBatchUtilities.readResponseLine(iterator);
+ ODataBatchErrorResponse error = new ODataBatchErrorResponse
+ (line, header, iterator, boundary );
+ assertNotNull(error);
+ assertNull(error.getETag());
+ }
+
+ class BatchResponse implements ODataBatchResponse{
+
+ @Override
+ public Collection<String> getHeaderNames() {
+ return null;
+ }
+
+ @Override
+ public Collection<String> getHeader(String name) {
+ List<String> list = new ArrayList<String>();
+ list.add("multipart/mixed;boundary=changeset_12ks93js84d");
+ return list;
+ }
+
+ @Override
+ public String getETag() {
+ return null;
+ }
+
+ @Override
+ public String getContentType() {
+ return null;
+ }
+
+ @Override
+ public int getStatusCode() {
+ return 0;
+ }
+
+ @Override
+ public String getStatusMessage() {
+ return null;
+ }
+
+ @Override
+ public InputStream getRawResponse() {
+ return getClass().getResourceAsStream("batchResponse.batch");
+ }
+
+ @Override
+ public ODataResponse initFromHttpResponse(HttpResponse res) {
+ return null;
+ }
+
+ @Override
+ public ODataResponse initFromBatch(Entry<Integer, String> responseLine,
+ Map<String, Collection<String>> headers,
+ ODataBatchLineIterator batchLineIterator, String boundary) {
+ return null;
+ }
+
+ @Override
+ public ODataResponse initFromEnclosedPart(InputStream part) {
+ return null;
+ }
+
+ @Override
+ public void close() {
+ }
+
+ @Override
+ public Iterator<ODataBatchResponseItem> getBody() {
+ return null;
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d40f1/lib/client-core/src/test/java/org/apache/olingo/client/core/data/ServiceDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/data/ServiceDocumentTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/data/ServiceDocumentTest.java
new file mode 100644
index 0000000..bceecbc
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/data/ServiceDocumentTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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.data;
+
+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.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.client.api.data.ServiceDocumentItem;
+import org.junit.Test;
+
+public class ServiceDocumentTest {
+
+ @Test
+ public void testServiceDocument() {
+ ServiceDocumentImpl sd = new ServiceDocumentImpl();
+ assertNull(sd.getTitle());
+ assertEquals(0,sd.getEntitySets().size());
+ List<ServiceDocumentItem> list = new ArrayList<ServiceDocumentItem>();
+ assertNull(sd.getByName(list , "test"));
+ assertNull(sd.getEntitySetByName("test"));
+ assertNull(sd.getFunctionImportByName("test"));
+ assertNull(sd.getSingletonByName("name"));
+ ServiceDocumentImpl sd2 = new ServiceDocumentImpl();
+ assertTrue(sd.equals(sd2));
+ assertNotNull(sd.toString());
+ assertNotNull(sd.hashCode());
+ }
+
+ @Test
+ public void testServiceDocumentItem() {
+ ServiceDocumentItemImpl sd = new ServiceDocumentItemImpl();
+ ServiceDocumentItemImpl sd2 = new ServiceDocumentItemImpl();
+ assertTrue(sd.equals(sd2));
+ assertNotNull(sd.toString());
+ assertNotNull(sd.hashCode());
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d40f1/lib/client-core/src/test/java/org/apache/olingo/client/core/domain/ClientObjectImplTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/domain/ClientObjectImplTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/domain/ClientObjectImplTest.java
new file mode 100644
index 0000000..b4cc131
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/domain/ClientObjectImplTest.java
@@ -0,0 +1,249 @@
+/*
+ * 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.domain;
+
+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.math.BigDecimal;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.UUID;
+
+import org.apache.olingo.client.api.domain.ClientDeletedEntity.Reason;
+import org.apache.olingo.client.api.domain.ClientEntity;
+import org.apache.olingo.client.api.domain.ClientInlineEntity;
+import org.apache.olingo.client.api.domain.ClientLink;
+import org.apache.olingo.client.api.domain.ClientLinkType;
+import org.apache.olingo.client.api.domain.ClientObjectFactory;
+import org.apache.olingo.client.api.domain.ClientValue;
+import org.apache.olingo.client.core.ODataClientFactory;
+import org.apache.olingo.client.core.ODataClientImpl;
+import org.apache.olingo.client.core.domain.ClientPrimitiveValueImpl.BuilderImpl;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.junit.Test;
+
+public class ClientObjectImplTest {
+
+ @Test
+ public void testFactory() throws URISyntaxException {
+
+ ODataClientImpl client = (ODataClientImpl) ODataClientFactory.getClient();
+ ClientObjectFactory factory = client.getObjectFactory();
+ assertNotNull(factory);
+ URI uri = new URI("test");
+ assertNotNull(factory.newEntitySet(uri));
+ FullQualifiedName typeName = new FullQualifiedName("name.test");
+ ClientEntity entity = new ClientEntityImpl(typeName );
+ assertNotNull(factory.newDeepInsertEntity("test", entity));
+ assertNotNull(factory.newEntity(typeName));
+ assertNotNull(factory.newSingleton(typeName));
+ assertNotNull(factory.newMediaEditLink("media",
+ uri, "image", "W/1"));
+ assertNotNull(factory.newDelta(uri));
+ assertNotNull(factory.newDelta());
+ }
+
+ @Test
+ public void testAnnotation(){
+ ClientValue val = new ClientCollectionValueImpl<ClientValue>("test");
+ ClientAnnotationImpl annotation = new ClientAnnotationImpl("term", val);
+ assertFalse(annotation.hasNullValue());
+ assertNull(annotation.getPrimitiveValue());
+ assertTrue(annotation.hasCollectionValue());
+ assertFalse(annotation.hasComplexValue());
+ }
+
+ @Test
+ public void testCollection(){
+ ClientCollectionValueImpl val = new ClientCollectionValueImpl<ClientValue>("test");
+ assertNull(val.asEnum());
+ ClientCollectionValueImpl val2 = new ClientCollectionValueImpl<ClientValue>("test");
+ assertTrue(val.equals(val2));
+ assertNotNull(val.hashCode());
+ assertNotNull(val.toString());
+ val.add(val2);
+ assertEquals(1, val.asJavaCollection().size());
+ }
+
+ @Test
+ public void testComplex() throws URISyntaxException{
+ ClientComplexValueImpl val = new ClientComplexValueImpl("test");
+ ClientEntity entity = new ClientEntityImpl(new FullQualifiedName("name.test"));
+ ClientLink link = new ClientInlineEntity(new URI("test"), ClientLinkType.ASSOCIATION,
+ "title", entity );
+ assertTrue(val.addLink(link ));
+ assertNull(val.asEnum());
+ assertTrue(val.removeLink(link));
+ ClientComplexValueImpl val2 = new ClientComplexValueImpl("test");
+ assertTrue(val.equals(val2));
+ assertNotNull(val.hashCode());
+ assertNotNull(val.toString());
+ }
+
+ @Test
+ public void testDeletedEntity() throws URISyntaxException {
+ ClientDeletedEntityImpl val = new ClientDeletedEntityImpl();
+ assertNotNull(val);
+ val.setId(new URI("Id"));
+ assertNotNull(val.getId());
+ val.setReason(Reason.changed);
+ assertNotNull(val.getReason());
+ assertNotNull(val.hashCode());
+ assertNotNull(val.toString());
+ ClientDeletedEntityImpl val2 = new ClientDeletedEntityImpl();
+ assertFalse(val.equals(val2));
+ }
+
+ @Test
+ public void testDelta() throws URISyntaxException {
+ ClientDeltaImpl val = new ClientDeltaImpl();
+ ClientDeltaImpl val2 = new ClientDeltaImpl(new URI("Id"));
+ assertNotNull(val);
+ assertNotNull(val.getAddedLinks());
+ assertNotNull(val.getDeletedLinks());
+ assertNotNull(val.getDeletedEntities());
+ assertNotNull(val.getAnnotations());
+ assertNull(val.getContextURL());
+ assertNull(val.getDeltaLink());
+ assertNotNull(val.getEntities());
+ assertNull(val.getLink());
+ assertNull(val.getName());
+ assertNull(val.getNext());
+ assertNotNull(val.getOperations());
+ assertNotNull(val.hashCode());
+ assertNotNull(val.toString());
+ assertFalse(val.equals(val2));
+ }
+
+ @Test
+ public void testDeltaLink() throws URISyntaxException {
+ ClientDeltaLinkImpl val = new ClientDeltaLinkImpl();
+ ClientDeltaLinkImpl val2 = new ClientDeltaLinkImpl();
+ assertNotNull(val);
+ URI uri = new URI("test");
+ val.setSource(uri );
+ assertNotNull(val.getSource());
+ val.setRelationship("Nav");
+ assertNotNull(val.getRelationship());
+ val.setTarget(uri);
+ assertNotNull(val.getTarget());
+ assertNotNull(val.getAnnotations());
+ assertNull(val.getLink());
+ assertNull(val.getName());
+ assertNotNull(val.hashCode());
+ assertNotNull(val.toString());
+ assertFalse(val.equals(val2));
+ }
+
+ @Test
+ public void testClientEntity() throws URISyntaxException {
+ FullQualifiedName name = new FullQualifiedName("test.name");
+ ClientEntityImpl val = new ClientEntityImpl(name );
+ URI uri = new URI("test");
+ assertNotNull(val);
+ val.setId(new URI("Id"));
+ assertNotNull(val.getId());
+ assertNull(val.getETag());
+ ClientEntity entity = new ClientEntityImpl(name);
+ ClientLink link = new ClientInlineEntity(uri, ClientLinkType.ASSOCIATION,
+ "title", entity);
+ assertTrue(val.addLink(link ));
+ assertNull(val.getLink());
+ assertNotNull(val.getAssociationLink("title"));
+ assertTrue(val.removeLink(link ));
+ assertFalse(val.isReadOnly());
+ assertNotNull(val.hashCode());
+ assertNotNull(val.toString());
+ ClientDeletedEntityImpl val2 = new ClientDeletedEntityImpl();
+ assertFalse(val.equals(val2));
+ }
+
+ @Test
+ public void testClientEntitySet() throws URISyntaxException {
+ ClientEntitySetImpl val = new ClientEntitySetImpl();
+ URI uri = new URI("test");
+ ClientEntitySetImpl val2 = new ClientEntitySetImpl(uri);
+ assertNotNull(val);
+ val.setDeltaLink(uri);
+ assertNotNull(val.getOperations());
+ assertNull(val.getOperation("test"));
+ assertNotNull(val.hashCode());
+ assertNotNull(val.toString());
+ assertFalse(val.equals(val2));
+ }
+
+ @Test
+ public void testClientEnumValue() {
+ ClientEnumValueImpl val = new ClientEnumValueImpl("type", "value");
+ ClientEnumValueImpl val2 = new ClientEnumValueImpl("type", "value");
+ assertNotNull(val.hashCode());
+ assertNotNull(val.toString());
+ assertTrue(val.equals(val2));
+ }
+
+ @Test
+ public void testClientPrimitiveValue() {
+ ClientPrimitiveValueImpl val = new ClientPrimitiveValueImpl();
+ ClientPrimitiveValueImpl val2 = new ClientPrimitiveValueImpl();
+ BuilderImpl builder = new BuilderImpl();
+ builder.setType(EdmPrimitiveTypeKind.Binary);
+ assertNotNull(builder.buildBoolean(true));
+ assertNotNull(builder);
+ byte[] byteArray = new byte[2];
+ assertNotNull(builder.buildBinary(byteArray));
+ Short shortValue = new Short("1");
+ assertNotNull(builder.buildInt16(shortValue));
+ assertNotNull(builder.buildInt32(new Integer("1")));
+ assertNotNull(builder.buildSingle(new Float("1")));
+ assertNotNull(builder.buildDouble(new Double("1")));
+ assertNotNull(builder.buildGuid(new UUID(1,1)));
+ assertNotNull(builder.buildDecimal(new BigDecimal("1")));
+ assertNotNull(builder.buildDuration(new BigDecimal("1")));
+ assertNotNull(val.hashCode());
+ assertNotNull(val.toString());
+ assertTrue(val.equals(val2));
+ }
+
+ @Test
+ public void testClientProperty() {
+ ClientValue value = new ClientCollectionValueImpl<ClientValue>("type");
+ ClientPropertyImpl val = new ClientPropertyImpl("type", value );
+ ClientPropertyImpl val2 = new ClientPropertyImpl("type", value);
+ assertNull(val.getOperation("type"));
+ assertNotNull(val.getOperations());
+ assertNotNull(val.hashCode());
+ assertNotNull(val.toString());
+ assertTrue(val.equals(val2));
+ }
+
+ @Test
+ public void testClientValuable() {
+ ClientValue value = new ClientCollectionValueImpl<ClientValue>("type");
+ ClientValuableImpl val = new ClientValuableImpl(value);
+ ClientValuableImpl val2 = new ClientValuableImpl(value);
+ assertNotNull(val.hashCode());
+ assertNotNull(val.toString());
+ assertTrue(val.equals(val2));
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d40f1/lib/client-core/src/test/resources/org/apache/olingo/client/core/communication/request/batch/batchResponse.batch
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/communication/request/batch/batchResponse.batch b/lib/client-core/src/test/resources/org/apache/olingo/client/core/communication/request/batch/batchResponse.batch
new file mode 100644
index 0000000..f9e043b
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/communication/request/batch/batchResponse.batch
@@ -0,0 +1,37 @@
+--batch_123
+Content-Type: multipart/mixed;boundary=changeset_12ks93js84d
+
+--changeset_12ks93js84d
+Content-Type: application/http
+Content-Transfer-Encoding: binary
+Content-Id: 1
+
+HTTP/1.1 204 No Content
+
+
+--changeset_12ks93js84d
+Content-Type: application/http
+Content-Transfer-Encoding: binary
+
+HTTP/1.1 201 Created
+DataServiceVersion: 2.0
+Content-Id: 2
+Location: http://localhost:19000/ClientBatchTest/Employees('7')
+Content-Type: application/json
+Content-Length: 918
+
+{"d":{"__metadata":{"id":"http://localhost:19000/ClientBatchTest/Employees('7')","uri":"http://localhost:19000/ClientBatchTest/Employees('7')","type":"RefScenario.Employee","content_type":"application/octet-stream","media_src":"Employees('7')/$value","edit_media":"http://localhost:19000/ClientBatchTest/Employees('7')/$value"},"EmployeeId":"7","EmployeeName":"Employee 7","ManagerId":null,"RoomId":null,"TeamId":null,"Location":{"__metadata":{"type":"RefScenario.c_Location"},"City":{"__metadata":{"type":"RefScenario.c_City"},"PostalCode":null,"CityName":null},"Country":null},"Age":0,"EntryDate":null,"ImageUrl":null,"ne_Manager":{"__deferred":{"uri":"http://localhost:19000/ClientBatchTest/Employees('7')/ne_Manager"}},"ne_Team":{"__deferred":{"uri":"http://localhost:19000/ClientBatchTest/Employees('7')/ne_Team"}},"ne_Room":{"__deferred":{"uri":"http://localhost:19000/ClientBatchTest/Employees('7')/ne_Room"}}}}
+--changeset_12ks93js84d--
+
+--batch_123
+Content-Type: application/http
+Content-Transfer-Encoding: binary
+Content-ID: 2
+
+HTTP/1.1 200 OK
+DataServiceVersion: 2.0
+Content-Type: text/plain;charset=utf-8
+Content-length: 13
+
+Frederic Fall
+--batch_123--
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d40f1/lib/client-core/src/test/resources/org/apache/olingo/client/core/communication/response/batch/batchResponse.batch
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/communication/response/batch/batchResponse.batch b/lib/client-core/src/test/resources/org/apache/olingo/client/core/communication/response/batch/batchResponse.batch
new file mode 100644
index 0000000..f9e043b
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/communication/response/batch/batchResponse.batch
@@ -0,0 +1,37 @@
+--batch_123
+Content-Type: multipart/mixed;boundary=changeset_12ks93js84d
+
+--changeset_12ks93js84d
+Content-Type: application/http
+Content-Transfer-Encoding: binary
+Content-Id: 1
+
+HTTP/1.1 204 No Content
+
+
+--changeset_12ks93js84d
+Content-Type: application/http
+Content-Transfer-Encoding: binary
+
+HTTP/1.1 201 Created
+DataServiceVersion: 2.0
+Content-Id: 2
+Location: http://localhost:19000/ClientBatchTest/Employees('7')
+Content-Type: application/json
+Content-Length: 918
+
+{"d":{"__metadata":{"id":"http://localhost:19000/ClientBatchTest/Employees('7')","uri":"http://localhost:19000/ClientBatchTest/Employees('7')","type":"RefScenario.Employee","content_type":"application/octet-stream","media_src":"Employees('7')/$value","edit_media":"http://localhost:19000/ClientBatchTest/Employees('7')/$value"},"EmployeeId":"7","EmployeeName":"Employee 7","ManagerId":null,"RoomId":null,"TeamId":null,"Location":{"__metadata":{"type":"RefScenario.c_Location"},"City":{"__metadata":{"type":"RefScenario.c_City"},"PostalCode":null,"CityName":null},"Country":null},"Age":0,"EntryDate":null,"ImageUrl":null,"ne_Manager":{"__deferred":{"uri":"http://localhost:19000/ClientBatchTest/Employees('7')/ne_Manager"}},"ne_Team":{"__deferred":{"uri":"http://localhost:19000/ClientBatchTest/Employees('7')/ne_Team"}},"ne_Room":{"__deferred":{"uri":"http://localhost:19000/ClientBatchTest/Employees('7')/ne_Room"}}}}
+--changeset_12ks93js84d--
+
+--batch_123
+Content-Type: application/http
+Content-Transfer-Encoding: binary
+Content-ID: 2
+
+HTTP/1.1 200 OK
+DataServiceVersion: 2.0
+Content-Type: text/plain;charset=utf-8
+Content-length: 13
+
+Frederic Fall
+--batch_123--
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d40f1/lib/server-api/src/test/java/org/apache/olingo/server/api/ODataResponseTest.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/test/java/org/apache/olingo/server/api/ODataResponseTest.java b/lib/server-api/src/test/java/org/apache/olingo/server/api/ODataResponseTest.java
new file mode 100644
index 0000000..bac4f24
--- /dev/null
+++ b/lib/server-api/src/test/java/org/apache/olingo/server/api/ODataResponseTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.server.api;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+
+public class ODataResponseTest {
+
+ @Test
+ public void testResponse() {
+ ODataResponse r = new ODataResponse ();
+ assertNotNull(r);
+ r.addHeader("header", "value");
+ List<String> list = new ArrayList<String>();
+ r.addHeader("headerList", list );
+ assertNotNull(r.getAllHeaders());
+ }
+
+ @Test
+ public void testError() {
+ ODataServerError r = new ODataServerError ();
+ assertNotNull(r);
+ assertNull(r.getLocale());
+ Map<String, String> map = new HashMap<String, String>();
+ r.setInnerError(map);
+ assertNotNull(r.getInnerError());
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d40f1/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/ErrorHandlerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/ErrorHandlerTest.java b/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/ErrorHandlerTest.java
new file mode 100644
index 0000000..da893b9
--- /dev/null
+++ b/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/ErrorHandlerTest.java
@@ -0,0 +1,131 @@
+/*
+ * 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.server.core;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.FileReader;
+import java.net.URI;
+import java.util.Collections;
+import java.util.Locale;
+
+import org.apache.olingo.commons.api.edm.provider.CsdlEdmProvider;
+import org.apache.olingo.commons.api.edmx.EdmxReference;
+import org.apache.olingo.commons.api.edmx.EdmxReferenceInclude;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataApplicationException;
+import org.apache.olingo.server.api.ODataRequest;
+import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.ODataServerError;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.deserializer.DeserializerException;
+import org.apache.olingo.server.api.deserializer.batch.BatchDeserializerException;
+import org.apache.olingo.server.api.etag.ServiceMetadataETagSupport;
+import org.apache.olingo.server.api.serializer.SerializerException;
+import org.apache.olingo.server.core.legacy.ProcessorServiceHandler;
+import org.apache.olingo.server.core.uri.parser.UriParserException;
+import org.apache.olingo.server.core.uri.parser.UriParserSemanticException;
+import org.apache.olingo.server.core.uri.parser.UriParserSyntaxException;
+import org.apache.olingo.server.core.uri.validator.UriValidationException;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ErrorHandlerTest {
+ CsdlEdmProvider provider = null;
+
+ @Before
+ public void setUp() throws Exception {
+ MetadataParser parser = new MetadataParser();
+ parser.parseAnnotations(true);
+ parser.useLocalCoreVocabularies(true);
+ provider = (CsdlEdmProvider) parser.buildEdmProvider(new FileReader("src/test/resources/annotations.xml"));
+ }
+
+ @Test
+ public void testError(){
+ EdmxReference reference = new EdmxReference
+ (URI.create("../v4.0/cs02/vocabularies/Org.OData.Core.V1.xml"));
+ reference.addInclude(new EdmxReferenceInclude("Org.OData.Core.V1", "Core"));
+ ServiceHandler handler = new ProcessorServiceHandler();
+ ServiceMetadata metadata = new ServiceMetadataImpl(provider,
+ Collections.singletonList(reference), new ServiceMetadataETagSupport() {
+ @Override
+ public String getServiceDocumentETag() {
+ return "W/\"serviceDocumentETag\"";
+ }
+ @Override
+ public String getMetadataETag() {
+ return "W/\"metadataETag\"";
+ }
+ } );
+ OData odata = new ODataImpl();
+ ErrorHandler error = new ErrorHandler(odata , metadata, handler,
+ ContentType.APPLICATION_ATOM_XML);
+ assertNotNull(error);
+ UriValidationException e =new UriValidationException("message",
+ UriValidationException.MessageKeys.DOUBLE_KEY_PROPERTY , "param");
+ ODataRequest request = new ODataRequest();
+ ODataResponse response = new ODataResponse();
+ error.handleException(e, request , response);
+ error.handleException(new UriParserSemanticException("message",
+ UriParserSemanticException.MessageKeys.COLLECTION_NOT_ALLOWED, "param")
+ , request , response);
+ error.handleException(new UriParserSyntaxException("message",
+ UriParserSyntaxException.MessageKeys.DOUBLE_SYSTEM_QUERY_OPTION, "param")
+ , request , response);
+ String[] param = new String[2];
+ error.handleException(new UriParserExceptionCustom("message",
+ UriParserSyntaxException.MessageKeys.DOUBLE_SYSTEM_QUERY_OPTION, param)
+ , request , response);
+ error.handleException(new BatchDeserializerException("message",
+ BatchDeserializerException.MessageKeys.INVALID_BASE_URI, "param")
+ , request , response);
+ error.handleException(new SerializerException("message",
+ SerializerException.MessageKeys.IO_EXCEPTION, "param")
+ , request , response);
+ error.handleException(new ContentNegotiatorException("message",
+ ContentNegotiatorException.MessageKeys.NO_CONTENT_TYPE_SUPPORTED, "param")
+ , request , response);
+ error.handleException(new UriParserSyntaxException("message",
+ UriParserSyntaxException.MessageKeys.DUPLICATED_ALIAS, "param")
+ , request , response);
+ error.handleException(new DeserializerException("message",
+ DeserializerException.MessageKeys.DUPLICATE_PROPERTY, "param")
+ , request , response);
+ error.handleException(new ODataHandlerException("message",
+ ODataHandlerException.MessageKeys.AMBIGUOUS_XHTTP_METHOD, "param")
+ , request , response);
+ error.handleException(new ODataApplicationException("message",
+ 500, Locale.ENGLISH)
+ , request , response);
+ error.handleException(new NullPointerException("message")
+ , request , response);
+ error.handleServerError(request, response, new ODataServerError());
+ }
+
+ class UriParserExceptionCustom extends UriParserException{
+
+ public UriParserExceptionCustom(String developmentMessage, MessageKey messageKey,
+ String[] parameters) {
+ super(developmentMessage, messageKey, parameters);
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d40f1/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/RequestUrlHierarchyVisitorTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/RequestUrlHierarchyVisitorTest.java b/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/RequestUrlHierarchyVisitorTest.java
new file mode 100644
index 0000000..fe246fa
--- /dev/null
+++ b/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/RequestUrlHierarchyVisitorTest.java
@@ -0,0 +1,101 @@
+/*
+ * 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.server.core;
+
+import static org.junit.Assert.assertNull;
+
+import org.apache.olingo.server.api.uri.UriInfoEntityId;
+import org.apache.olingo.server.api.uri.UriInfoKind;
+import org.apache.olingo.server.api.uri.UriInfoMetadata;
+import org.apache.olingo.server.api.uri.queryoption.FormatOption;
+import org.apache.olingo.server.core.uri.UriInfoImpl;
+import org.apache.olingo.server.core.uri.UriResourceComplexPropertyImpl;
+import org.apache.olingo.server.core.uri.UriResourceCountImpl;
+import org.apache.olingo.server.core.uri.UriResourceEntitySetImpl;
+import org.apache.olingo.server.core.uri.UriResourceFunctionImpl;
+import org.apache.olingo.server.core.uri.UriResourceItImpl;
+import org.apache.olingo.server.core.uri.UriResourceLambdaAllImpl;
+import org.apache.olingo.server.core.uri.UriResourceLambdaAnyImpl;
+import org.apache.olingo.server.core.uri.UriResourceNavigationPropertyImpl;
+import org.apache.olingo.server.core.uri.UriResourcePrimitivePropertyImpl;
+import org.apache.olingo.server.core.uri.UriResourceRefImpl;
+import org.apache.olingo.server.core.uri.UriResourceRootImpl;
+import org.apache.olingo.server.core.uri.UriResourceSingletonImpl;
+import org.apache.olingo.server.core.uri.UriResourceValueImpl;
+import org.apache.olingo.server.core.uri.queryoption.CountOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.DeltaTokenOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.ExpandOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.FilterOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.FormatOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.SearchOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.SkipOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.SkipTokenOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.TopOptionImpl;
+import org.junit.Test;
+
+public class RequestUrlHierarchyVisitorTest {
+
+ @Test
+ public void visitorTest(){
+ RequestURLHierarchyVisitor visitor = new RequestURLHierarchyVisitor();
+ assertNull(visitor.getUriInfo());
+ UriInfoImpl info = new UriInfoImpl();
+ visitor.visit(info.setKind(UriInfoKind.all));
+ visitor.visit(info.setKind(UriInfoKind.batch));
+ visitor.visit(info.setKind(UriInfoKind.crossjoin));
+ visitor.visit(info.setKind(UriInfoKind.entityId));
+ visitor.visit(info.setKind(UriInfoKind.service));
+ UriInfoEntityId entityId = info;
+ visitor.visit(entityId);
+ visitor.visit(new UriInfoMetadata() {
+
+ @Override
+ public String getFragment() {
+ return null;
+ }
+
+ @Override
+ public FormatOption getFormatOption() {
+ return null;
+ }
+ });
+ visitor.visit(new ExpandOptionImpl());
+ visitor.visit(new FilterOptionImpl());
+ visitor.visit(new FormatOptionImpl());
+ visitor.visit(new CountOptionImpl());
+ visitor.visit(new SearchOptionImpl());
+ visitor.visit(new SkipOptionImpl());
+ visitor.visit(new SkipTokenOptionImpl());
+ visitor.visit(new TopOptionImpl());
+ visitor.visit(new UriResourceCountImpl());
+ visitor.visit(new DeltaTokenOptionImpl());
+ visitor.visit(new UriResourceRefImpl());
+ visitor.visit(new UriResourceRootImpl(null, false));
+ visitor.visit(new UriResourceValueImpl());
+ visitor.visit(new UriResourceEntitySetImpl(null));
+ visitor.visit(new UriResourceFunctionImpl(null, null, null));
+ visitor.visit(new UriResourceItImpl(null, false));
+ visitor.visit(new UriResourceLambdaAllImpl(null, null));
+ visitor.visit(new UriResourceLambdaAnyImpl(null, null));
+ visitor.visit(new UriResourceNavigationPropertyImpl(null));
+ visitor.visit(new UriResourceSingletonImpl(null));
+ visitor.visit(new UriResourceComplexPropertyImpl(null));
+ visitor.visit(new UriResourcePrimitivePropertyImpl(null));
+ }
+}