You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by il...@apache.org on 2014/05/15 15:56:40 UTC

[1/2] [OLINGO-260] Filter/orderby and search tests

Repository: olingo-odata4
Updated Branches:
  refs/heads/master 0e5b32e68 -> e854f416f


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/fit/src/test/java/org/apache/olingo/fit/proxy/v4/OpenTypeTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/OpenTypeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/OpenTypeTestITCase.java
index b1b61c8..11f7d07 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/OpenTypeTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/OpenTypeTestITCase.java
@@ -18,7 +18,6 @@
  */
 package org.apache.olingo.fit.proxy.v4;
 
-
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -29,7 +28,7 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.UUID;
-
+import org.apache.olingo.client.api.v4.EdmEnabledODataClient;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.ext.proxy.EntityContainerFactory;
 import org.apache.olingo.ext.proxy.api.annotations.EntityType;
@@ -39,7 +38,6 @@ import org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.ope
 import org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.Row;
 import org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.RowIndex;
 import org.junit.BeforeClass;
-
 import org.junit.Test;
 
 /**
@@ -51,8 +49,10 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
 
   @BeforeClass
   public static void initContainer() {
-    final EntityContainerFactory otcontainerFactory = EntityContainerFactory.getV4(testOpenTypeServiceRootURL);
-    otcontainerFactory.getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
+    final EntityContainerFactory<EdmEnabledODataClient> otcontainerFactory =
+            EntityContainerFactory.getV4(testOpenTypeServiceRootURL);
+    otcontainerFactory.getClient().getConfiguration().
+            setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
     otcontainer = otcontainerFactory.getEntityContainer(DefaultContainer.class);
     assertNotNull(otcontainer);
   }
@@ -95,10 +95,10 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
 
     Calendar cal = Calendar.getInstance();
     cal.clear();
-    cal.setTime(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX").parse("2001-04-05T05:05:05.001+00:01"));
+    cal.setTime(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").parse("2001-04-05T05:05:05.001"));
 
     contact.setLastContacted(cal);
-    
+
     cal = Calendar.getInstance();
     cal.clear();
     cal.setTime(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").parse("2001-04-05T05:05:04.001"));
@@ -114,7 +114,7 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
     contact.setInt(Integer.MAX_VALUE);
     rowIndex.addAdditionalProperty("aContact", contact);
     rowIndex.addAdditionalProperty("aColor", Color.Green);
-    
+
     otcontainer.flush();
 
     rowIndex = otcontainer.getRowIndex().get(id);
@@ -129,10 +129,10 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
     assertEquals(Color.Green, rowIndex.getAdditionalProperty("aColor"));
 
     entityContext.detachAll();
-    
+
     otcontainer.getRowIndex().delete(id);
     otcontainer.flush();
-    
+
     assertNull(otcontainer.getRowIndex().get(id));
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/fit/src/test/java/org/apache/olingo/fit/v3/AsyncTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/AsyncTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/AsyncTestITCase.java
index aa6f5e2..5b10eb1 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/AsyncTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/AsyncTestITCase.java
@@ -91,9 +91,6 @@ public class AsyncTestITCase extends AbstractTestITCase {
     assertEquals(204, res.getStatusCode());
   }
 
-  /**
-   * @see MediaEntityTest#createMediaEntity(com.msopentech.odatajclient.engine.format.ODataPubFormat)
-   */
   @Test
   public void createMediaEntity() throws Exception {
     URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car");


[2/2] git commit: [OLINGO-260] Filter/orderby and search tests

Posted by il...@apache.org.
[OLINGO-260] Filter/orderby and search tests


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/e854f416
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/e854f416
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/e854f416

Branch: refs/heads/master
Commit: e854f416ff44bbcdb9cbee6cca6d61e92019144b
Parents: 0e5b32e
Author: Francesco Chicchiriccò <--global>
Authored: Thu May 15 15:56:28 2014 +0200
Committer: Francesco Chicchiriccò <--global>
Committed: Thu May 15 15:56:28 2014 +0200

----------------------------------------------------------------------
 .../ext/proxy/EntityContainerFactory.java       |  33 ++--
 .../olingo/ext/proxy/api/AbstractEntitySet.java |  36 +++-
 .../org/apache/olingo/ext/proxy/api/Filter.java | 131 ++++++++++++++
 .../olingo/ext/proxy/api/NoResultException.java |   6 +-
 .../ext/proxy/api/NonUniqueResultException.java |   6 +-
 .../org/apache/olingo/ext/proxy/api/Query.java  | 128 --------------
 .../org/apache/olingo/ext/proxy/api/Search.java |  64 +++++++
 .../commons/EntitySetInvocationHandler.java     |  40 ++++-
 .../olingo/ext/proxy/commons/FilterImpl.java    | 172 ++++++++++++++++++
 .../olingo/ext/proxy/commons/QueryImpl.java     | 173 -------------------
 .../olingo/ext/proxy/commons/SearchImpl.java    |  89 ++++++++++
 .../java/org/apache/olingo/fit/V3Services.java  |  16 ++
 .../java/org/apache/olingo/fit/V4Services.java  |  28 ++-
 .../V30/Car/filter/(VIN eq 16).full.json        |  15 ++
 .../resources/V30/Car/filter/(VIN eq 16).xml    |  45 +++++
 .../olingo/fit/proxy/v3/AbstractTestITCase.java |  18 +-
 .../proxy/v3/ActionOverloadingTestITCase.java   |   6 +-
 .../olingo/fit/proxy/v3/AsyncTestITCase.java    |  25 +--
 .../proxy/v3/AuthEntityRetrieveTestITCase.java  |   2 +-
 .../olingo/fit/proxy/v3/FilterTestITCase.java   | 113 ++++++++++++
 .../olingo/fit/proxy/v3/OpenTypeTestITCase.java |  11 +-
 .../fit/proxy/v3/PrimitiveKeysTestITCase.java   |   7 +-
 .../olingo/fit/proxy/v4/AbstractTestITCase.java |   5 +-
 .../olingo/fit/proxy/v4/AsyncTestITCase.java    |   6 +-
 .../proxy/v4/AuthEntityRetrieveTestITCase.java  |  27 ++-
 .../fit/proxy/v4/EntityRetrieveTestITCase.java  |  25 +--
 .../olingo/fit/proxy/v4/FilterTestITCase.java   |  82 +++++++++
 .../fit/proxy/v4/KeyAsSegmentTestITCase.java    |   8 +-
 .../olingo/fit/proxy/v4/OpenTypeTestITCase.java |  20 +--
 .../apache/olingo/fit/v3/AsyncTestITCase.java   |   3 -
 30 files changed, 922 insertions(+), 418 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/EntityContainerFactory.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/EntityContainerFactory.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/EntityContainerFactory.java
index 3e8606e..c378a7a 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/EntityContainerFactory.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/EntityContainerFactory.java
@@ -22,7 +22,6 @@ import java.lang.reflect.Proxy;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.client.api.CommonConfiguration;
 import org.apache.olingo.client.api.CommonEdmEnabledODataClient;
 import org.apache.olingo.client.core.ODataClientFactory;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
@@ -30,16 +29,18 @@ import org.apache.olingo.ext.proxy.commons.EntityContainerInvocationHandler;
 import org.apache.olingo.ext.proxy.context.Context;
 
 /**
- * Entry point for ODataJClient proxy mode, gives access to entity container instances.
+ * Entry point for proxy mode, gives access to entity container instances.
+ *
+ * @param <C> actual client class
  */
-public final class EntityContainerFactory {
+public final class EntityContainerFactory<C extends CommonEdmEnabledODataClient<?>> {
 
   private static final Object MONITOR = new Object();
 
   private static Context context = null;
 
-  private static final Map<String, EntityContainerFactory> FACTORY_PER_SERVICEROOT =
-          new ConcurrentHashMap<String, EntityContainerFactory>();
+  private static final Map<String, EntityContainerFactory<?>> FACTORY_PER_SERVICEROOT =
+          new ConcurrentHashMap<String, EntityContainerFactory<?>>();
 
   private static final Map<Class<?>, Object> ENTITY_CONTAINERS = new ConcurrentHashMap<Class<?>, Object>();
 
@@ -57,23 +58,28 @@ public final class EntityContainerFactory {
     return context;
   }
 
-  private static <C extends CommonEdmEnabledODataClient<?>> EntityContainerFactory getInstance(
+  @SuppressWarnings("unchecked")
+  private static <C extends CommonEdmEnabledODataClient<?>> EntityContainerFactory<C> getInstance(
           final C client, final String serviceRoot) {
 
     if (!FACTORY_PER_SERVICEROOT.containsKey(serviceRoot)) {
-      final EntityContainerFactory instance = new EntityContainerFactory(client, serviceRoot);
+      final EntityContainerFactory<C> instance = new EntityContainerFactory<C>(client, serviceRoot);
       FACTORY_PER_SERVICEROOT.put(serviceRoot, instance);
     }
     client.getConfiguration().setDefaultPubFormat(ODataPubFormat.JSON_FULL_METADATA);
-    
-    return FACTORY_PER_SERVICEROOT.get(serviceRoot);
+
+    return (EntityContainerFactory<C>) FACTORY_PER_SERVICEROOT.get(serviceRoot);
   }
 
-  public static EntityContainerFactory getV3(final String serviceRoot) {
+  public static EntityContainerFactory<org.apache.olingo.client.api.v3.EdmEnabledODataClient> getV3(
+          final String serviceRoot) {
+
     return getInstance(ODataClientFactory.getEdmEnabledV3(serviceRoot), serviceRoot);
   }
 
-  public static EntityContainerFactory getV4(final String serviceRoot) {
+  public static EntityContainerFactory<org.apache.olingo.client.api.v4.EdmEnabledODataClient> getV4(
+          final String serviceRoot) {
+
     return getInstance(ODataClientFactory.getEdmEnabledV4(serviceRoot), serviceRoot);
   }
 
@@ -82,8 +88,9 @@ public final class EntityContainerFactory {
     this.serviceRoot = serviceRoot;
   }
 
-  public CommonConfiguration getConfiguration() {
-    return client.getConfiguration();
+  @SuppressWarnings("unchecked")
+  public C getClient() {
+    return (C) client;
   }
 
   public String getServiceRoot() {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntitySet.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntitySet.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntitySet.java
index 6f22164..71a7392 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntitySet.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntitySet.java
@@ -48,6 +48,7 @@ public interface AbstractEntitySet<
   /**
    * Retrieves an entity by its key, considering polymorphism.
    *
+   * @param <S>
    * @param key must not be null
    * @param reference entity class to be returned
    * @return the entity with the given id or null if none found
@@ -72,6 +73,8 @@ public interface AbstractEntitySet<
   /**
    * Returns all instances of the given subtype.
    *
+   * @param <S>
+   * @param <SEC>
    * @param reference entity collection class to be returned
    * @return all entities of the given subtype
    */
@@ -88,21 +91,42 @@ public interface AbstractEntitySet<
   /**
    * Deletes the given entities in a batch.
    *
+   * @param <S>
    * @param entities to be deleted
    */
   <S extends T> void delete(Iterable<S> entities);
 
   /**
-   * Create an instance of <tt>Query</tt>.
+   * Create an instance of <tt>Filter</tt>.
    *
-   * @return the new query instance
+   * @return the new filter instance
    */
-  Query<T, EC> createQuery();
+  Filter<T, EC> createFilter();
 
   /**
-   * Create an instance of <tt>Query</tt>.
+   * Create an instance of <tt>Filter</tt>.
    *
-   * @return the new query instance
+   * @param <S>
+   * @param <SEC>
+   * @param reference
+   * @return the new filter instance
    */
-  <S extends T, SEC extends AbstractEntityCollection<S>> Query<S, SEC> createQuery(Class<SEC> reference);
+  <S extends T, SEC extends AbstractEntityCollection<S>> Filter<S, SEC> createFilter(Class<SEC> reference);
+
+  /**
+   * Create an instance of <tt>Search</tt>.
+   *
+   * @return the new search instance
+   */
+  Search<T, EC> createSearch();
+
+  /**
+   * Create an instance of <tt>Search</tt>.
+   *
+   * @param <S>
+   * @param <SEC>
+   * @param reference
+   * @return the new search instance
+   */
+  <S extends T, SEC extends AbstractEntityCollection<S>> Search<S, SEC> createSearch(Class<SEC> reference);
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Filter.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Filter.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Filter.java
new file mode 100644
index 0000000..11b3e83
--- /dev/null
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Filter.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.ext.proxy.api;
+
+import java.io.Serializable;
+import org.apache.olingo.client.api.uri.URIFilter;
+
+/**
+ * Interface used to control filter execution.
+ *
+ * @param <T> filter result type
+ * @param <EC>
+ */
+public interface Filter<T extends Serializable, EC extends AbstractEntityCollection<T>> extends Serializable {
+
+  /**
+   * Sets the <tt>$filter</tt> expression for this filter.
+   * <br/>
+   * Any of available operators and functions can be embodied here.
+   *
+   * @param filter the <tt>$filter</tt> expression for this filter
+   * @return the same filter instance
+   */
+  Filter<T, EC> setFilter(String filter);
+
+  /**
+   * Sets the filter generating the <tt>$filter</tt> expression for this filter.
+   *
+   * @param filter filter instance (to be obtained via factory): note that <tt>build()</tt> method
+   * will be immediately invoked.
+   * @return the same filter instance
+   */
+  Filter<T, EC> setFilter(URIFilter filter);
+
+  /**
+   * The <tt>$filter</tt> expression for this filter.
+   *
+   * @return the <tt>$filter</tt> expression for this filter
+   */
+  String getFilter();
+
+  /**
+   * Sets the <tt>$orderBy</tt> expression for this filter via sort options.
+   *
+   * @param sort sort options
+   * @return the same filter instance
+   */
+  Filter<T, EC> setOrderBy(Sort... sort);
+
+  /**
+   * Sets the <tt>$orderBy</tt> expression for this filter.
+   *
+   * @param orderBy the <tt>$orderBy</tt> expression for this filter
+   * @return the same filter instance
+   */
+  Filter<T, EC> setOrderBy(String orderBy);
+
+  /**
+   * The <tt>$orderBy</tt> expression for this filter.
+   *
+   * @return the <tt>$orderBy</tt> expression for this filter
+   */
+  String getOrderBy();
+
+  /**
+   * Sets the maximum number of results to retrieve (<tt>$top</tt>).
+   *
+   * @param maxResults maximum number of results to retrieve
+   * @return the same filter instance
+   * @throws IllegalArgumentException if the argument is negative
+   */
+  Filter<T, EC> setMaxResults(int maxResults) throws IllegalArgumentException;
+
+  /**
+   * The maximum number of results the filter object was set to retrieve (<tt>$top</tt>). Returns
+   * <tt>Integer.MAX_VALUE</tt> if setMaxResults was not applied to the filter object.
+   *
+   * @return maximum number of results
+   */
+  int getMaxResults();
+
+  /**
+   * Sets the position of the first result to retrieve (<tt>$skip</tt>).
+   *
+   * @param firstResult position of the first result, numbered from 0
+   * @return the same filter instance
+   * @throws IllegalArgumentException if the argument is negative
+   */
+  Filter<T, EC> setFirstResult(int firstResult) throws IllegalArgumentException;
+
+  /**
+   * The position of the first result the filter object was set to retrieve (<tt>$skip</tt>).
+   *
+   * Returns 0 if <tt>setFirstResult</tt> was not applied to the filter object.
+   *
+   * @return position of the first result
+   */
+  int getFirstResult();
+
+  /**
+   * Executes a <tt>$filter</tt> filter that returns a single result.
+   *
+   * @return the result
+   * @throws NoResultException if there is no result
+   * @throws NonUniqueResultException if more than one result
+   */
+  T getSingleResult() throws NoResultException, NonUniqueResultException;
+
+  /**
+   * Executes a <tt>$filter</tt> filter and return the filter results as collection.
+   *
+   * @return an iterable view of the results
+   */
+  EC getResult();
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/NoResultException.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/NoResultException.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/NoResultException.java
index da76bf0..617b305 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/NoResultException.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/NoResultException.java
@@ -19,11 +19,7 @@
 package org.apache.olingo.ext.proxy.api;
 
 /**
- * Thrown when <tt>Query.getSingleResult()</tt> or <tt>EntityQuery.getSingleResult()</tt> is executed on a query and
- * there is no result to return.
- *
- * @see Query#getSingleResult()
- * @see EntityQuery#getSingleResult()
+ * Thrown when {@link Filter#getSingleResult()} is executed and there is no result to return.
  */
 public class NoResultException extends RuntimeException {
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/NonUniqueResultException.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/NonUniqueResultException.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/NonUniqueResultException.java
index bb5737f..37658c6 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/NonUniqueResultException.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/NonUniqueResultException.java
@@ -19,11 +19,7 @@
 package org.apache.olingo.ext.proxy.api;
 
 /**
- * Thrown when <tt>Query.getSingleResult()</tt> or <tt>EntityQuery.getSingleResult()</tt> is executed on a query and
- * there is more than one result from the query.
- *
- * @see Query#getSingleResult()
- * @see EntityQuery#getSingleResult()
+ * Thrown when {@link Filter#getSingleResult()} is executed and there is more than one result.
  */
 public class NonUniqueResultException extends RuntimeException {
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Query.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Query.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Query.java
deleted file mode 100644
index ec7b944..0000000
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Query.java
+++ /dev/null
@@ -1,128 +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.ext.proxy.api;
-
-import java.io.Serializable;
-import org.apache.olingo.client.api.uri.URIFilter;
-
-/**
- * Interface used to control query execution.
- *
- * @param <T> query result type
- */
-public interface Query<T extends Serializable, EC extends AbstractEntityCollection<T>> extends Serializable {
-
-  /**
-   * Sets the <tt>$filter</tt> expression for this query. Any of available operators and functions can be embodied here.
-   *
-   * @param filter the <tt>$filter</tt> expression for this query
-   * @return the same query instance
-   */
-  Query<T, EC> setFilter(String filter);
-
-  /**
-   * Sets the filter generating the <tt>$filter</tt> expression for this query.
-   *
-   * @param filter filter instance (to be obtained via <tt>ODataFilterFactory</tt>): note that <tt>build()</tt> method
-   * will be immediately invoked.
-   * @return the same query instance
-   */
-  Query<T, EC> setFilter(URIFilter filter);
-
-  /**
-   * The <tt>$filter</tt> expression for this query.
-   *
-   * @return the <tt>$filter</tt> expression for this query
-   */
-  String getFilter();
-
-  /**
-   * Sets the <tt>$orderBy</tt> expression for this query via sort options.
-   *
-   * @param sort sort options
-   * @return the same query instance
-   */
-  Query<T, EC> setOrderBy(Sort... sort);
-
-  /**
-   * Sets the <tt>$orderBy</tt> expression for this query.
-   *
-   * @param select the <tt>$orderBy</tt> expression for this query
-   * @return the same query instance
-   */
-  Query<T, EC> setOrderBy(String orderBy);
-
-  /**
-   * The <tt>$orderBy</tt> expression for this query.
-   *
-   * @return the <tt>$orderBy</tt> expression for this query
-   */
-  String getOrderBy();
-
-  /**
-   * Sets the maximum number of results to retrieve (<tt>$top</tt>).
-   *
-   * @param maxResults maximum number of results to retrieve
-   * @return the same query instance
-   * @throws IllegalArgumentException if the argument is negative
-   */
-  Query<T, EC> setMaxResults(int maxResults) throws IllegalArgumentException;
-
-  /**
-   * The maximum number of results the query object was set to retrieve (<tt>$top</tt>). Returns
-   * <tt>Integer.MAX_VALUE</tt> if setMaxResults was not applied to the query object.
-   *
-   * @return maximum number of results
-   */
-  int getMaxResults();
-
-  /**
-   * Sets the position of the first result to retrieve (<tt>$skip</tt>).
-   *
-   * @param firstResult position of the first result, numbered from 0
-   * @return the same query instance
-   * @throws IllegalArgumentException if the argument is negative
-   */
-  Query<T, EC> setFirstResult(int firstResult) throws IllegalArgumentException;
-
-  /**
-   * The position of the first result the query object was set to retrieve (<tt>$skip</tt>).
-   *
-   * Returns 0 if <tt>setFirstResult</tt> was not applied to the query object.
-   *
-   * @return position of the first result
-   */
-  int getFirstResult();
-
-  /**
-   * Executes a <tt>$filter</tt> query that returns a single result.
-   *
-   * @return the result
-   * @throws NoResultException if there is no result
-   * @throws NonUniqueResultException if more than one result
-   */
-  T getSingleResult() throws NoResultException, NonUniqueResultException;
-
-  /**
-   * Executes a <tt>$filter</tt> query and return the query results as collection.
-   *
-   * @return an iterable view of the results
-   */
-  EC getResult();
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Search.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Search.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Search.java
new file mode 100644
index 0000000..a4efc22
--- /dev/null
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Search.java
@@ -0,0 +1,64 @@
+/*
+ * 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.ext.proxy.api;
+
+import java.io.Serializable;
+import org.apache.olingo.client.api.uri.v4.URISearch;
+
+/**
+ * Interface used to control search execution.
+ *
+ * @param <T> search result type
+ * @param <EC>
+ */
+public interface Search<T extends Serializable, EC extends AbstractEntityCollection<T>> extends Serializable {
+
+  /**
+   * Sets the <tt>$search</tt> expression for this search.
+   * <br/>
+   * Any of available operators and functions can be embodied here.
+   *
+   * @param search the <tt>$search</tt> expression for this search
+   * @return the same search instance
+   */
+  Search<T, EC> setSearch(String search);
+
+  /**
+   * Sets the search generating the <tt>$search</tt> expression for this search.
+   *
+   * @param search search instance (to be obtained via <tt>ODataSearchFactory</tt>): note that <tt>build()</tt> method
+   * will be immediately invoked.
+   * @return the same search instance
+   */
+  Search<T, EC> setSearch(URISearch search);
+
+  /**
+   * The <tt>$search</tt> expression for this search.
+   *
+   * @return the <tt>$search</tt> expression for this search
+   */
+  String getSearch();
+
+  /**
+   * Executes a <tt>$search</tt> search and return the search results as collection.
+   *
+   * @return an iterable view of the results
+   */
+  EC getResult();
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java
index bee8d12..dcd7812 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java
@@ -36,16 +36,20 @@ import org.apache.commons.lang3.ArrayUtils;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
 import org.apache.olingo.client.api.uri.CommonURIBuilder;
+import org.apache.olingo.client.api.v3.UnsupportedInV3Exception;
+import org.apache.olingo.client.api.v4.EdmEnabledODataClient;
 import org.apache.olingo.client.api.v4.ODataClient;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
 import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.ODataValueFormat;
 import org.apache.olingo.ext.proxy.EntityContainerFactory;
 import org.apache.olingo.ext.proxy.api.AbstractEntityCollection;
 import org.apache.olingo.ext.proxy.api.AbstractEntitySet;
 import org.apache.olingo.ext.proxy.api.AbstractSingleton;
-import org.apache.olingo.ext.proxy.api.Query;
+import org.apache.olingo.ext.proxy.api.Filter;
+import org.apache.olingo.ext.proxy.api.Search;
 import org.apache.olingo.ext.proxy.api.annotations.CompoundKey;
 import org.apache.olingo.ext.proxy.api.annotations.CompoundKeyElement;
 import org.apache.olingo.ext.proxy.api.annotations.EntitySet;
@@ -93,7 +97,7 @@ class EntitySetInvocationHandler<
           final String entitySetName) {
 
     super(containerHandler.getClient(), containerHandler);
-    
+
     this.entitySetName = entitySetName;
     this.isSingleton = AbstractSingleton.class.isAssignableFrom(ref);
 
@@ -245,7 +249,7 @@ class EntitySetInvocationHandler<
           uriBuilder.appendKeySegment(getCompoundKey(key));
         }
 
-        LOG.debug("Execute query '{}'", uriBuilder.toString());
+        LOG.debug("GET {}", uriBuilder.toString());
 
         final ODataRetrieveResponse<CommonODataEntity> res =
                 client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()).execute();
@@ -355,15 +359,37 @@ class EntitySetInvocationHandler<
   }
 
   @Override
-  public Query<T, EC> createQuery() {
-    return new QueryImpl<T, EC>(this.client, this.collTypeRef, this.uri, this);
+  public Filter<T, EC> createFilter() {
+    return new FilterImpl<T, EC>(this.client, this.collTypeRef, this.uri, this);
   }
 
   @Override
-  public <S extends T, SEC extends AbstractEntityCollection<S>> Query<S, SEC> createQuery(
+  @SuppressWarnings("unchecked")
+  public <S extends T, SEC extends AbstractEntityCollection<S>> Filter<S, SEC> createFilter(
           final Class<SEC> reference) {
 
-    return new QueryImpl<S, SEC>(this.client, reference, this.uri, this);
+    return new FilterImpl<S, SEC>(
+            this.client, reference, this.uri, (EntitySetInvocationHandler<S, ?, SEC>) this);
+  }
+
+  @Override
+  public Search<T, EC> createSearch() {
+    if (client.getServiceVersion().compareTo(ODataServiceVersion.V30) <= 0) {
+      throw new UnsupportedInV3Exception();
+    }
+    return new SearchImpl<T, EC>((EdmEnabledODataClient) this.client, this.collTypeRef, this.uri, this);
+  }
+
+  @Override
+  @SuppressWarnings("unchecked")
+  public <S extends T, SEC extends AbstractEntityCollection<S>> Search<S, SEC> createSearch(
+          final Class<SEC> reference) {
+
+    if (client.getServiceVersion().compareTo(ODataServiceVersion.V30) <= 0) {
+      throw new UnsupportedInV3Exception();
+    }
+    return new SearchImpl<S, SEC>(
+            (EdmEnabledODataClient) this.client, reference, this.uri, (EntitySetInvocationHandler<S, ?, SEC>) this);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/FilterImpl.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/FilterImpl.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/FilterImpl.java
new file mode 100644
index 0000000..4299dde
--- /dev/null
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/FilterImpl.java
@@ -0,0 +1,172 @@
+/*
+ * 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.ext.proxy.commons;
+
+import java.io.Serializable;
+import java.net.URI;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.client.api.CommonODataClient;
+import org.apache.olingo.client.api.uri.CommonURIBuilder;
+import org.apache.olingo.client.api.uri.URIFilter;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.ext.proxy.api.AbstractEntityCollection;
+import org.apache.olingo.ext.proxy.api.NoResultException;
+import org.apache.olingo.ext.proxy.api.NonUniqueResultException;
+import org.apache.olingo.ext.proxy.api.Filter;
+import org.apache.olingo.ext.proxy.api.Sort;
+import org.apache.olingo.ext.proxy.utils.ClassUtils;
+
+public class FilterImpl<T extends Serializable, EC extends AbstractEntityCollection<T>> implements Filter<T, EC> {
+
+  private static final long serialVersionUID = -300830736753191114L;
+
+  private final CommonODataClient<?> client;
+
+  private final Class<T> typeRef;
+
+  private final Class<EC> collTypeRef;
+
+  private final EntitySetInvocationHandler<T, ?, EC> handler;
+
+  private final URI baseURI;
+
+  private String filter;
+
+  private String orderBy;
+
+  private Integer maxResults;
+
+  private Integer firstResult;
+
+  @SuppressWarnings("unchecked")
+  FilterImpl(final CommonODataClient<?> client,
+          final Class<EC> collTypeRef, final URI baseURI, final EntitySetInvocationHandler<T, ?, EC> handler) {
+
+    this.client = client;
+    this.typeRef = (Class<T>) ClassUtils.extractTypeArg(collTypeRef);
+    this.collTypeRef = collTypeRef;
+    this.baseURI = baseURI;
+    this.handler = handler;
+  }
+
+  @Override
+  public Filter<T, EC> setFilter(final String filter) {
+    this.filter = filter;
+    return this;
+  }
+
+  @Override
+  public Filter<T, EC> setFilter(final URIFilter filter) {
+    this.filter = filter.build();
+    return this;
+  }
+
+  @Override
+  public String getFilter() {
+    return filter;
+  }
+
+  @Override
+  public Filter<T, EC> setOrderBy(final Sort... sort) {
+    final StringBuilder builder = new StringBuilder();
+    for (Sort sortClause : sort) {
+      builder.append(sortClause.getKey()).append(' ').append(sortClause.getValue()).append(',');
+    }
+    builder.deleteCharAt(builder.length() - 1);
+
+    this.orderBy = builder.toString();
+    return this;
+  }
+
+  @Override
+  public Filter<T, EC> setOrderBy(final String orderBy) {
+    this.orderBy = orderBy;
+    return this;
+  }
+
+  @Override
+  public String getOrderBy() {
+    return orderBy;
+  }
+
+  @Override
+  public Filter<T, EC> setMaxResults(final int maxResults) throws IllegalArgumentException {
+    if (maxResults <= 0) {
+      throw new IllegalArgumentException("maxResults must be positive");
+    }
+
+    this.maxResults = maxResults;
+    return this;
+  }
+
+  @Override
+  public int getMaxResults() {
+    return maxResults;
+  }
+
+  @Override
+  public Filter<T, EC> setFirstResult(final int firstResult) throws IllegalArgumentException {
+    if (firstResult <= 0) {
+      throw new IllegalArgumentException("firstResult must be positive");
+    }
+
+    this.firstResult = firstResult;
+    return this;
+  }
+
+  @Override
+  public int getFirstResult() {
+    return firstResult;
+  }
+
+  @Override
+  public T getSingleResult() throws NoResultException, NonUniqueResultException {
+    final EC result = getResult();
+    if (result.isEmpty()) {
+      throw new NoResultException();
+    }
+    if (result.size() > 1) {
+      throw new NonUniqueResultException();
+    }
+
+    return result.iterator().next();
+  }
+
+  @Override
+  public EC getResult() {
+    final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(this.baseURI.toASCIIString()).
+            appendDerivedEntityTypeSegment(new FullQualifiedName(
+                            ClassUtils.getNamespace(typeRef), ClassUtils.getEntityTypeName(typeRef)).toString());
+
+    if (StringUtils.isNotBlank(filter)) {
+      uriBuilder.filter(filter);
+    }
+    if (StringUtils.isNotBlank(orderBy)) {
+      uriBuilder.orderBy(orderBy);
+    }
+    if (maxResults != null) {
+      uriBuilder.top(maxResults);
+    }
+    if (firstResult != null) {
+      uriBuilder.skip(firstResult);
+    }
+
+    return handler.fetchWholeEntitySet(uriBuilder.build(), typeRef, collTypeRef);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/QueryImpl.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/QueryImpl.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/QueryImpl.java
deleted file mode 100644
index 00c3f73..0000000
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/QueryImpl.java
+++ /dev/null
@@ -1,173 +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.ext.proxy.commons;
-
-import java.io.Serializable;
-import java.net.URI;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.client.api.CommonODataClient;
-import org.apache.olingo.client.api.uri.CommonURIBuilder;
-import org.apache.olingo.client.api.uri.URIFilter;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.ext.proxy.api.AbstractEntityCollection;
-import org.apache.olingo.ext.proxy.api.NoResultException;
-import org.apache.olingo.ext.proxy.api.NonUniqueResultException;
-import org.apache.olingo.ext.proxy.api.Query;
-import org.apache.olingo.ext.proxy.api.Sort;
-import org.apache.olingo.ext.proxy.utils.ClassUtils;
-
-public class QueryImpl<T extends Serializable, EC extends AbstractEntityCollection<T>> implements Query<T, EC> {
-
-  private static final long serialVersionUID = -300830736753191114L;
-
-  private final CommonODataClient client;
-
-  private final Class<T> typeRef;
-
-  private final Class<EC> collTypeRef;
-
-  private final EntitySetInvocationHandler handler;
-
-  private final URI baseURI;
-
-  private String filter;
-
-  private String orderBy;
-
-  private Integer maxResults;
-
-  private Integer firstResult;
-
-  @SuppressWarnings("unchecked")
-  QueryImpl(final CommonODataClient client,
-          final Class<EC> collTypeRef, final URI baseURI, final EntitySetInvocationHandler handler) {
-
-    this.client = client;
-    this.typeRef = (Class<T>) ClassUtils.extractTypeArg(collTypeRef);
-    this.collTypeRef = collTypeRef;
-    this.baseURI = baseURI;
-    this.handler = handler;
-  }
-
-  @Override
-  public Query<T, EC> setFilter(final String filter) {
-    this.filter = filter;
-    return this;
-  }
-
-  @Override
-  public Query<T, EC> setFilter(final URIFilter filter) {
-    this.filter = filter.build();
-    return this;
-  }
-
-  @Override
-  public String getFilter() {
-    return filter;
-  }
-
-  @Override
-  public Query<T, EC> setOrderBy(final Sort... sort) {
-    final StringBuilder builder = new StringBuilder();
-    for (Sort sortClause : sort) {
-      builder.append(sortClause.getKey()).append(' ').append(sortClause.getValue()).append(',');
-    }
-    builder.deleteCharAt(builder.length() - 1);
-
-    this.orderBy = builder.toString();
-    return this;
-  }
-
-  @Override
-  public Query<T, EC> setOrderBy(final String orderBy) {
-    this.orderBy = orderBy;
-    return this;
-  }
-
-  @Override
-  public String getOrderBy() {
-    return orderBy;
-  }
-
-  @Override
-  public Query<T, EC> setMaxResults(final int maxResults) throws IllegalArgumentException {
-    if (maxResults <= 0) {
-      throw new IllegalArgumentException("maxResults must be positive");
-    }
-
-    this.maxResults = maxResults;
-    return this;
-  }
-
-  @Override
-  public int getMaxResults() {
-    return maxResults;
-  }
-
-  @Override
-  public Query<T, EC> setFirstResult(final int firstResult) throws IllegalArgumentException {
-    if (firstResult <= 0) {
-      throw new IllegalArgumentException("firstResult must be positive");
-    }
-
-    this.firstResult = firstResult;
-    return this;
-  }
-
-  @Override
-  public int getFirstResult() {
-    return firstResult;
-  }
-
-  @Override
-  public T getSingleResult() throws NoResultException, NonUniqueResultException {
-    final EC result = getResult();
-    if (result.isEmpty()) {
-      throw new NoResultException();
-    }
-    if (result.size() > 1) {
-      throw new NonUniqueResultException();
-    }
-
-    return result.iterator().next();
-  }
-
-  @Override
-  @SuppressWarnings("unchecked")
-  public EC getResult() {
-    final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(this.baseURI.toASCIIString()).
-            appendNavigationSegment(new FullQualifiedName(
-            ClassUtils.getNamespace(typeRef), ClassUtils.getEntityTypeName(typeRef)).toString());
-
-    if (StringUtils.isNotBlank(filter)) {
-      uriBuilder.filter(filter);
-    }
-    if (StringUtils.isNotBlank(orderBy)) {
-      uriBuilder.orderBy(orderBy);
-    }
-    if (maxResults != null) {
-      uriBuilder.top(maxResults);
-    }
-    if (firstResult != null) {
-      uriBuilder.skip(firstResult);
-    }
-
-    return (EC) handler.fetchWholeEntitySet(uriBuilder.build(), typeRef, collTypeRef);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SearchImpl.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SearchImpl.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SearchImpl.java
new file mode 100644
index 0000000..73a0585
--- /dev/null
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SearchImpl.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.ext.proxy.commons;
+
+import java.io.Serializable;
+import java.net.URI;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.client.api.uri.v4.URIBuilder;
+import org.apache.olingo.client.api.uri.v4.URISearch;
+import org.apache.olingo.client.api.v4.EdmEnabledODataClient;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.ext.proxy.api.AbstractEntityCollection;
+import org.apache.olingo.ext.proxy.api.Search;
+import org.apache.olingo.ext.proxy.utils.ClassUtils;
+
+public class SearchImpl<T extends Serializable, EC extends AbstractEntityCollection<T>> implements Search<T, EC> {
+
+  private static final long serialVersionUID = 4383858176507769973L;
+
+  private final EdmEnabledODataClient client;
+
+  private final Class<T> typeRef;
+
+  private final Class<EC> collTypeRef;
+
+  private final EntitySetInvocationHandler<T, ?, EC> handler;
+
+  private final URI baseURI;
+
+  private String search;
+
+  @SuppressWarnings("unchecked")
+  SearchImpl(EdmEnabledODataClient client,
+          final Class<EC> collTypeRef, final URI baseURI, final EntitySetInvocationHandler<T, ?, EC> handler) {
+
+    this.client = client;
+    this.typeRef = (Class<T>) ClassUtils.extractTypeArg(collTypeRef);
+    this.collTypeRef = collTypeRef;
+    this.baseURI = baseURI;
+    this.handler = handler;
+  }
+
+  @Override
+  public Search<T, EC> setSearch(final String search) {
+    this.search = search;
+    return this;
+  }
+
+  @Override
+  public Search<T, EC> setSearch(final URISearch search) {
+    this.search = search.build();
+    return this;
+  }
+
+  @Override
+  public String getSearch() {
+    return search;
+  }
+
+  @Override
+  public EC getResult() {
+    final URIBuilder uriBuilder = client.getURIBuilder(this.baseURI.toASCIIString()).
+            appendDerivedEntityTypeSegment(new FullQualifiedName(
+                    ClassUtils.getNamespace(typeRef), ClassUtils.getEntityTypeName(typeRef)).toString());
+
+    if (StringUtils.isNotBlank(search)) {
+      uriBuilder.search(search);
+    }
+
+    return handler.fetchWholeEntitySet(uriBuilder.build(), typeRef, collTypeRef);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/fit/src/main/java/org/apache/olingo/fit/V3Services.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/V3Services.java b/fit/src/main/java/org/apache/olingo/fit/V3Services.java
index 45642c3..410fcad 100644
--- a/fit/src/main/java/org/apache/olingo/fit/V3Services.java
+++ b/fit/src/main/java/org/apache/olingo/fit/V3Services.java
@@ -211,6 +211,22 @@ public class V3Services extends AbstractServices {
   }
 
   @GET
+  @Path("/Car/{type:.*}")
+  public Response filterCar(
+          @Context UriInfo uriInfo,
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+          @QueryParam("$top") @DefaultValue(StringUtils.EMPTY) String top,
+          @QueryParam("$skip") @DefaultValue(StringUtils.EMPTY) String skip,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
+          @QueryParam("$inlinecount") @DefaultValue(StringUtils.EMPTY) String count,
+          @QueryParam("$filter") @DefaultValue(StringUtils.EMPTY) String filter,
+          @QueryParam("$orderby") @DefaultValue(StringUtils.EMPTY) String orderby,
+          @QueryParam("$skiptoken") @DefaultValue(StringUtils.EMPTY) String skiptoken) {
+    
+    return super.getEntitySet(uriInfo, accept, "Car", top, skip, format, count, filter, orderby, skiptoken);
+  }  
+  
+  @GET
   @Path("/Login({entityId})")
   public Response getLogin(
           @Context UriInfo uriInfo,

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/fit/src/main/java/org/apache/olingo/fit/V4Services.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/V4Services.java b/fit/src/main/java/org/apache/olingo/fit/V4Services.java
index 2d774d5..52d8cb6 100644
--- a/fit/src/main/java/org/apache/olingo/fit/V4Services.java
+++ b/fit/src/main/java/org/apache/olingo/fit/V4Services.java
@@ -54,6 +54,7 @@ import javax.ws.rs.core.UriInfo;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.math.NumberUtils;
 import org.apache.cxf.interceptor.InInterceptors;
 import org.apache.cxf.jaxrs.ext.multipart.Attachment;
 import org.apache.cxf.jaxrs.ext.multipart.Multipart;
@@ -102,7 +103,7 @@ public class V4Services extends AbstractServices {
   protected static final Pattern CROSSJOIN_PATTERN = Pattern.compile(
           "^\\$crossjoin\\(.*\\)\\?\\$filter=\\([a-zA-Z/]+ eq [a-zA-Z/]+\\)$");
 
-  private Map<String, String> providedAsync = new HashMap<String, String>();
+  private final Map<String, String> providedAsync = new HashMap<String, String>();
 
   public V4Services() throws Exception {
     super(ODataServiceVersion.V40, Commons.getMetadata(ODataServiceVersion.V40));
@@ -346,6 +347,29 @@ public class V4Services extends AbstractServices {
   }
 
   @GET
+  @Path("/People/{type:.*}")
+  public Response getPeople(
+          @Context UriInfo uriInfo,
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+          @PathParam("type") final String type, 
+          @QueryParam("$top") @DefaultValue(StringUtils.EMPTY) String top,
+          @QueryParam("$skip") @DefaultValue(StringUtils.EMPTY) String skip,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
+          @QueryParam("$inlinecount") @DefaultValue(StringUtils.EMPTY) String count,
+          @QueryParam("$filter") @DefaultValue(StringUtils.EMPTY) String filter,
+          @QueryParam("$search") @DefaultValue(StringUtils.EMPTY) String search,
+          @QueryParam("$orderby") @DefaultValue(StringUtils.EMPTY) String orderby,
+          @QueryParam("$skiptoken") @DefaultValue(StringUtils.EMPTY) String skiptoken) {
+
+    return StringUtils.isBlank(filter) && StringUtils.isBlank(search)
+            ? NumberUtils.isNumber(type)
+            ? super.getEntityInternal(
+                    uriInfo.getRequestUri().toASCIIString(), accept, "People", type, format, null, null, true)
+            : super.getEntitySet(accept, "People", type)
+            : super.getEntitySet(uriInfo, accept, "People", top, skip, format, count, filter, orderby, skiptoken);
+  }
+
+  @GET
   @Path("/Boss")
   public Response getSingletonBoss(
           @Context UriInfo uriInfo,
@@ -1239,7 +1263,7 @@ public class V4Services extends AbstractServices {
         acceptType = Accept.parse(accept, version);
       }
 
-      final Accept contentTypeValue = Accept.parse(contentType, version);      
+      final Accept contentTypeValue = Accept.parse(contentType, version);
       final AtomEntityImpl entity = xml.readEntity(contentTypeValue, IOUtils.toInputStream(param, Constants.ENCODING));
 
       assert "Microsoft.Test.OData.Services.ODataWCFService.Address".equals(entity.getType());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/fit/src/main/resources/V30/Car/filter/(VIN eq 16).full.json
----------------------------------------------------------------------
diff --git a/fit/src/main/resources/V30/Car/filter/(VIN eq 16).full.json b/fit/src/main/resources/V30/Car/filter/(VIN eq 16).full.json
new file mode 100644
index 0000000..6c1637c
--- /dev/null
+++ b/fit/src/main/resources/V30/Car/filter/(VIN eq 16).full.json	
@@ -0,0 +1,15 @@
+{
+  "odata.metadata": "http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/$metadata#Car",
+  "value": [{
+      "odata.type": "Microsoft.Test.OData.Services.AstoriaDefaultService.Car",
+      "odata.id": "http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Car(16)",
+      "odata.editLink": "Car(16)",
+      "odata.mediaEditLink": "Car(16)/$value",
+      "odata.mediaReadLink": "Car(16)/$value",
+      "odata.mediaContentType": "application/octet-stream",
+      "Photo@odata.mediaEditLink": "Car(16)/Photo",
+      "Video@odata.mediaEditLink": "Car(16)/Video",
+      "VIN": 16,
+      "Description": "kphszztczthjacvjnttrarxru"
+    }]
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/fit/src/main/resources/V30/Car/filter/(VIN eq 16).xml
----------------------------------------------------------------------
diff --git a/fit/src/main/resources/V30/Car/filter/(VIN eq 16).xml b/fit/src/main/resources/V30/Car/filter/(VIN eq 16).xml
new file mode 100644
index 0000000..83f6e67
--- /dev/null
+++ b/fit/src/main/resources/V30/Car/filter/(VIN eq 16).xml	
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+    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.
+
+-->
+<feed xml:base="http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml">
+  <id>http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Car</id>
+  <title type="text">Car</title>
+  <updated>2014-02-13T12:09:31Z</updated>
+  <link rel="self" title="Car" href="Car" />
+  <entry>
+    <id>http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Car(16)</id>
+    <category term="Microsoft.Test.OData.Services.AstoriaDefaultService.Car" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
+    <link rel="edit" title="Car" href="Car(16)" />
+    <title />
+    <updated>2014-02-13T12:09:31Z</updated>
+    <author>
+      <name />
+    </author>
+    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/edit-media/Photo" title="Photo" href="Car(16)/Photo" />
+    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/edit-media/Video" title="Video" href="Car(16)/Video" />
+    <link rel="edit-media" title="Car" href="Car(16)/$value" />
+    <content type="application/octet-stream" src="Car(16)/$value" />
+    <m:properties>
+      <d:VIN m:type="Edm.Int32">16</d:VIN>
+      <d:Description>cenbviijieljtrtdslbuiqubcvhxhzenidqdnaopplvlqc</d:Description>
+    </m:properties>
+  </entry>
+</feed>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AbstractTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AbstractTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AbstractTestITCase.java
index 987ecb5..de9cdc3 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AbstractTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AbstractTestITCase.java
@@ -26,19 +26,17 @@ import static org.junit.Assert.assertNotNull;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.Collections;
+import org.apache.olingo.client.api.v3.EdmEnabledODataClient;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.ext.proxy.EntityContainerFactory;
 import org.apache.olingo.ext.proxy.context.EntityContext;
 import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.
         DefaultContainer;
-import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.
-        types.ContactDetails;
-import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.
-        types.Customer;
-import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.
-        types.Aliases;
-import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.
-        types.Phone;
+import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.
+        ContactDetails;
+import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Customer;
+import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Aliases;
+import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Phone;
 
 import org.junit.BeforeClass;
 import org.slf4j.Logger;
@@ -69,7 +67,7 @@ public abstract class AbstractTestITCase {
 
   protected final EntityContext entityContext = EntityContainerFactory.getContext().entityContext();
 
-  protected static EntityContainerFactory containerFactory;
+  protected static EntityContainerFactory<EdmEnabledODataClient> containerFactory;
 
   protected static DefaultContainer container;
 
@@ -84,7 +82,7 @@ public abstract class AbstractTestITCase {
     testAuthServiceRootURL = "http://localhost:9080/stub/DefaultService.svc";
 
     containerFactory = EntityContainerFactory.getV3(testStaticServiceRootURL);
-    containerFactory.getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
+    containerFactory.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
     container = containerFactory.getEntityContainer(DefaultContainer.class);
     assertNotNull(container);
     EntityContainerFactory.getContext().detachAll();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/fit/src/test/java/org/apache/olingo/fit/proxy/v3/ActionOverloadingTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/ActionOverloadingTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/ActionOverloadingTestITCase.java
index c573af6..c0e65c9 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/ActionOverloadingTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/ActionOverloadingTestITCase.java
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 
+import org.apache.olingo.client.api.v3.EdmEnabledODataClient;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.ext.proxy.EntityContainerFactory;
 import org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.
@@ -44,8 +45,9 @@ import org.junit.Test;
 public class ActionOverloadingTestITCase extends AbstractTestITCase {
 
   private DefaultContainer getContainer() {
-    final EntityContainerFactory ecf = EntityContainerFactory.getV3(testActionOverloadingServiceRootURL);
-    ecf.getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
+    final EntityContainerFactory<EdmEnabledODataClient> ecf = 
+            EntityContainerFactory.getV3(testActionOverloadingServiceRootURL);
+    ecf.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
     return ecf.getEntityContainer(DefaultContainer.class);
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AsyncTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AsyncTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AsyncTestITCase.java
index 3cd51bc..70346f7 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AsyncTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AsyncTestITCase.java
@@ -27,7 +27,7 @@ import java.util.UUID;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import org.apache.olingo.ext.proxy.api.AsyncCall;
-import org.apache.olingo.ext.proxy.api.Query;
+import org.apache.olingo.ext.proxy.api.Filter;
 import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Employee;
 import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.
         EmployeeCollection;
@@ -45,7 +45,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
   @Test
   public void retrieveEntitySet() throws InterruptedException, ExecutionException {
     final Future<ProductCollection> futureProds =
-            new AsyncCall<ProductCollection>(containerFactory.getConfiguration()) {
+            new AsyncCall<ProductCollection>(containerFactory.getClient().getConfiguration()) {
 
               @Override
               public ProductCollection call() {
@@ -73,7 +73,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
     final Product product = container.getProduct().get(-10);
     product.setDescription("AsyncTest#updateEntity " + random);
 
-    final Future<Void> futureFlush = new AsyncCall<Void>(containerFactory.getConfiguration()) {
+    final Future<Void> futureFlush = new AsyncCall<Void>(containerFactory.getClient().getConfiguration()) {
 
       @Override
       public Void call() {
@@ -87,7 +87,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
       Thread.sleep(1000L);
     }
 
-    final Future<Product> futureProd = new AsyncCall<Product>(containerFactory.getConfiguration()) {
+    final Future<Product> futureProd = new AsyncCall<Product>(containerFactory.getClient().getConfiguration()) {
 
       @Override
       public Product call() {
@@ -100,22 +100,23 @@ public class AsyncTestITCase extends AbstractTestITCase {
 
   @Test
   public void polymorphQuery() throws Exception {
-    final Future<Query<Employee, EmployeeCollection>> queryEmployee =
-            new AsyncCall<Query<Employee, EmployeeCollection>>(containerFactory.getConfiguration()) {
+    final Future<Filter<Employee, EmployeeCollection>> queryEmployee =
+            new AsyncCall<Filter<Employee, EmployeeCollection>>(containerFactory.getClient().getConfiguration()) {
 
               @Override
-              public Query<Employee, EmployeeCollection> call() {
-                return container.getPerson().createQuery(EmployeeCollection.class);
+              public Filter<Employee, EmployeeCollection> call() {
+                return container.getPerson().createFilter(EmployeeCollection.class);
               }
             };
     assertFalse(queryEmployee.get().getResult().isEmpty());
 
-    final Future<Query<SpecialEmployee, SpecialEmployeeCollection>> querySpecialEmployee =
-            new AsyncCall<Query<SpecialEmployee, SpecialEmployeeCollection>>(containerFactory.getConfiguration()) {
+    final Future<Filter<SpecialEmployee, SpecialEmployeeCollection>> querySpecialEmployee =
+            new AsyncCall<Filter<SpecialEmployee, SpecialEmployeeCollection>>(
+                    containerFactory.getClient().getConfiguration()) {
 
               @Override
-              public Query<SpecialEmployee, SpecialEmployeeCollection> call() {
-                return container.getPerson().createQuery(SpecialEmployeeCollection.class);
+              public Filter<SpecialEmployee, SpecialEmployeeCollection> call() {
+                return container.getPerson().createFilter(SpecialEmployeeCollection.class);
               }
             };
     assertFalse(querySpecialEmployee.get().getResult().isEmpty());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AuthEntityRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AuthEntityRetrieveTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AuthEntityRetrieveTestITCase.java
index cca4f1f..7a721a4 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AuthEntityRetrieveTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AuthEntityRetrieveTestITCase.java
@@ -33,7 +33,7 @@ public class AuthEntityRetrieveTestITCase extends EntityRetrieveTestITCase {
   @BeforeClass
   public static void setupContaner() {
     containerFactory = EntityContainerFactory.getV3(testAuthServiceRootURL);
-    containerFactory.getConfiguration().
+    containerFactory.getClient().getConfiguration().
             setHttpClientFactory(new BasicAuthHttpClientFactory("odatajclient", "odatajclient"));
     container = containerFactory.getEntityContainer(DefaultContainer.class);
     assertNotNull(container);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/fit/src/test/java/org/apache/olingo/fit/proxy/v3/FilterTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/FilterTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/FilterTestITCase.java
new file mode 100644
index 0000000..2ceb3c7
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/FilterTestITCase.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.fit.proxy.v3;
+
+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 static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.apache.olingo.ext.proxy.api.NonUniqueResultException;
+import org.apache.olingo.ext.proxy.api.Filter;
+import org.apache.olingo.ext.proxy.api.Sort;
+import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Car;
+import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.
+        CarCollection;
+import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Employee;
+import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.
+        EmployeeCollection;
+import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.
+        SpecialEmployee;
+import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.
+        SpecialEmployeeCollection;
+import org.junit.Test;
+
+public class FilterTestITCase extends AbstractTestITCase {
+
+  @Test
+  public void filterOrderby() {
+    final Filter<Car, CarCollection> filter = container.getCar().createFilter().
+            setFilter(containerFactory.getClient().getFilterFactory().lt("VIN", 16));
+    CarCollection result = filter.getResult();
+    assertNotNull(result);
+
+    // 1. check that filtered entity set looks as expected
+    assertEquals(5, result.size());
+
+    // 2. extract VIN values - sorted ASC by default
+    final List<Integer> vinsASC = new ArrayList<Integer>(5);
+    for (Car car : result) {
+      assertTrue(car.getVIN() < 16);
+      vinsASC.add(car.getVIN());
+    }
+
+    // 3. add orderby clause to filter above
+    result = filter.setOrderBy(new Sort("VIN", Sort.Direction.DESC)).getResult();
+    assertNotNull(result);
+    assertEquals(5, result.size());
+
+    // 4. extract again VIN value - now they were required to be sorted DESC
+    final List<Integer> vinsDESC = new ArrayList<Integer>(5);
+    for (Car car : result) {
+      assertTrue(car.getVIN() < 16);
+      vinsDESC.add(car.getVIN());
+    }
+
+    // 5. reverse vinsASC and expect to be equal to vinsDESC
+    Collections.reverse(vinsASC);
+    assertEquals(vinsASC, vinsDESC);
+  }
+
+  @Test
+  public void single() {
+    final Filter<Car, CarCollection> filter = container.getCar().createFilter().
+            setFilter(containerFactory.getClient().getFilterFactory().lt("VIN", 16));
+
+    Exception exception = null;
+    try {
+      filter.getSingleResult();
+      fail();
+    } catch (NonUniqueResultException e) {
+      exception = e;
+    }
+    assertNotNull(exception);
+
+    filter.setFilter(containerFactory.getClient().getFilterFactory().eq("VIN", 16));
+    final Car result = filter.getSingleResult();
+    assertNotNull(result);
+  }
+
+  @Test
+  public void derived() {
+    final Filter<Employee, EmployeeCollection> filterEmployee =
+            container.getPerson().createFilter(EmployeeCollection.class);
+    assertFalse(filterEmployee.getResult().isEmpty());
+
+    final Filter<SpecialEmployee, SpecialEmployeeCollection> filterSpecialEmployee =
+            container.getPerson().createFilter(SpecialEmployeeCollection.class);
+    assertFalse(filterSpecialEmployee.getResult().isEmpty());
+
+    assertTrue(container.getPerson().getAll().size()
+            > filterEmployee.getResult().size() + filterSpecialEmployee.getResult().size());
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/fit/src/test/java/org/apache/olingo/fit/proxy/v3/OpenTypeTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/OpenTypeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/OpenTypeTestITCase.java
index 3cc863d..28b768f 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/OpenTypeTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/OpenTypeTestITCase.java
@@ -28,7 +28,7 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.UUID;
-
+import org.apache.olingo.client.api.v3.EdmEnabledODataClient;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.ext.proxy.EntityContainerFactory;
 import org.apache.olingo.ext.proxy.api.annotations.EntityType;
@@ -37,7 +37,6 @@ import org.apache.olingo.fit.proxy.v3.opentype.microsoft.test.odata.services.ope
 import org.apache.olingo.fit.proxy.v3.opentype.microsoft.test.odata.services.opentypesservicev3.types.Row;
 import org.apache.olingo.fit.proxy.v3.opentype.microsoft.test.odata.services.opentypesservicev3.types.RowIndex;
 import org.junit.BeforeClass;
-
 import org.junit.Test;
 
 /**
@@ -49,8 +48,10 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
 
   @BeforeClass
   public static void initContainer() {
-    final EntityContainerFactory otcontainerFactory = EntityContainerFactory.getV3(testOpenTypeServiceRootURL);
-    otcontainerFactory.getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
+    final EntityContainerFactory<EdmEnabledODataClient> otcontainerFactory = 
+            EntityContainerFactory.getV3(testOpenTypeServiceRootURL);
+    otcontainerFactory.getClient().getConfiguration().
+            setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
     otcontainer = otcontainerFactory.getEntityContainer(DefaultContainer.class);
     assertNotNull(otcontainer);
   }
@@ -93,7 +94,7 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
 
     Calendar cal = Calendar.getInstance();
     cal.clear();
-    cal.setTime(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX").parse("2001-04-05T05:05:05.001+00:01"));
+    cal.setTime(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").parse("2001-04-05T05:05:05.001"));
 
     contact.setLastContacted(cal);
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/fit/src/test/java/org/apache/olingo/fit/proxy/v3/PrimitiveKeysTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/PrimitiveKeysTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/PrimitiveKeysTestITCase.java
index a99a583..f0a4912 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/PrimitiveKeysTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/PrimitiveKeysTestITCase.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertEquals;
 
 import java.math.BigDecimal;
 import java.util.UUID;
+import org.apache.olingo.client.api.v3.EdmEnabledODataClient;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.ext.proxy.EntityContainerFactory;
 import org.apache.olingo.fit.proxy.v3.primitivekeys.microsoft.test.odata.services.primitivekeysservice.TestContext;
@@ -45,8 +46,10 @@ public class PrimitiveKeysTestITCase extends AbstractTestITCase {
 
   @Test
   public void readPrimitiveKeys() {
-    final EntityContainerFactory testContainerFactory = EntityContainerFactory.getV3(testPrimitiveKeysServiceRootURL);
-    testContainerFactory.getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
+    final EntityContainerFactory<EdmEnabledODataClient> testContainerFactory = 
+            EntityContainerFactory.getV3(testPrimitiveKeysServiceRootURL);
+    testContainerFactory.getClient().getConfiguration().
+            setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
     final TestContext testContainer = testContainerFactory.getEntityContainer(TestContext.class);
     assertNotNull(testContainer);
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AbstractTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AbstractTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AbstractTestITCase.java
index f6be6c9..baa4128 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AbstractTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AbstractTestITCase.java
@@ -27,6 +27,7 @@ import java.math.BigDecimal;
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.TimeZone;
+import org.apache.olingo.client.api.v4.EdmEnabledODataClient;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.ext.proxy.EntityContainerFactory;
 import org.apache.olingo.ext.proxy.context.EntityContext;
@@ -60,7 +61,7 @@ public abstract class AbstractTestITCase {
 
   protected final EntityContext entityContext = EntityContainerFactory.getContext().entityContext();
 
-  protected static EntityContainerFactory containerFactory;
+  protected static EntityContainerFactory<EdmEnabledODataClient> containerFactory;
 
   protected static InMemoryEntities container;
 
@@ -74,7 +75,7 @@ public abstract class AbstractTestITCase {
     testAuthServiceRootURL = "http://localhost:9080/stub/DefaultService.svc";
 
     containerFactory = EntityContainerFactory.getV4(testStaticServiceRootURL);
-    containerFactory.getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
+    containerFactory.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
     container = containerFactory.getEntityContainer(InMemoryEntities.class);
     assertNotNull(container);
     EntityContainerFactory.getContext().detachAll();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AsyncTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AsyncTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AsyncTestITCase.java
index f5f4561..b0cbbdd 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AsyncTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AsyncTestITCase.java
@@ -37,7 +37,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
   @Test
   public void retrieveEntitySet() throws InterruptedException, ExecutionException {
     final Future<CustomerCollection> futureCustomers =
-            new AsyncCall<CustomerCollection>(containerFactory.getConfiguration()) {
+            new AsyncCall<CustomerCollection>(containerFactory.getClient().getConfiguration()) {
 
               @Override
               public CustomerCollection call() {
@@ -65,7 +65,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
     Person person = container.getPeople().get(1);
     person.setFirstName(randomFirstName);
 
-    final Future<Void> futureFlush = new AsyncCall<Void>(containerFactory.getConfiguration()) {
+    final Future<Void> futureFlush = new AsyncCall<Void>(containerFactory.getClient().getConfiguration()) {
 
       @Override
       public Void call() {
@@ -79,7 +79,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
       Thread.sleep(1000L);
     }
 
-    final Future<Person> futureProd = new AsyncCall<Person>(containerFactory.getConfiguration()) {
+    final Future<Person> futureProd = new AsyncCall<Person>(containerFactory.getClient().getConfiguration()) {
 
       @Override
       public Person call() {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AuthEntityRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AuthEntityRetrieveTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AuthEntityRetrieveTestITCase.java
index bafddad..afe4d00 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AuthEntityRetrieveTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AuthEntityRetrieveTestITCase.java
@@ -18,30 +18,25 @@
  */
 package org.apache.olingo.fit.proxy.v4;
 
-import static org.junit.Assert.assertNotNull;
+import static org.apache.olingo.fit.proxy.v4.AbstractTestITCase.testKeyAsSegmentServiceRootURL;
 
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.apache.olingo.client.api.v4.EdmEnabledODataClient;
 
 import org.apache.olingo.client.core.http.BasicAuthHttpClientFactory;
+import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.ext.proxy.EntityContainerFactory;
 import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities;
 
 public class AuthEntityRetrieveTestITCase extends EntityRetrieveTestITCase {
 
-  @BeforeClass
-  public static void setupContaner() {
-    containerFactory = EntityContainerFactory.getV3(testAuthServiceRootURL);
-    containerFactory.getConfiguration().
+  @Override
+  protected InMemoryEntities getContainer() {
+    final EntityContainerFactory<EdmEnabledODataClient> ecf =
+            EntityContainerFactory.getV4(testKeyAsSegmentServiceRootURL);
+    ecf.getClient().getConfiguration().setKeyAsSegment(true);
+    ecf.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
+    ecf.getClient().getConfiguration().
             setHttpClientFactory(new BasicAuthHttpClientFactory("odatajclient", "odatajclient"));
-    container = containerFactory.getEntityContainer(InMemoryEntities.class);
-    assertNotNull(container);
-  }
-
-  @AfterClass
-  public static void disableBasicAuth() {
-    containerFactory = EntityContainerFactory.getV3(testStaticServiceRootURL);
-    container = containerFactory.getEntityContainer(InMemoryEntities.class);
-    assertNotNull(container);
+    return ecf.getEntityContainer(InMemoryEntities.class);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntityRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntityRetrieveTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntityRetrieveTestITCase.java
index efad794..ee5b049 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntityRetrieveTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntityRetrieveTestITCase.java
@@ -29,6 +29,7 @@ import java.util.Calendar;
 import java.util.TimeZone;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.ext.proxy.commons.EntityTypeInvocationHandler;
+import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities;
 import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccessLevel;
 import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address;
 import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Company;
@@ -53,10 +54,14 @@ import org.junit.Test;
  */
 public class EntityRetrieveTestITCase extends AbstractTestITCase {
 
+  protected InMemoryEntities getContainer() {
+    return container;
+  }
+
   @Test
   public void exists() {
-    assertTrue(container.getCustomers().exists(1));
-    assertFalse(container.getOrders().exists(1));
+    assertTrue(getContainer().getCustomers().exists(1));
+    assertFalse(getContainer().getOrders().exists(1));
   }
 
   @Test
@@ -66,21 +71,21 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
 
   @Test
   public void getAll() {
-    final PersonCollection all = container.getPeople().getAll();
+    final PersonCollection all = getContainer().getPeople().getAll();
     assertNotNull(all);
     assertFalse(all.isEmpty());
     for (Person person : all) {
       assertNotNull(person);
     }
 
-    final EmployeeCollection employees = container.getPeople().getAll(EmployeeCollection.class);
+    final EmployeeCollection employees = getContainer().getPeople().getAll(EmployeeCollection.class);
     assertNotNull(employees);
     assertFalse(employees.isEmpty());
     for (Employee employee : employees) {
       assertNotNull(employee);
     }
 
-    final CustomerCollection customers = container.getPeople().getAll(CustomerCollection.class);
+    final CustomerCollection customers = getContainer().getPeople().getAll(CustomerCollection.class);
     assertNotNull(customers);
     assertFalse(customers.isEmpty());
     for (Customer customer : customers) {
@@ -92,7 +97,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
 
   @Test
   public void navigate() {
-    final Order order = container.getOrders().get(8);
+    final Order order = getContainer().getOrders().get(8);
     assertNotNull(order);
     assertEquals(8, order.getOrderID(), 0);
 
@@ -103,7 +108,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
     actual.set(2011, 2, 4, 16, 3, 57);
     assertEquals(actual.getTimeInMillis(), date.getTimeInMillis());
 
-    final Customer customer = container.getCustomers().get(1);
+    final Customer customer = getContainer().getCustomers().get(1);
     assertNotNull(customer);
     assertEquals(1, customer.getPersonID(), 0);
     final Address address = customer.getHomeAddress();
@@ -128,7 +133,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
 
   @Test
   public void withActions() {
-    final Product product = container.getProducts().get(5);
+    final Product product = getContainer().getProducts().get(5);
     assertEquals(5, product.getProductID(), 0);
 
     try {
@@ -144,7 +149,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
     orderDetailKey.setOrderID(7);
     orderDetailKey.setProductID(5);
 
-    final OrderDetail orderDetail = container.getOrderDetails().get(orderDetailKey);
+    final OrderDetail orderDetail = getContainer().getOrderDetails().get(orderDetailKey);
     assertNotNull(orderDetail);
     assertEquals(7, orderDetail.getOrderID(), 0);
     assertEquals(5, orderDetail.getProductID(), 0);
@@ -152,7 +157,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
 
   @Test
   public void checkForETag() {
-    final Order order = container.getOrders().get(8);
+    final Order order = getContainer().getOrders().get(8);
     assertTrue(StringUtils.isNotBlank(((EntityTypeInvocationHandler) Proxy.getInvocationHandler(order)).getETag()));
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/fit/src/test/java/org/apache/olingo/fit/proxy/v4/FilterTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/FilterTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/FilterTestITCase.java
new file mode 100644
index 0000000..3eb135f
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/FilterTestITCase.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.fit.proxy.v4;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.apache.olingo.ext.proxy.api.Filter;
+import org.apache.olingo.ext.proxy.api.Search;
+import org.apache.olingo.ext.proxy.api.Sort;
+import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person;
+import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.
+        PersonCollection;
+import org.junit.Test;
+
+public class FilterTestITCase extends AbstractTestITCase {
+
+  @Test
+  public void filterOrderby() {
+    final Filter<Person, PersonCollection> filter = container.getPeople().createFilter().setFilter(
+            containerFactory.getClient().getFilterFactory().lt("PersonID", 3));
+
+    // 1. check that result looks as expected
+    PersonCollection result = filter.getResult();
+    assertEquals(2, result.size());
+
+    // 2. extract PersonID values - sorted ASC by default
+    final List<Integer> former = new ArrayList<Integer>(2);
+    for (Person person : result) {
+      final Integer personID = person.getPersonID();
+      assertTrue(personID < 3);
+      former.add(personID);
+    }
+
+    // 3. add orderby clause to filter above
+    result = filter.setOrderBy(new Sort("PersonID", Sort.Direction.DESC)).getResult();
+    assertEquals(2, result.size());
+
+    // 4. extract again VIN value - now they were required to be sorted DESC
+    final List<Integer> latter = new ArrayList<Integer>(2);
+    for (Person person : result) {
+      final Integer personID = person.getPersonID();
+      assertTrue(personID < 3);
+      latter.add(personID);
+    }
+
+    // 5. reverse latter and expect to be equal to former
+    Collections.reverse(latter);
+    assertEquals(former, latter);
+  }
+
+  @Test
+  public void search() {
+    final Search<Person, PersonCollection> search = container.getPeople().createSearch().setSearch(
+            containerFactory.getClient().getSearchFactory().or(
+                    containerFactory.getClient().getSearchFactory().literal("Bob"),
+                    containerFactory.getClient().getSearchFactory().literal("Jill")));
+
+    final PersonCollection result = search.getResult();
+    assertFalse(result.isEmpty());
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e854f416/fit/src/test/java/org/apache/olingo/fit/proxy/v4/KeyAsSegmentTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/KeyAsSegmentTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/KeyAsSegmentTestITCase.java
index 817d271..a992133 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/KeyAsSegmentTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/KeyAsSegmentTestITCase.java
@@ -21,6 +21,7 @@ package org.apache.olingo.fit.proxy.v4;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
+import org.apache.olingo.client.api.v4.EdmEnabledODataClient;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.ext.proxy.EntityContainerFactory;
 import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities;
@@ -30,9 +31,10 @@ import org.junit.Test;
 public class KeyAsSegmentTestITCase extends AbstractTestITCase {
 
   private InMemoryEntities getContainer() {
-    final EntityContainerFactory ecf = EntityContainerFactory.getV3(testKeyAsSegmentServiceRootURL);
-    ecf.getConfiguration().setKeyAsSegment(true);
-    ecf.getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
+    final EntityContainerFactory<EdmEnabledODataClient> ecf = 
+            EntityContainerFactory.getV4(testKeyAsSegmentServiceRootURL);
+    ecf.getClient().getConfiguration().setKeyAsSegment(true);
+    ecf.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
     return ecf.getEntityContainer(InMemoryEntities.class);
   }