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

[02/14] [OLINGO-266] refactor ref - tecsvc

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6d344e2c/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java
new file mode 100644
index 0000000..fde13c8
--- /dev/null
+++ b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java
@@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.core.uri.testutil;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import org.apache.olingo.commons.api.ODataApplicationException;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmType;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.server.api.uri.UriInfoKind;
+import org.apache.olingo.server.api.uri.queryoption.ExpandItem;
+import org.apache.olingo.server.api.uri.queryoption.SelectItem;
+import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException;
+import org.apache.olingo.server.core.uri.UriInfoImpl;
+import org.apache.olingo.server.core.uri.queryoption.ExpandOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.FilterOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.OrderByOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.QueryOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.SelectOptionImpl;
+
+public class ExpandValidator implements TestValidator {
+  private Edm edm;
+  private TestValidator invokedByValidator;
+
+  private int expandItemIndex;
+  private ExpandOptionImpl expandOption;
+  private ExpandItem expandItem;
+
+  // --- Setup ---
+
+  public ExpandValidator setUpValidator(final TestValidator validator) {
+    invokedByValidator = validator;
+    return this;
+  }
+
+  public ExpandValidator setExpand(final ExpandOptionImpl expand) {
+    expandOption = expand;
+    first();
+    return this;
+  }
+
+  public ExpandValidator setEdm(final Edm edm) {
+    this.edm = edm;
+    return this;
+  }
+
+  // --- Navigation ---
+
+  public ExpandValidator goUpToExpandValidator() {
+    return (ExpandValidator) invokedByValidator;
+  }
+
+  public ResourceValidator goUpToUriResourceValidator() {
+    return (ResourceValidator) invokedByValidator;
+  }
+
+  public ResourceValidator goPath() {
+    UriInfoImpl uriInfo = (UriInfoImpl) expandItem.getResourcePath();
+
+    if (uriInfo.getKind() != UriInfoKind.resource) {
+      fail("goPath() can only be used on UriInfoKind.resource");
+    }
+
+    return new ResourceValidator()
+        .setUpValidator(this)
+        .setEdm(edm)
+        .setUriInfoImplPath(uriInfo);
+
+  }
+
+  public FilterValidator goOrder(final int index) {
+    OrderByOptionImpl orderBy = (OrderByOptionImpl) expandItem.getOrderByOption();
+
+    return new FilterValidator()
+        .setValidator(this)
+        .setEdm(edm)
+        .setExpression(orderBy.getOrders().get(index).getExpression());
+  }
+
+  public ResourceValidator goSelectItem(final int index) {
+    SelectOptionImpl select = (SelectOptionImpl) expandItem.getSelectOption();
+
+    SelectItem item = select.getSelectItems().get(index);
+    UriInfoImpl uriInfo = (UriInfoImpl) item.getResourcePath();
+
+    return new ResourceValidator()
+        .setUpValidator(this)
+        .setEdm(edm)
+        .setUriInfoImplPath(uriInfo);
+
+  }
+
+  public ExpandValidator goExpand() {
+    ExpandValidator val = new ExpandValidator()
+        .setExpand((ExpandOptionImpl) expandItem.getExpandOption())
+        .setUpValidator(this);
+    return val;
+  }
+
+  public ExpandValidator first() {
+    expandItemIndex = 0;
+    expandItem = expandOption.getExpandItems().get(expandItemIndex);
+    return this;
+  }
+
+  public ExpandValidator next() {
+    expandItemIndex++;
+
+    try {
+      expandItem = expandOption.getExpandItems().get(expandItemIndex);
+    } catch (IndexOutOfBoundsException ex) {
+      fail("not enought segments");
+    }
+    return this;
+
+  }
+
+  public ExpandValidator isSegmentStar(final int index) {
+    assertEquals(true, expandItem.isStar());
+    return this;
+  }
+
+  public ExpandValidator isSegmentRef(final int index) {
+    assertEquals(true, expandItem.isRef());
+    return this;
+  }
+
+  public ExpandValidator isLevelText(final String text) {
+    QueryOptionImpl option = (QueryOptionImpl) expandItem.getLevelsOption();
+    assertEquals(text, option.getText());
+    return this;
+  }
+
+  public ExpandValidator isSkipText(final String text) {
+    QueryOptionImpl option = (QueryOptionImpl) expandItem.getSkipOption();
+    assertEquals(text, option.getText());
+    return this;
+  }
+
+  public ExpandValidator isTopText(final String text) {
+    QueryOptionImpl option = (QueryOptionImpl) expandItem.getTopOption();
+    assertEquals(text, option.getText());
+    return this;
+  }
+
+  public ExpandValidator isInlineCountText(final String text) {
+    QueryOptionImpl option = (QueryOptionImpl) expandItem.getCountOption();
+    assertEquals(text, option.getText());
+    return this;
+  }
+
+  public ExpandValidator isSelectText(final String text) {
+    QueryOptionImpl option = (QueryOptionImpl) expandItem.getSelectOption();
+    assertEquals(text, option.getText());
+    return this;
+  }
+
+  public ExpandValidator isSelectItemStar(final int index) {
+    SelectOptionImpl select = (SelectOptionImpl) expandItem.getSelectOption();
+
+    SelectItem item = select.getSelectItems().get(index);
+    assertEquals(true, item.isStar());
+    return this;
+  }
+
+  public ExpandValidator isSelectItemAllOperations(final int index, final FullQualifiedName fqn) {
+    SelectOptionImpl select = (SelectOptionImpl) expandItem.getSelectOption();
+
+    SelectItem item = select.getSelectItems().get(index);
+    assertEquals(fqn.toString(), item.getAllOperationsInSchemaNameSpace().toString());
+    return this;
+  }
+
+  public ExpandValidator isFilterOptionText(final String text) {
+    QueryOptionImpl option = (QueryOptionImpl) expandItem.getFilterOption();
+    assertEquals(text, option.getText());
+    return this;
+  }
+
+  public ExpandValidator isFilterSerialized(final String serialized) {
+    FilterOptionImpl filter = (FilterOptionImpl) expandItem.getFilterOption();
+
+    try {
+      String tmp = FilterTreeToText.Serialize(filter);
+      assertEquals(serialized, tmp);
+    } catch (ExpressionVisitException e) {
+      fail("Exception occured while converting the filterTree into text" + "\n"
+          + " Exception: " + e.getMessage());
+    } catch (ODataApplicationException e) {
+      fail("Exception occured while converting the filterTree into text" + "\n"
+          + " Exception: " + e.getMessage());
+    }
+
+    return this;
+  }
+
+  public ExpandValidator isSortOrder(final int index, final boolean descending) {
+    OrderByOptionImpl orderBy = (OrderByOptionImpl) expandItem.getOrderByOption();
+    assertEquals(descending, orderBy.getOrders().get(index).isDescending());
+    return this;
+  }
+
+  public ExpandValidator isExpandStartType(final FullQualifiedName fullName) {
+    EdmType actualType = expandItem.getStartTypeFilter();
+
+    FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
+    assertEquals(fullName, actualName);
+    return this;
+
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6d344e2c/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java
new file mode 100644
index 0000000..06056e0
--- /dev/null
+++ b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.core.uri.testutil;
+
+import java.util.List;
+
+import org.apache.olingo.commons.api.ODataApplicationException;
+import org.apache.olingo.commons.api.edm.EdmEnumType;
+import org.apache.olingo.commons.api.edm.EdmType;
+import org.apache.olingo.server.api.uri.UriInfoResource;
+import org.apache.olingo.server.api.uri.UriResource;
+import org.apache.olingo.server.api.uri.UriResourceLambdaAll;
+import org.apache.olingo.server.api.uri.UriResourceLambdaAny;
+import org.apache.olingo.server.api.uri.UriResourcePartTyped;
+import org.apache.olingo.server.api.uri.queryoption.FilterOption;
+import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind;
+import org.apache.olingo.server.api.uri.queryoption.expression.Expression;
+import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException;
+import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitor;
+import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
+import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind;
+
+public class FilterTreeToText implements ExpressionVisitor<String> {
+
+  public static String Serialize(final FilterOption filter)
+      throws ExpressionVisitException, ODataApplicationException {
+
+    Expression expression = filter.getExpression();
+    return expression.accept(new FilterTreeToText());
+  }
+
+  public static String Serialize(final Expression expression)
+      throws ExpressionVisitException, ODataApplicationException {
+
+    return expression.accept(new FilterTreeToText());
+  }
+
+  @Override
+  public String visitBinaryOperator(final BinaryOperatorKind operator, final String left, final String right)
+      throws ExpressionVisitException {
+
+    return "<" + left + " " + operator.toString() + " " + right + ">";
+  }
+
+  @Override
+  public String visitUnaryOperator(final UnaryOperatorKind operator, final String operand)
+      throws ExpressionVisitException {
+
+    return "<" + operator + " " + operand.toString() + ">";
+  }
+
+  @Override
+  public String visitMethodCall(final MethodKind methodCall, final List<String> parameters)
+      throws ExpressionVisitException {
+
+    String text = "<" + methodCall + "(";
+    int i = 0;
+    while (i < parameters.size()) {
+      if (i > 0) {
+        text += ",";
+      }
+      text += parameters.get(i);
+      i++;
+    }
+    return text + ")>";
+  }
+
+  @Override
+  public String visitLiteral(final String literal) throws ExpressionVisitException {
+    return "<" + literal + ">";
+  }
+
+  @Override
+  public String visitMember(final UriInfoResource resource) throws ExpressionVisitException, ODataApplicationException {
+    String ret = "";
+
+    UriInfoResource path = resource;
+
+    for (UriResource item : path.getUriResourceParts()) {
+      String tmp = "";
+      if (item instanceof UriResourceLambdaAll) {
+        UriResourceLambdaAll all = (UriResourceLambdaAll) item;
+        tmp = visitLambdaExpression("ALL", all.getLambdaVariable(), all.getExpression());
+      } else if (item instanceof UriResourceLambdaAny) {
+        UriResourceLambdaAny any = (UriResourceLambdaAny) item;
+        tmp = visitLambdaExpression("ANY", any.getLamdaVariable(), any.getExpression());
+      } else if (item instanceof UriResourcePartTyped) {
+        UriResourcePartTyped typed = (UriResourcePartTyped) item;
+        tmp = typed.toString(true);
+      }
+
+      if (ret.length() != 0) {
+        ret += "/";
+      }
+      ret += tmp;
+
+    }
+    return "<" + ret + ">";
+  }
+
+  @Override
+  public String visitAlias(final String referenceName) throws ExpressionVisitException {
+    return "<" + referenceName + ">";
+  }
+
+  @Override
+  public String visitLambdaExpression(final String functionText, final String string, final Expression expression)
+      throws ExpressionVisitException, ODataApplicationException {
+
+    return "<" + functionText + ";" + ((expression == null) ? "" : expression.accept(this)) + ">";
+  }
+
+  @Override
+  public String visitTypeLiteral(final EdmType type) {
+    return "<" + type.getNamespace() + "." + type.getName() + ">";
+  }
+
+  @Override
+  public String visitLambdaReference(final String variableText) {
+    return "<" + variableText + ">";
+  }
+
+  @Override
+  public String visitEnum(final EdmEnumType type, final List<String> enumValues)
+      throws ExpressionVisitException, ODataApplicationException {
+    String tmp = "";
+
+    for (String item : enumValues) {
+      if (tmp.length() > 0) {
+        tmp += ",";
+      }
+      tmp += item;
+    }
+
+    return "<" + type.getNamespace() + "." + type.getName() + "<" + tmp + ">>";
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6d344e2c/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java
new file mode 100644
index 0000000..58e429f
--- /dev/null
+++ b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java
@@ -0,0 +1,534 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.core.uri.testutil;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.List;
+
+import org.apache.olingo.commons.api.ODataApplicationException;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmType;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.server.api.uri.UriInfo;
+import org.apache.olingo.server.api.uri.UriInfoKind;
+import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind;
+import org.apache.olingo.server.api.uri.queryoption.expression.Expression;
+import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException;
+import org.apache.olingo.server.api.uri.queryoption.expression.Member;
+import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
+import org.apache.olingo.server.core.uri.UriInfoImpl;
+import org.apache.olingo.server.core.uri.parser.Parser;
+import org.apache.olingo.server.core.uri.parser.UriParserException;
+import org.apache.olingo.server.core.uri.parser.UriParserSemanticException;
+import org.apache.olingo.server.core.uri.parser.UriParserSyntaxException;
+import org.apache.olingo.server.core.uri.queryoption.FilterOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.OrderByOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.expression.BinaryImpl;
+import org.apache.olingo.server.core.uri.queryoption.expression.EnumerationImpl;
+import org.apache.olingo.server.core.uri.queryoption.expression.LiteralImpl;
+import org.apache.olingo.server.core.uri.queryoption.expression.MemberImpl;
+import org.apache.olingo.server.core.uri.queryoption.expression.MethodImpl;
+import org.apache.olingo.server.core.uri.queryoption.expression.TypeLiteralImpl;
+
+public class FilterValidator implements TestValidator {
+  private Edm edm;
+
+  private TestValidator invokedByValidator;
+  private FilterOptionImpl filter;
+
+  private Expression curExpression;
+  private Expression rootExpression;
+
+  private OrderByOptionImpl orderBy;
+
+  private UriParserException exception;
+
+  // --- Setup ---
+  public FilterValidator setUriResourcePathValidator(final ResourceValidator uriResourcePathValidator) {
+    invokedByValidator = uriResourcePathValidator;
+    return this;
+  }
+
+  public FilterValidator setUriValidator(final TestUriValidator uriValidator) {
+    invokedByValidator = uriValidator;
+    return this;
+  }
+
+  public FilterValidator setValidator(final TestValidator uriValidator) {
+    invokedByValidator = uriValidator;
+    return this;
+  }
+
+  public FilterValidator setEdm(final Edm edm) {
+    this.edm = edm;
+    return this;
+  }
+
+  public FilterValidator setFilter(final FilterOptionImpl filter) {
+    this.filter = filter;
+
+    if (filter.getExpression() == null) {
+      fail("FilterValidator: no filter found");
+    }
+    setExpression(filter.getExpression());
+    return this;
+  }
+
+  public FilterValidator setOrderBy(final OrderByOptionImpl orderBy) {
+    this.orderBy = orderBy;
+
+    return this;
+  }
+
+  public FilterValidator setExpression(final Expression expression) {
+    rootExpression = curExpression = expression;
+    return this;
+  }
+
+  // --- Execution ---
+
+  public FilterValidator runOrderByOnETAllPrim(final String orderBy) throws UriParserException {
+    String uri = "ESAllPrim?$orderby=" + orderBy.trim();
+    return runUriOrderBy(uri);
+  }
+
+  public FilterValidator runOrderByOnETTwoKeyNav(final String orderBy) throws UriParserException {
+    String uri = "ESTwoKeyNav?$orderby=" + orderBy.trim();
+    return runUriOrderBy(uri);
+  }
+
+  public FilterValidator runOrderByOnETTwoKeyNavEx(final String orderBy) throws UriParserException {
+    String uri = "ESTwoKeyNav?$orderby=" + orderBy.trim();
+    return runUriOrderByEx(uri);
+  }
+
+  public FilterValidator runOnETTwoKeyNav(final String filter) throws UriParserException {
+    String uri = "ESTwoKeyNav?$filter=" + filter.trim();
+    return runUri(uri);
+  }
+
+  public FilterValidator runOnETTwoKeyNavSingle(final String filter) throws UriParserException {
+    String uri = "SINav?$filter=" + filter.trim();
+    return runUri(uri);
+  }
+
+  public FilterValidator runOnETTwoKeyNavEx(final String filter) throws UriParserException {
+    String uri = "ESTwoKeyNav?$filter=" + filter.trim();
+    return runUriEx(uri);
+  }
+
+  public FilterValidator runOnETAllPrim(final String filter) throws UriParserException {
+    String uri = "ESAllPrim(1)?$filter=" + filter.trim();
+    return runUri(uri);
+  }
+
+  public FilterValidator runOnETKeyNav(final String filter) throws UriParserException {
+    String uri = "ESKeyNav(1)?$filter=" + filter.trim();
+    return runUri(uri);
+  }
+
+  public FilterValidator runOnETKeyNavEx(final String filter) throws UriParserException {
+    String uri = "ESKeyNav(1)?$filter=" + filter.trim();
+    return runUriEx(uri);
+  }
+
+  public FilterValidator runOnCTTwoPrim(final String filter) throws UriParserException {
+    String uri = "SINav/PropertyComplexTwoPrim?$filter=" + filter.trim();
+    return runUri(uri);
+  }
+
+  public FilterValidator runOnString(final String filter) throws UriParserException {
+    String uri = "SINav/PropertyString?$filter=" + filter.trim();
+    return runUri(uri);
+  }
+
+  public FilterValidator runOnInt32(final String filter) throws UriParserException {
+    String uri = "ESCollAllPrim(1)/CollPropertyInt32?$filter=" + filter.trim();
+    return runUri(uri);
+  }
+
+  public FilterValidator runOnDateTimeOffset(final String filter) throws UriParserException {
+    String uri = "ESCollAllPrim(1)/CollPropertyDateTimeOffset?$filter=" + filter.trim();
+    return runUri(uri);
+  }
+
+  public FilterValidator runOnDuration(final String filter) throws UriParserException {
+    String uri = "ESCollAllPrim(1)/CollPropertyDuration?$filter=" + filter.trim();
+    return runUri(uri);
+  }
+
+  public FilterValidator runOnTimeOfDay(final String filter) throws UriParserException {
+    String uri = "ESCollAllPrim(1)/CollPropertyTimeOfDay?$filter=" + filter.trim();
+    return runUri(uri);
+  }
+
+  public FilterValidator runESabc(final String filter) throws UriParserException {
+    String uri = "ESabc?$filter=" + filter.trim();
+    return runUri(uri);
+  }
+
+  public FilterValidator runUri(final String uri) throws UriParserException {
+    Parser parser = new Parser();
+    UriInfo uriInfo = null;
+
+    uriInfo = parser.parseUri(uri, edm);
+
+    if (uriInfo.getKind() != UriInfoKind.resource) {
+      fail("Filtervalidator can only be used on resourcePaths");
+    }
+
+    setFilter((FilterOptionImpl) uriInfo.getFilterOption());
+    curExpression = filter.getExpression();
+    return this;
+  }
+
+  public FilterValidator runUriEx(final String uri) {
+    Parser parser = new Parser();
+    UriInfo uriInfo = null;
+
+    try {
+      uriInfo = parser.parseUri(uri, edm);
+    } catch (UriParserException e) {
+      exception = e;
+      return this;
+    }
+
+    if (uriInfo.getKind() != UriInfoKind.resource) {
+      fail("Filtervalidator can only be used on resourcePaths");
+    }
+
+    setFilter((FilterOptionImpl) uriInfo.getFilterOption());
+    curExpression = filter.getExpression();
+    return this;
+  }
+
+  public FilterValidator runUriOrderBy(final String uri) throws UriParserException {
+    Parser parser = new Parser();
+    UriInfo uriInfo = null;
+
+    uriInfo = parser.parseUri(uri, edm);
+
+    if (uriInfo.getKind() != UriInfoKind.resource) {
+      fail("Filtervalidator can only be used on resourcePaths");
+    }
+
+    setOrderBy((OrderByOptionImpl) uriInfo.getOrderByOption());
+    return this;
+  }
+
+  public FilterValidator runUriOrderByEx(final String uri) {
+    Parser parser = new Parser();
+    UriInfo uriInfo = null;
+
+    try {
+      uriInfo = parser.parseUri(uri, edm);
+    } catch (UriParserException e) {
+      exception = e;
+      return this;
+    }
+
+    if (uriInfo.getKind() != UriInfoKind.resource) {
+      fail("Filtervalidator can only be used on resourcePaths");
+    }
+
+    setOrderBy((OrderByOptionImpl) uriInfo.getOrderByOption());
+    return this;
+  }
+
+  // --- Navigation ---
+
+  public ExpandValidator goUpToExpandValidator() {
+    return (ExpandValidator) invokedByValidator;
+  }
+
+  public ResourceValidator goUpToResourceValidator() {
+    return (ResourceValidator) invokedByValidator;
+  }
+
+  public ResourceValidator goPath() {
+    if (!(curExpression instanceof MemberImpl)) {
+      fail("Current expression not a member");
+    }
+
+    MemberImpl member = (MemberImpl) curExpression;
+
+    return new ResourceValidator()
+        .setEdm(edm)
+        .setUriInfoImplPath((UriInfoImpl) member.getResourcePath())
+        .setUpValidator(this);
+
+  }
+
+  public FilterValidator goParameter(final int parameterIndex) {
+    if (curExpression instanceof MethodImpl) {
+      MethodImpl methodCall = (MethodImpl) curExpression;
+      curExpression = methodCall.getParameters().get(parameterIndex);
+    } else {
+      fail("Current expression not a methodCall");
+    }
+    return this;
+  }
+
+  // --- Validation ---
+
+  /**
+   * Validates the serialized filterTree against a given filterString
+   * The given expected filterString is compressed before to allow better readable code in the unit tests
+   * @param toBeCompr
+   * @return
+   */
+  public FilterValidator isCompr(final String toBeCompr) {
+    return is(compress(toBeCompr));
+  }
+
+  public FilterValidator is(final String expectedFilterAsString) {
+    try {
+      String actualFilterAsText = FilterTreeToText.Serialize((FilterOptionImpl) filter);
+      assertEquals(expectedFilterAsString, actualFilterAsText);
+    } catch (ExpressionVisitException e) {
+      fail("Exception occured while converting the filterTree into text" + "\n"
+          + " Exception: " + e.getMessage());
+    } catch (ODataApplicationException e) {
+      fail("Exception occured while converting the filterTree into text" + "\n"
+          + " Exception: " + e.getMessage());
+    }
+
+    return this;
+  }
+
+  // --- Helper ---
+
+  private String compress(final String expected) {
+    String ret = expected.replaceAll("\\s+", " ");
+    ret = ret.replaceAll("< ", "<");
+    ret = ret.replaceAll(" >", ">");
+    return ret;
+  }
+
+  public FilterValidator isType(final FullQualifiedName fullName) {
+    EdmType actualType = null;
+
+    if (curExpression instanceof MemberImpl) {
+      Member member = (Member) curExpression;
+      actualType = member.getType();
+    } else if (curExpression instanceof TypeLiteralImpl) {
+      TypeLiteralImpl typeLiteral = (TypeLiteralImpl) curExpression;
+      actualType = typeLiteral.getType();
+    } else if (curExpression instanceof LiteralImpl) {
+      LiteralImpl typeLiteral = (LiteralImpl) curExpression;
+      actualType = typeLiteral.getType();
+    }
+
+    if (actualType == null) {
+      fail("Current expression not typed");
+    }
+
+    FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
+    assertEquals(fullName, actualName);
+    return this;
+  }
+
+  public FilterValidator left() {
+    if (!(curExpression instanceof BinaryImpl)) {
+      fail("Current expression not a binary operator");
+    }
+
+    curExpression = ((BinaryImpl) curExpression).getLeftOperand();
+
+    return this;
+  }
+
+  public FilterValidator root() {
+    if (filter != null) {
+      curExpression = filter.getExpression();
+    } else {
+      curExpression = rootExpression;
+    }
+
+    return this;
+  }
+
+  public FilterValidator right() {
+    if (!(curExpression instanceof BinaryImpl)) {
+      fail("Current expression is not a binary operator");
+    }
+
+    curExpression = ((BinaryImpl) curExpression).getRightOperand();
+
+    return this;
+
+  }
+
+  public FilterValidator isLiteral(final String literalText) {
+    if (!(curExpression instanceof LiteralImpl)) {
+      fail("Current expression is not a literal");
+    }
+
+    String actualLiteralText = ((LiteralImpl) curExpression).getText();
+    assertEquals(literalText, actualLiteralText);
+
+    return this;
+  }
+
+  public FilterValidator isMethod(final MethodKind methodKind, final int parameterCount) {
+    if (!(curExpression instanceof MethodImpl)) {
+      fail("Current expression is not a methodCall");
+    }
+
+    MethodImpl methodCall = (MethodImpl) curExpression;
+    assertEquals(methodKind, methodCall.getMethod());
+    assertEquals(parameterCount, methodCall.getParameters().size());
+
+    return this;
+  }
+
+  public FilterValidator isParameterText(final int parameterIndex, final String parameterText)
+      throws ExpressionVisitException, ODataApplicationException {
+
+    if (!(curExpression instanceof MethodImpl)) {
+      fail("Current expression is not a method");
+    }
+
+    MethodImpl methodCall = (MethodImpl) curExpression;
+
+    Expression parameter = methodCall.getParameters().get(parameterIndex);
+    String actualParameterText = FilterTreeToText.Serialize(parameter);
+    assertEquals(parameterText, actualParameterText);
+
+    return this;
+  }
+
+  public FilterValidator isBinary(final BinaryOperatorKind binaryOperator) {
+    if (!(curExpression instanceof BinaryImpl)) {
+      fail("Current expression is not a binary operator");
+    }
+
+    BinaryImpl binary = (BinaryImpl) curExpression;
+    assertEquals(binaryOperator, binary.getOperator());
+
+    return this;
+  }
+
+  public FilterValidator isTypedLiteral(final FullQualifiedName fullName) {
+    if (!(curExpression instanceof TypeLiteralImpl)) {
+      fail("Current expression not a typeLiteral");
+    }
+
+    isType(fullName);
+
+    return this;
+  }
+
+  public FilterValidator isMember() {
+    if (!(curExpression instanceof MemberImpl)) {
+      fail("Current expression not a member");
+    }
+
+    return this;
+  }
+
+  public FilterValidator isMemberStartType(final FullQualifiedName fullName) {
+    if (!(curExpression instanceof MemberImpl)) {
+      fail("Current expression not a member");
+    }
+
+    MemberImpl member = (MemberImpl) curExpression;
+    EdmType actualType = member.getStartTypeFilter();
+
+    FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
+    assertEquals(fullName, actualName);
+    return this;
+  }
+
+  public FilterValidator isEnum(final FullQualifiedName nameenstring, final List<String> enumValues) {
+    if (!(curExpression instanceof EnumerationImpl)) {
+      fail("Current expression not a enumeration");
+    }
+
+    EnumerationImpl enumeration = (EnumerationImpl) curExpression;
+
+    FullQualifiedName actualName =
+        new FullQualifiedName(enumeration.getType().getNamespace(), enumeration.getType().getName());
+
+    // check name
+    assertEquals(nameenstring.toString(), actualName.toString());
+
+    // check values
+    int i = 0;
+    for (String item : enumValues) {
+      assertEquals(item, enumeration.getValues().get(i));
+      i++;
+    }
+
+    return this;
+  }
+
+  public FilterValidator isSortOrder(final int index, final boolean descending) {
+    assertEquals(descending, orderBy.getOrders().get(index).isDescending());
+    return this;
+  }
+
+  public FilterValidator goOrder(final int index) {
+    curExpression = orderBy.getOrders().get(index).getExpression();
+    return this;
+  }
+
+  public FilterValidator isExSyntax(final long errorID) {
+    assertEquals(UriParserSyntaxException.class, exception.getClass());
+    return this;
+  }
+
+  public FilterValidator isExSemantic(final long errorID) {
+    assertEquals(UriParserSemanticException.class, exception.getClass());
+    return this;
+  }
+
+  public FilterValidator isNull() {
+    if (!(curExpression instanceof LiteralImpl)) {
+      fail("Current expression is not a literal");
+    }
+
+    String actualLiteralText = ((LiteralImpl) curExpression).getText();
+    assertEquals("null", actualLiteralText);
+    return this;
+  }
+
+  public FilterValidator isTrue() {
+    if (!(curExpression instanceof LiteralImpl)) {
+      fail("Current expression is not a literal");
+    }
+
+    String actualLiteralText = ((LiteralImpl) curExpression).getText();
+    assertEquals("true", actualLiteralText);
+    return this;
+  }
+
+  public FilterValidator isFalse() {
+    if (!(curExpression instanceof LiteralImpl)) {
+      fail("Current expression is not a literal");
+    }
+
+    String actualLiteralText = ((LiteralImpl) curExpression).getText();
+    assertEquals("false", actualLiteralText);
+    return this;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6d344e2c/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/ParseTreeToText.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/ParseTreeToText.java b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/ParseTreeToText.java
new file mode 100644
index 0000000..f6a3086
--- /dev/null
+++ b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/ParseTreeToText.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.server.core.uri.testutil;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.antlr.v4.runtime.Token;
+import org.antlr.v4.runtime.misc.NotNull;
+import org.antlr.v4.runtime.misc.Nullable;
+import org.antlr.v4.runtime.misc.Utils;
+import org.antlr.v4.runtime.tree.ErrorNode;
+import org.antlr.v4.runtime.tree.RuleNode;
+import org.antlr.v4.runtime.tree.TerminalNode;
+import org.antlr.v4.runtime.tree.Tree;
+
+public class ParseTreeToText {
+
+  public static String getTreeAsText(final Tree contextTree, final String[] ruleNames) {
+    return toStringTree(contextTree, Arrays.asList(ruleNames));
+  }
+
+  private static String toStringTree(final Tree t, @Nullable final List<String> ruleNames) {
+
+    if (t.getChildCount() == 0) {
+      return Utils.escapeWhitespace(getNodeText(t, ruleNames), false);
+    }
+
+    StringBuilder buf = new StringBuilder();
+    String s = Utils.escapeWhitespace(getNodeText(t, ruleNames), false);
+    buf.append(s);
+    buf.append("(");
+
+    for (int i = 0; i < t.getChildCount(); i++) {
+      if (i > 0) {
+        buf.append(' ');
+      }
+      buf.append(toStringTree(t.getChild(i), ruleNames));
+    }
+    buf.append(")");
+    return buf.toString();
+  }
+
+  private static String getNodeText(@NotNull final Tree t, @Nullable final List<String> ruleNames) {
+    if (ruleNames != null) {
+      if (t instanceof RuleNode) {
+        int ruleIndex = ((RuleNode) t).getRuleContext().getRuleIndex();
+        return ruleNames.get(ruleIndex);
+      } else if (t instanceof ErrorNode) {
+        return t.toString();
+      } else if (t instanceof TerminalNode) {
+        Token symbol = ((TerminalNode) t).getSymbol();
+        if (symbol != null) {
+          String s = symbol.getText();
+          return s;
+        }
+      }
+    }
+    // no recog for rule names
+    Object payload = t.getPayload();
+    if (payload instanceof Token) {
+      return ((Token) payload).getText();
+    }
+    return t.getPayload().toString();
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6d344e2c/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserValidator.java b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserValidator.java
new file mode 100644
index 0000000..3f73b97
--- /dev/null
+++ b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserValidator.java
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.core.uri.testutil;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.antlr.v4.runtime.ParserRuleContext;
+import org.apache.olingo.server.core.uri.antlr.UriParserParser;
+
+public class ParserValidator {
+
+  private String input = null;
+  private ParserRuleContext root;
+
+  int logLevel = 0;
+  private int lexerLogLevel = 0;
+
+  boolean allowFullContext;
+  boolean allowContextSensitifity;
+  boolean allowAmbiguity;
+
+  List<Exception> exceptions = new ArrayList<Exception>();
+  private Exception curException = null;
+
+  // --- Setup ---
+
+  public ParserValidator log(final int logLevel) {
+    this.logLevel = logLevel;
+    return this;
+  }
+
+  public ParserValidator lexerLog(final int logLevel) {
+    lexerLogLevel = logLevel;
+    return this;
+  }
+
+  /**
+   * Used in fast LL Parsing:
+   * Don't stop the parsing process when the slower full context parsing (with prediction mode SLL) is
+   * required
+   * @return
+   */
+  public ParserValidator aFC() {
+    allowFullContext = true;
+    return this;
+  }
+
+  /**
+   * Used in fast LL Parsing:
+   * Allows ContextSensitifity Errors which occur often when using the slower full context parsing
+   * and indicate that there is a context sensitivity ( which may not be an error).
+   * @return
+   */
+  public ParserValidator aCS() {
+    allowContextSensitifity = true;
+    return this;
+  }
+
+  /**
+   * Used in fast LL Parsing:
+   * Allows ambiguities
+   * @return
+   */
+  public ParserValidator aAM() {
+    allowAmbiguity = true;
+    return this;
+  }
+
+  // --- Execution ---
+
+  public ParserValidator run(final String uri) {
+    input = uri;
+
+    // just run a short lexer step. E.g. to print the tokens
+    if (lexerLogLevel > 0) {
+      (new TokenValidator()).log(lexerLogLevel).run(input);
+    }
+
+    /**/// root = parseInput(uri);
+
+    // if LOG > 0 - Write serialized tree
+    if (logLevel > 0) {
+      if (root != null) {
+        System.out.println(ParseTreeToText.getTreeAsText(root, new UriParserParser(null).getRuleNames()));
+      } else {
+        System.out.println("root == null");
+      }
+    }
+
+    // reset for next test
+    allowFullContext = false;
+    allowContextSensitifity = false;
+    allowAmbiguity = false;
+    logLevel = 0;
+
+    return this;
+  }
+
+  // --- Navigation ---
+
+  public ParserValidator exFirst() {
+    try {
+      // curWeakException = exceptions.get(0);
+    } catch (IndexOutOfBoundsException ex) {
+      // curWeakException = null;
+    }
+    return this;
+
+  }
+
+  public ParserValidator exLast() {
+    // curWeakException = exceptions.get(exceptions.size() - 1);
+    return this;
+  }
+
+  public ParserValidator exAt(final int index) {
+    try {
+      // curWeakException = exceptions.get(index);
+    } catch (IndexOutOfBoundsException ex) {
+      // curWeakException = null;
+    }
+    return this;
+  }
+
+  // --- Validation ---
+
+  public ParserValidator isText(final String expected) {
+
+    assertEquals(null, curException);
+    assertEquals(0, exceptions.size());
+
+    String actualTreeAsText = ParseTreeToText.getTreeAsText(root, new UriParserParser(null).getRuleNames());
+
+    assertEquals(expected, actualTreeAsText);
+    return this;
+  }
+
+  public ParserValidator isExeptionType(final Class<?> exClass) {
+    assertEquals(exClass, curException.getClass());
+    return this;
+  }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6d344e2c/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserWithLogging.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserWithLogging.java b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserWithLogging.java
new file mode 100644
index 0000000..524a38a
--- /dev/null
+++ b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserWithLogging.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.core.uri.testutil;
+
+import org.antlr.v4.runtime.DefaultErrorStrategy;
+import org.antlr.v4.runtime.DiagnosticErrorListener;
+import org.apache.olingo.server.core.uri.antlr.UriParserParser;
+import org.apache.olingo.server.core.uri.parser.Parser;
+
+public class ParserWithLogging extends Parser {
+  TestErrorLogger errorCollector1;
+  TestErrorLogger errorCollector2;
+
+  public ParserWithLogging() {
+    errorCollector1 = new TestErrorLogger("Stage 1", 1);
+    errorCollector2 = new TestErrorLogger("Stage 2", 1);
+  }
+
+  @Override
+  protected void addStage2ErrorStategy(final UriParserParser parser) {
+    // Don't throw an at first syntax error, so the error listener will be called
+    parser.setErrorHandler(new DefaultErrorStrategy());
+  }
+
+  @Override
+  protected void addStage1ErrorListener(final UriParserParser parser) {
+    // Log error to console
+    parser.removeErrorListeners();
+    parser.addErrorListener(errorCollector1);
+    parser.addErrorListener(new DiagnosticErrorListener());
+  }
+
+  @Override
+  protected void addStage2ErrorListener(final UriParserParser parser) {
+    // Log error to console
+    parser.removeErrorListeners();
+    parser.addErrorListener(errorCollector2);
+    parser.addErrorListener(new DiagnosticErrorListener());
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6d344e2c/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java
new file mode 100644
index 0000000..143871a
--- /dev/null
+++ b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java
@@ -0,0 +1,599 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.core.uri.testutil;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.util.List;
+
+import org.apache.olingo.commons.api.ODataApplicationException;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmElement;
+import org.apache.olingo.commons.api.edm.EdmType;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.server.api.uri.UriInfo;
+import org.apache.olingo.server.api.uri.UriInfoKind;
+import org.apache.olingo.server.api.uri.UriParameter;
+import org.apache.olingo.server.api.uri.UriResourceKind;
+import org.apache.olingo.server.api.uri.UriResourcePartTyped;
+import org.apache.olingo.server.api.uri.queryoption.CustomQueryOption;
+import org.apache.olingo.server.api.uri.queryoption.SelectItem;
+import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException;
+import org.apache.olingo.server.core.uri.UriInfoImpl;
+import org.apache.olingo.server.core.uri.UriResourceActionImpl;
+import org.apache.olingo.server.core.uri.UriResourceComplexPropertyImpl;
+import org.apache.olingo.server.core.uri.UriResourceEntitySetImpl;
+import org.apache.olingo.server.core.uri.UriResourceFunctionImpl;
+import org.apache.olingo.server.core.uri.UriResourceImpl;
+import org.apache.olingo.server.core.uri.UriResourceLambdaAllImpl;
+import org.apache.olingo.server.core.uri.UriResourceLambdaAnyImpl;
+import org.apache.olingo.server.core.uri.UriResourceNavigationPropertyImpl;
+import org.apache.olingo.server.core.uri.UriResourcePrimitivePropertyImpl;
+import org.apache.olingo.server.core.uri.UriResourceSingletonImpl;
+import org.apache.olingo.server.core.uri.UriResourceWithKeysImpl;
+import org.apache.olingo.server.core.uri.queryoption.CustomQueryOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.ExpandOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.SelectOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.expression.ExpressionImpl;
+import org.apache.olingo.server.core.uri.validator.UriValidator;
+
+public class ResourceValidator implements TestValidator {
+  private Edm edm;
+  private TestValidator invokedBy;
+  private UriInfo uriInfo = null;
+
+  private UriResourceImpl uriPathInfo = null;
+  private int uriResourceIndex;
+
+  // --- Setup ---
+
+  public ResourceValidator setUpValidator(final TestValidator uriValidator) {
+    invokedBy = uriValidator;
+    return this;
+  }
+
+  public ResourceValidator setEdm(final Edm edm) {
+    this.edm = edm;
+    return this;
+  }
+
+  public ResourceValidator setUriInfoImplPath(final UriInfoImpl uriInfoPath) {
+    uriInfo = uriInfoPath;
+    last();
+    return this;
+  }
+
+  // --- Execution ---
+
+  public ResourceValidator run(final String uri) {
+    ParserWithLogging testParser = new ParserWithLogging();
+
+    UriInfoImpl uriInfoTmp = null;
+    uriPathInfo = null;
+    try {
+      uriInfoTmp = (UriInfoImpl) testParser.parseUri(uri, edm);
+      
+      UriValidator uriValidator = new UriValidator();
+      uriValidator.validate(uriInfoTmp, "GET");
+    } catch (Exception e) {
+      fail("Exception occured while parsing the URI: " + uri + "\n"
+          + " Message: " + e.getMessage());
+    }
+
+    if (uriInfoTmp.getKind() != UriInfoKind.resource) {
+      fail("Invalid UriInfoKind: " + uriInfoTmp.getKind().toString());
+    }
+    uriInfo = uriInfoTmp;
+
+    first();
+    return this;
+  }
+
+  // --- Navigation ---
+
+  public TestUriValidator goUpUriValidator() {
+    return (TestUriValidator) invokedBy;
+  }
+
+  public ExpandValidator goUpExpandValidator() {
+    return (ExpandValidator) invokedBy;
+  }
+
+  public FilterValidator goUpFilterValidator() {
+    return (FilterValidator) invokedBy;
+  }
+
+  public FilterValidator goParameter(final int index) {
+    assertEquals(UriResourceKind.function, uriPathInfo.getKind());
+    UriResourceFunctionImpl function = (UriResourceFunctionImpl) uriPathInfo;
+
+    return new FilterValidator()
+        .setEdm(edm)
+        .setExpression(function.getParameters().get(index).getExression())
+        .setValidator(this);
+  }
+
+  public FilterValidator goLambdaExpression() {
+    if (uriPathInfo.getKind() == UriResourceKind.lambdaAll) {
+      return new FilterValidator()
+          .setEdm(edm)
+          .setExpression(((UriResourceLambdaAllImpl) uriPathInfo).getExpression());
+
+    } else if (uriPathInfo.getKind() == UriResourceKind.lambdaAny) {
+      return new FilterValidator()
+          .setEdm(edm)
+          .setExpression(((UriResourceLambdaAnyImpl) uriPathInfo).getExpression());
+    } else {
+      fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+    }
+    return null;
+  }
+
+  public ResourceValidator goSelectItem(final int index) {
+    SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
+
+    SelectItem item = select.getSelectItems().get(index);
+    UriInfoImpl uriInfo1 = (UriInfoImpl) item.getResourcePath();
+
+    return new ResourceValidator()
+        .setUpValidator(this)
+        .setEdm(edm)
+        .setUriInfoImplPath(uriInfo1);
+
+  }
+
+  public ExpandValidator goExpand() {
+    ExpandOptionImpl expand = (ExpandOptionImpl) uriInfo.getExpandOption();
+    if (expand == null) {
+      fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+    }
+
+    return new ExpandValidator().setUpValidator(this).setExpand(expand);
+  }
+
+  public ResourceValidator first() {
+    uriResourceIndex = 0;
+    uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(0);
+    return this;
+  }
+
+  public ResourceValidator last() {
+    uriResourceIndex = 0;
+
+    try {
+      uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(uriInfo.getUriResourceParts().size() - 1);
+      uriResourceIndex = uriInfo.getUriResourceParts().size() - 1;
+    } catch (IndexOutOfBoundsException ex) {
+      fail("not enough segments");
+    }
+
+    return this;
+  }
+
+  public ResourceValidator n() {
+    uriResourceIndex++;
+
+    try {
+      uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(uriResourceIndex);
+    } catch (IndexOutOfBoundsException ex) {
+      fail("not enough segments");
+    }
+
+    return this;
+  }
+
+  public ResourceValidator at(final int index) {
+    uriResourceIndex = index;
+    try {
+      uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(index);
+    } catch (IndexOutOfBoundsException ex) {
+      fail("not enough segments");
+    }
+    return this;
+  }
+
+  // --- Validation ---
+
+  public ResourceValidator isLambdaVar(final String var) {
+    String actualVar = null;
+    if (uriPathInfo.getKind() == UriResourceKind.lambdaAll) {
+      actualVar = ((UriResourceLambdaAllImpl) uriPathInfo).getLambdaVariable();
+    } else if (uriPathInfo.getKind() == UriResourceKind.lambdaAny) {
+      actualVar = ((UriResourceLambdaAnyImpl) uriPathInfo).getLamdaVariable();
+    } else {
+      fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+    }
+
+    assertEquals(var, actualVar);
+    return this;
+  }
+
+  public ResourceValidator isTypeFilter(final FullQualifiedName expectedType) {
+
+    if (uriPathInfo.getKind() != UriResourceKind.complexProperty &&
+        uriPathInfo.getKind() != UriResourceKind.singleton) {
+      fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+    }
+
+    EdmType actualType = null;
+    if (uriPathInfo instanceof UriResourceComplexPropertyImpl) {
+      actualType = ((UriResourceComplexPropertyImpl) uriPathInfo).getComplexTypeFilter();
+    } else if (uriPathInfo instanceof UriResourceSingletonImpl) {
+      actualType = ((UriResourceSingletonImpl) uriPathInfo).getEntityTypeFilter();
+    }
+
+    if (actualType == null) {
+      fail("type information not set");
+    }
+
+    FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
+
+    assertEquals(expectedType.toString(), actualName.toString());
+    return this;
+  }
+
+  public ResourceValidator isType(final FullQualifiedName type) {
+    if (!(uriPathInfo instanceof UriResourcePartTyped)) {
+      fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+    }
+    UriResourcePartTyped uriPathInfoTyped = (UriResourcePartTyped) uriPathInfo;
+
+    EdmType actualType = uriPathInfoTyped.getType();
+    if (actualType == null) {
+      fail("type information not set");
+    }
+
+    FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
+
+    assertEquals(type.toString(), actualName.toString());
+
+    return this;
+  }
+
+  public ResourceValidator isType(final FullQualifiedName type, final boolean isFinallyACollection) {
+    isType(type);
+    assertEquals(isFinallyACollection, ((UriResourcePartTyped) uriPathInfo).isCollection());
+    return this;
+  }
+
+  public ResourceValidator isTypeFilterOnEntry(final FullQualifiedName type) {
+    if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {
+      fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+    }
+
+    UriResourceWithKeysImpl uriPathInfoKeyPred = (UriResourceWithKeysImpl) uriPathInfo;
+
+    // input parameter type may be null in order to assert that the singleTypeFilter is not set
+    EdmType actualType = uriPathInfoKeyPred.getTypeFilterOnEntry();
+    if (type == null) {
+      assertEquals(type, actualType);
+    } else {
+      assertEquals(type.toString(), new FullQualifiedName(actualType.getNamespace(), actualType.getName()).toString());
+    }
+
+    return this;
+  }
+
+  public ResourceValidator isTypeFilterOnCollection(final FullQualifiedName expectedType) {
+    if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {
+      fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+    }
+    UriResourceWithKeysImpl uriPathInfoKeyPred = (UriResourceWithKeysImpl) uriPathInfo;
+
+    // input parameter type may be null in order to assert that the collectionTypeFilter is not set
+    EdmType actualType = uriPathInfoKeyPred.getTypeFilterOnCollection();
+    if (expectedType == null) {
+      assertEquals(expectedType, actualType);
+    } else {
+      FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
+      assertEquals(expectedType.toString(), actualName.toString());
+    }
+
+    return this;
+  }
+
+  // other functions
+  public ResourceValidator checkCustomParameter(final int index, final String name, final String value) {
+    if (uriInfo == null) {
+      fail("hasQueryParameter: uriInfo == null");
+    }
+
+    List<CustomQueryOption> list = uriInfo.getCustomQueryOptions();
+    if (list.size() <= index) {
+      fail("not enough queryParameters");
+    }
+
+    CustomQueryOptionImpl option = (CustomQueryOptionImpl) list.get(index);
+    assertEquals(name, option.getName());
+    assertEquals(value, option.getText());
+    return this;
+  }
+
+  // TODO remove
+  /*
+   * public ResourceValidator isCollection(final boolean isCollection) {
+   * if (!(uriPathInfo instanceof UriResourcePartTyped)) {
+   * fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+   * }
+   * UriResourcePartTyped uriPathInfoTyped = (UriResourcePartTyped) uriPathInfo;
+   * 
+   * EdmType type = uriPathInfoTyped.getType();
+   * if (type == null) {
+   * fail("isCollection: type == null");
+   * }
+   * assertEquals(isCollection, uriPathInfoTyped.isCollection());
+   * return this;
+   * }
+   */
+
+  public ResourceValidator isFilterString(final String expectedFilterTreeAsString) {
+
+    ExpressionImpl filterTree = (ExpressionImpl) uriInfo.getFilterOption().getExpression();
+    try {
+      String filterTreeAsString = filterTree.accept(new FilterTreeToText());
+      assertEquals(expectedFilterTreeAsString, filterTreeAsString);
+    } catch (ExpressionVisitException e) {
+      fail("isFilterString: Exception " + e.getMessage() + " occured");
+    } catch (ODataApplicationException e) {
+      fail("isFilterString: Exception " + e.getMessage() + " occured");
+    }
+
+    return this;
+  }
+
+  public ResourceValidator isKeyPredicateRef(final int index, final String name, final String refencedProperty) {
+    if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {
+      fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+    }
+
+    UriResourceWithKeysImpl info = (UriResourceWithKeysImpl) uriPathInfo;
+    List<UriParameter> keyPredicates = info.getKeyPredicates();
+    assertEquals(name, keyPredicates.get(index).getName());
+    assertEquals(refencedProperty, keyPredicates.get(index).getRefencedProperty());
+    return this;
+
+  }
+
+  public ResourceValidator isKeyPredicateAlias(final int index, final String name, final String alias) {
+    if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {
+      fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+    }
+
+    UriResourceWithKeysImpl info = (UriResourceWithKeysImpl) uriPathInfo;
+    List<UriParameter> keyPredicates = info.getKeyPredicates();
+    assertEquals(name, keyPredicates.get(index).getName());
+    assertEquals(alias, keyPredicates.get(index).getAlias());
+    return this;
+
+  }
+
+  public ResourceValidator isKeyPredicate(final int index, final String name, final String text) {
+    if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {
+      fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+    }
+
+    UriResourceWithKeysImpl info = (UriResourceWithKeysImpl) uriPathInfo;
+    List<UriParameter> keyPredicates = info.getKeyPredicates();
+    assertEquals(name, keyPredicates.get(index).getName());
+    assertEquals(text, keyPredicates.get(index).getText());
+    return this;
+
+  }
+
+  public ResourceValidator isParameter(final int index, final String name, final String text) {
+    if (!(uriPathInfo instanceof UriResourceFunctionImpl)) {
+      fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+    }
+
+    UriResourceFunctionImpl info = (UriResourceFunctionImpl) uriPathInfo;
+    List<UriParameter> keyPredicates = info.getParameters();
+    assertEquals(name, keyPredicates.get(index).getName());
+    assertEquals(text, keyPredicates.get(index).getText());
+    return this;
+
+  }
+
+  public ResourceValidator isParameterAlias(final int index, final String name, final String alias) {
+    if (!(uriPathInfo instanceof UriResourceFunctionImpl)) {
+      fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+    }
+
+    UriResourceFunctionImpl info = (UriResourceFunctionImpl) uriPathInfo;
+    List<UriParameter> keyPredicates = info.getParameters();
+    assertEquals(name, keyPredicates.get(index).getName());
+    assertEquals(alias, keyPredicates.get(index).getAlias());
+    return this;
+
+  }
+
+  public ResourceValidator isKind(final UriInfoKind kind) {
+    assertEquals(kind, uriInfo.getKind());
+    return this;
+  }
+
+  public ResourceValidator isPrimitiveProperty(final String name,
+      final FullQualifiedName type, final boolean isCollection) {
+    if (!(uriPathInfo instanceof UriResourcePrimitivePropertyImpl)) {
+      fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+    }
+
+    UriResourcePrimitivePropertyImpl uriPathInfoProp = (UriResourcePrimitivePropertyImpl) uriPathInfo;
+
+    EdmElement property = uriPathInfoProp.getProperty();
+
+    assertEquals(name, property.getName());
+    assertEquals(type, new FullQualifiedName(property.getType().getNamespace(), property.getType().getName()));
+    assertEquals(isCollection, property.isCollection());
+    return this;
+  }
+
+  public ResourceValidator
+      isComplexProperty(final String name, final FullQualifiedName type, final boolean isCollection) {
+    if (!(uriPathInfo instanceof UriResourceComplexPropertyImpl)) {
+      fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+    }
+
+    UriResourceComplexPropertyImpl uriPathInfoProp = (UriResourceComplexPropertyImpl) uriPathInfo;
+
+    EdmElement property = uriPathInfoProp.getProperty();
+
+    assertEquals(name, property.getName());
+    assertEquals(type, new FullQualifiedName(property.getType().getNamespace(), property.getType().getName()));
+    assertEquals(isCollection, property.isCollection());
+    return this;
+  }
+
+  public ResourceValidator isNavProperty(final String name, final FullQualifiedName type, final boolean isCollection) {
+    if (!(uriPathInfo instanceof UriResourceNavigationPropertyImpl)) {
+      fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+    }
+
+    UriResourceNavigationPropertyImpl uriPathInfoProp = (UriResourceNavigationPropertyImpl) uriPathInfo;
+
+    EdmElement property = uriPathInfoProp.getProperty();
+
+    assertEquals(name, property.getName());
+    assertEquals(type, new FullQualifiedName(property.getType().getNamespace(), property.getType().getName()));
+    assertEquals(isCollection, uriPathInfoProp.isCollection());
+    return this;
+  }
+
+  public ResourceValidator isUriPathInfoKind(final UriResourceKind infoType) {
+    assertNotNull(uriPathInfo);
+    assertEquals(infoType, uriPathInfo.getKind());
+    return this;
+  }
+
+  public ResourceValidator isAction(final String name) {
+    assertEquals(UriResourceKind.action, uriPathInfo.getKind());
+    assertEquals(name, ((UriResourceActionImpl) uriPathInfo).getAction().getName());
+    return this;
+  }
+
+  public ResourceValidator isFunction(final String name) {
+    assertEquals(UriResourceKind.function, uriPathInfo.getKind());
+    assertEquals(name, ((UriResourceFunctionImpl) uriPathInfo).getFunction().getName());
+    return this;
+  }
+
+  public ResourceValidator isFunctionImport(final String name) {
+    assertEquals(UriResourceKind.function, uriPathInfo.getKind());
+    assertEquals(name, ((UriResourceFunctionImpl) uriPathInfo).getFunctionImport().getName());
+    return this;
+  }
+
+  public ResourceValidator isEntitySet(final String name) {
+    assertEquals(UriResourceKind.entitySet, uriPathInfo.getKind());
+    assertEquals(name, ((UriResourceEntitySetImpl) uriPathInfo).getEntitySet().getName());
+    return this;
+  }
+
+  public ResourceValidator isComplex(final String name) {
+    assertEquals(UriResourceKind.complexProperty, uriPathInfo.getKind());
+    assertEquals(name, ((UriResourceComplexPropertyImpl) uriPathInfo).getProperty().getName());
+    return this;
+  }
+
+  public ResourceValidator isSingleton(final String name) {
+    assertEquals(UriResourceKind.singleton, uriPathInfo.getKind());
+    assertEquals(name, ((UriResourceSingletonImpl) uriPathInfo).getSingleton().getName());
+    return this;
+  }
+
+  public ResourceValidator isValue() {
+    assertEquals(UriResourceKind.value, uriPathInfo.getKind());
+    return this;
+  }
+
+  public ResourceValidator isCount() {
+    assertEquals(UriResourceKind.count, uriPathInfo.getKind());
+    return this;
+  }
+
+  public ResourceValidator isRef() {
+    assertEquals(UriResourceKind.ref, uriPathInfo.getKind());
+    return this;
+  }
+
+  public ResourceValidator isActionImport(final String actionName) {
+    assertEquals(UriResourceKind.action, uriPathInfo.getKind());
+    assertEquals(actionName, ((UriResourceActionImpl) uriPathInfo).getActionImport().getName());
+    return this;
+  }
+
+  public ResourceValidator isIt() {
+    assertEquals(UriResourceKind.it, uriPathInfo.getKind());
+    return this;
+  }
+
+  public ResourceValidator isTopText(final String topText) {
+    assertEquals(topText, uriInfo.getTopOption().getText());
+    return this;
+  }
+
+  public ResourceValidator isFormatText(final String formatText) {
+    assertEquals(formatText, uriInfo.getFormatOption().getText());
+    return this;
+  }
+
+  public ResourceValidator isInlineCountText(final String inlineCountText) {
+    assertEquals(inlineCountText, uriInfo.getCountOption().getText());
+    return this;
+  }
+
+  public ResourceValidator isSkipText(final String skipText) {
+    assertEquals(skipText, uriInfo.getSkipOption().getText());
+    return this;
+  }
+
+  public ResourceValidator isSkipTokenText(final String skipTokenText) {
+    assertEquals(skipTokenText, uriInfo.getSkipTokenOption().getText());
+    return this;
+  }
+
+  public ResourceValidator isSelectItemStar(final int index) {
+    SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
+
+    SelectItem item = select.getSelectItems().get(index);
+    assertEquals(true, item.isStar());
+    return this;
+  }
+
+  public ResourceValidator isSelectItemAllOp(final int index, final FullQualifiedName fqn) {
+    SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
+
+    SelectItem item = select.getSelectItems().get(index);
+    assertEquals(fqn.toString(), item.getAllOperationsInSchemaNameSpace().toString());
+    return this;
+  }
+
+  public ResourceValidator isSelectStartType(final int index, final FullQualifiedName fullName) {
+    SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
+    SelectItem item = select.getSelectItems().get(index);
+
+    EdmType actualType = item.getStartTypeFilter();
+
+    FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
+    assertEquals(fullName, actualName);
+    return this;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6d344e2c/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/TestErrorLogger.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/TestErrorLogger.java b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/TestErrorLogger.java
new file mode 100644
index 0000000..0153036
--- /dev/null
+++ b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/TestErrorLogger.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.core.uri.testutil;
+
+import java.util.BitSet;
+import java.util.Collections;
+import java.util.List;
+
+import org.antlr.v4.runtime.ANTLRErrorListener;
+import org.antlr.v4.runtime.Parser;
+import org.antlr.v4.runtime.RecognitionException;
+import org.antlr.v4.runtime.Recognizer;
+import org.antlr.v4.runtime.atn.ATNConfigSet;
+import org.antlr.v4.runtime.dfa.DFA;
+import org.apache.olingo.server.core.uri.antlr.UriLexer;
+
+class TestErrorLogger implements ANTLRErrorListener {
+
+  private String prefix;
+  private int logLevel = 0;
+
+  public TestErrorLogger(final String prefix, final int logLevel) {
+    this.prefix = prefix;
+    this.logLevel = logLevel;
+  }
+
+  @Override
+  public void syntaxError(final Recognizer<?, ?> recognizer, final Object offendingSymbol, final int line,
+      final int charPositionInLine,
+      final String msg, final RecognitionException e) {
+
+    if (logLevel > 0) {
+      System.out.println("\n" + prefix + " -- SyntaxError");
+      trace(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
+    }
+
+  }
+
+  @Override
+  public void reportAmbiguity(final Parser recognizer, final DFA dfa, final int startIndex, final int stopIndex,
+      final boolean exact,
+      final BitSet ambigAlts, final ATNConfigSet configs) {
+
+  }
+
+  @Override
+  public void reportAttemptingFullContext(final Parser recognizer, final DFA dfa, final int startIndex,
+      final int stopIndex,
+      final BitSet conflictingAlts, final ATNConfigSet configs) {
+
+  }
+
+  @Override
+  public void reportContextSensitivity(final Parser recognizer, final DFA dfa, final int startIndex,
+      final int stopIndex, final int prediction,
+      final ATNConfigSet configs) {
+
+  }
+
+  private void printStack(final Recognizer<?, ?> recognizer) {
+    List<String> stack = ((Parser) recognizer).getRuleInvocationStack();
+    Collections.reverse(stack);
+    System.out.println(" rule stack: " + stack);
+  }
+
+  public void trace(final Recognizer<?, ?> recognizer, final Object offendingSymbol,
+      final int line, final int charPositionInLine, final String msg, final RecognitionException e) {
+
+    System.out.println("Error message: " + msg);
+
+    printStack(recognizer);
+
+    System.out.println(" line/char :" + line + " / " + charPositionInLine);
+    System.out.println(" sym       :" + offendingSymbol);
+    if (e != null && e.getOffendingToken() != null) {
+
+      String lexerTokenName = "";
+      try {
+        lexerTokenName = UriLexer.tokenNames[e.getOffendingToken().getType()];
+      } catch (ArrayIndexOutOfBoundsException es) {
+        lexerTokenName = "token error";
+      }
+
+      System.out.println(" tokenname:" + lexerTokenName);
+    }
+
+  }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6d344e2c/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java
new file mode 100644
index 0000000..35687f6
--- /dev/null
+++ b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java
@@ -0,0 +1,258 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.core.uri.testutil;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.List;
+
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.edm.EdmType;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.server.api.uri.UriInfoKind;
+import org.apache.olingo.server.api.uri.queryoption.CustomQueryOption;
+import org.apache.olingo.server.api.uri.queryoption.SelectItem;
+import org.apache.olingo.server.core.uri.UriInfoImpl;
+import org.apache.olingo.server.core.uri.parser.Parser;
+import org.apache.olingo.server.core.uri.parser.UriParserException;
+import org.apache.olingo.server.core.uri.parser.UriParserSemanticException;
+import org.apache.olingo.server.core.uri.parser.UriParserSyntaxException;
+import org.apache.olingo.server.core.uri.queryoption.CustomQueryOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.ExpandOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.FilterOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.SelectOptionImpl;
+import org.apache.olingo.server.core.uri.validator.UriValidator;
+
+public class TestUriValidator implements TestValidator {
+  private Edm edm;
+
+  private UriInfoImpl uriInfo;
+  private Exception exception;
+
+  // Setup
+  public TestUriValidator setEdm(final Edm edm) {
+    this.edm = edm;
+    return this;
+  }
+
+  // Execution
+  public TestUriValidator run(final String uri) {
+    Parser parser = new Parser();
+    UriValidator validator = new UriValidator();
+
+    uriInfo = null;
+    try {
+      uriInfo = (UriInfoImpl) parser.parseUri(uri, edm);
+      validator.validate(uriInfo, "GET");
+    } catch (Exception e) {
+      throw new RuntimeException(e);
+    }
+
+    return this;
+  }
+
+  public TestUriValidator runEx(final String uri) {
+    Parser parser = new Parser();
+    uriInfo = null;
+    try {
+      uriInfo = (UriInfoImpl) parser.parseUri(uri, edm);
+      fail("Exception expected");
+    } catch (UriParserException e) {
+      exception = e;
+    }
+
+    return this;
+  }
+
+  public TestUriValidator log(final String uri) {
+    ParserWithLogging parserTest = new ParserWithLogging();
+    parserTest.setLogLevel(1);
+    uriInfo = null;
+    try {
+      // uriInfoTmp = new UriParserImpl(edm).ParseUri(uri);
+      uriInfo = (UriInfoImpl) parserTest.parseUri(uri, edm);
+    } catch (UriParserException e) {
+      fail("Exception occured while parsing the URI: " + uri + "\n"
+          + " Exception: " + e.getMessage());
+    }
+
+    return this;
+  }
+
+  // Navigation
+  public ResourceValidator goPath() {
+    if (uriInfo.getKind() != UriInfoKind.resource) {
+      fail("invalid resource kind: " + uriInfo.getKind().toString());
+    }
+
+    return new ResourceValidator()
+        .setUpValidator(this)
+        .setEdm(edm)
+        .setUriInfoImplPath(uriInfo);
+  }
+
+  public FilterValidator goFilter() {
+    FilterOptionImpl filter = (FilterOptionImpl) uriInfo.getFilterOption();
+    if (filter == null) {
+      fail("no filter found");
+    }
+    return new FilterValidator().setUriValidator(this).setFilter(filter);
+
+  }
+
+  public ExpandValidator goExpand() {
+    ExpandOptionImpl expand = (ExpandOptionImpl) uriInfo.getExpandOption();
+    if (expand == null) {
+      fail("invalid resource kind: " + uriInfo.getKind().toString());
+    }
+
+    return new ExpandValidator().setUpValidator(this).setExpand(expand);
+  }
+
+  public ResourceValidator goSelectItemPath(final int index) {
+    SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
+
+    SelectItem item = select.getSelectItems().get(index);
+    UriInfoImpl uriInfo1 = (UriInfoImpl) item.getResourcePath();
+
+    return new ResourceValidator()
+        .setUpValidator(this)
+        .setEdm(edm)
+        .setUriInfoImplPath(uriInfo1);
+
+  }
+
+  public TestUriValidator isSelectStartType(final int index, final FullQualifiedName fullName) {
+    SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
+    SelectItem item = select.getSelectItems().get(index);
+    EdmType actualType = item.getStartTypeFilter();
+
+    FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
+    assertEquals(fullName, actualName);
+    return this;
+
+  }
+
+  // Validation
+  public TestUriValidator isKind(final UriInfoKind kind) {
+    assertEquals(kind, uriInfo.getKind());
+    return this;
+  }
+
+  public TestUriValidator isCustomParameter(final int index, final String name, final String value) {
+    if (uriInfo == null) {
+      fail("hasQueryParameter: uriInfo == null");
+    }
+
+    List<CustomQueryOption> list = uriInfo.getCustomQueryOptions();
+    if (list.size() <= index) {
+      fail("not enought queryParameters");
+    }
+
+    CustomQueryOptionImpl option = (CustomQueryOptionImpl) list.get(index);
+    assertEquals(name, option.getName());
+    assertEquals(value, option.getText());
+    return this;
+  }
+
+  public void isCrossJoinEntityList(final List<String> entitySets) {
+    if (uriInfo.getKind() != UriInfoKind.crossjoin) {
+      fail("invalid resource kind: " + uriInfo.getKind().toString());
+    }
+
+    int i = 0;
+    for (String entitySet : entitySets) {
+      assertEquals(entitySet, uriInfo.getEntitySetNames().get(i));
+      i++;
+    }
+
+  }
+
+  public TestUriValidator isExSyntax(final long errorID) {
+    assertEquals(UriParserSyntaxException.class, exception.getClass());
+    return this;
+  }
+
+  public TestUriValidator isExSemantic(final long errorID) {
+    assertEquals(UriParserSemanticException.class, exception.getClass());
+    return this;
+  }
+
+  public TestUriValidator isIdText(final String text) {
+    assertEquals(text, uriInfo.getIdOption().getText());
+    return this;
+  }
+
+  public TestUriValidator isExpandText(final String text) {
+    assertEquals(text, uriInfo.getExpandOption().getText());
+    return this;
+  }
+
+  public TestUriValidator isSelectText(final String text) {
+    assertEquals(text, uriInfo.getSelectOption().getText());
+    return this;
+  }
+
+  public TestUriValidator isFormatText(final String text) {
+    assertEquals(text, uriInfo.getFormatOption().getText());
+    return this;
+  }
+
+  public TestUriValidator isFragmentText(final String text) {
+    if (uriInfo.getKind() != UriInfoKind.metadata) {
+      fail("invalid resource kind: " + uriInfo.getKind().toString());
+    }
+
+    assertEquals(text, uriInfo.getFragment());
+
+    return this;
+  }
+
+  public TestUriValidator isEntityType(final FullQualifiedName fullName) {
+    if (uriInfo.getKind() != UriInfoKind.entityId) {
+      fail("invalid resource kind: " + uriInfo.getKind().toString());
+    }
+
+    assertEquals(fullName.toString(), fullName(uriInfo.getEntityTypeCast()));
+    return this;
+  }
+
+  private String fullName(final EdmEntityType type) {
+    return type.getNamespace() + "." + type.getName();
+  }
+
+  public TestUriValidator isSelectItemStar(final int index) {
+    SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
+
+    SelectItem item = select.getSelectItems().get(index);
+    assertEquals(true, item.isStar());
+    return this;
+  }
+
+  public TestUriValidator isSelectItemAllOp(final int index, final FullQualifiedName fqn) {
+    SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
+
+    SelectItem item = select.getSelectItems().get(index);
+    assertEquals(fqn.toString(), item.getAllOperationsInSchemaNameSpace().toString());
+    return this;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6d344e2c/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/TestValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/TestValidator.java b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/TestValidator.java
new file mode 100644
index 0000000..7e64f86
--- /dev/null
+++ b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/TestValidator.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.core.uri.testutil;
+
+public interface TestValidator {
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6d344e2c/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/TokenValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/TokenValidator.java b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/TokenValidator.java
new file mode 100644
index 0000000..4a94bb3
--- /dev/null
+++ b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/core/uri/testutil/TokenValidator.java
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.core.uri.testutil;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.antlr.v4.runtime.ANTLRInputStream;
+import org.antlr.v4.runtime.Token;
+import org.apache.olingo.server.core.uri.antlr.UriLexer;
+
+//TODO extend to test also exception which can occure while paring
+public class TokenValidator {
+
+  private String input = null;
+
+  private List<? extends Token> tokens = null;
+  private Token curToken = null;
+  private Exception curException = null;
+
+  private int startMode;
+  private int logLevel = 0;
+
+  // --- Setup ---
+
+  public TokenValidator log(final int logLevel) {
+    this.logLevel = logLevel;
+    return this;
+  }
+
+  // --- Execution ---
+
+  public TokenValidator run(final String uri) {
+    input = uri;
+
+    tokens = parseInput(uri);
+    if (logLevel > 0) {
+      showTokens();
+    }
+
+    first();
+    exFirst();
+    logLevel = 0;
+
+    return this;
+  }
+
+  // --- Navigation ---
+
+  // navigate within the tokenlist
+  public TokenValidator first() {
+    try {
+      curToken = tokens.get(0);
+    } catch (IndexOutOfBoundsException ex) {
+      curToken = null;
+    }
+    return this;
+  }
+
+  public TokenValidator last() {
+    curToken = tokens.get(tokens.size() - 1);
+    return this;
+  }
+
+  public TokenValidator at(final int index) {
+    try {
+      curToken = tokens.get(index);
+    } catch (IndexOutOfBoundsException ex) {
+      curToken = null;
+    }
+    return this;
+  }
+
+  public TokenValidator exLast() {
+    // curException = exceptions.get(exceptions.size() - 1);
+    return this;
+  }
+
+  // navigate within the exception list
+  public TokenValidator exFirst() {
+    try {
+      // curException = exceptions.get(0);
+    } catch (IndexOutOfBoundsException ex) {
+      curException = null;
+    }
+    return this;
+
+  }
+
+  public TokenValidator exAt(final int index) {
+    try {
+      // curException = exceptions.get(index);
+    } catch (IndexOutOfBoundsException ex) {
+      curException = null;
+    }
+    return this;
+  }
+
+  // --- Validation ---
+
+  public TokenValidator isText(final String expected) {
+    assertEquals(expected, curToken.getText());
+    return this;
+  }
+
+  public TokenValidator isAllText(final String expected) {
+    String actual = "";
+
+    for (Token curToken : tokens) {
+      actual += curToken.getText();
+    }
+    assertEquals(expected, actual);
+    return this;
+  }
+
+  public TokenValidator isAllInput() {
+    String actual = "";
+
+    for (Token curToken : tokens) {
+      actual += curToken.getText();
+    }
+    assertEquals(input, actual);
+    return this;
+  }
+
+  public TokenValidator isInput() {
+    assertEquals(input, curToken.getText());
+    return this;
+  }
+
+  public TokenValidator isType(final int expected) {
+    assertEquals(UriLexer.tokenNames[expected], UriLexer.tokenNames[curToken.getType()]);
+    return this;
+  }
+
+  public TokenValidator isExType(final Class<?> exClass) {
+    assertEquals(exClass, curException.getClass());
+    return this;
+  }
+
+  public void globalMode(final int mode) {
+    startMode = mode;
+  }
+
+  // --- Helper ---
+
+  private List<? extends Token> parseInput(final String input) {
+    ANTLRInputStream inputStream = new ANTLRInputStream(input);
+
+    UriLexer lexer = new UriLexerWithTrace(inputStream, logLevel, startMode);
+    // lexer.addErrorListener(new ErrorCollector(this));
+    return lexer.getAllTokens();
+  }
+
+  public TokenValidator showTokens() {
+    boolean first = true;
+    System.out.println("input: " + input);
+    String nL = "\n";
+    String out = "[" + nL;
+    for (Token token : tokens) {
+      if (!first) {
+        out += ",";
+        first = false;
+      }
+      int index = token.getType();
+      if (index != -1) {
+        out += "\"" + token.getText() + "\"" + "     " + UriLexer.tokenNames[index] + nL;
+      } else {
+        out += "\"" + token.getText() + "\"" + "     " + index + nL;
+      }
+    }
+    out += ']';
+    System.out.println("tokens: " + out);
+    return this;
+  }
+
+}