You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ko...@apache.org on 2014/01/23 12:30:35 UTC

[04/12] [OLINGO-63] Uri Parser: Add support for II

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/7955eadf/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/ExpandToText.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/ExpandToText.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/ExpandToText.java
new file mode 100644
index 0000000..d9926ce
--- /dev/null
+++ b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/ExpandToText.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata4.producer.core.testutil;
+
+import java.util.List;
+
+import org.apache.olingo.odata4.commons.api.edm.EdmElement;
+import org.apache.olingo.odata4.commons.api.edm.EdmType;
+import org.apache.olingo.odata4.producer.api.uri.queryoption.ExceptionVisitExpand;
+import org.apache.olingo.odata4.producer.api.uri.queryoption.ExpandVisitor;
+import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandOptionImpl;
+
+
+public class ExpandToText implements ExpandVisitor<String> {
+
+  public static String Serialize(ExpandOptionImpl expand) throws ExceptionVisitExpand {
+    return expand.accept(new ExpandToText());
+  }
+
+  @Override
+  public String visitExpandSegment(EdmElement property, EdmType initialType, EdmType finalType) {
+
+    return "<" + property.getName() + "(" + finalType.getNamespace() + "/" + finalType.getName() + ">";
+  }
+
+  @Override
+  public String visitExpandItem(List<String> expandSegments, boolean isStar, boolean isRef, EdmType finalType) {
+    String tmp = "";
+    for (String expandItem : expandSegments) {
+      if (tmp.length() != 0) {
+        tmp += ",";
+      }
+      tmp += expandItem;
+    }
+    return "<(" + tmp + ")>";
+  }
+
+  @Override
+  public String visitExpand(List<String> expandItems) {
+    String tmp = "";
+
+    for (String expandItem : expandItems) {
+      if (tmp.length() != 0) {
+        tmp += ",";
+      }
+      tmp += expandItem;
+    }
+    return "<(" + tmp + ")>";
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/7955eadf/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/FilterTreeToText.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/FilterTreeToText.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/FilterTreeToText.java
index 3ee3ff3..d3f933c 100644
--- a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/FilterTreeToText.java
+++ b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/FilterTreeToText.java
@@ -20,15 +20,21 @@ package org.apache.olingo.odata4.producer.core.testutil;
 
 import java.util.List;
 
-import org.apache.olingo.odata4.producer.core.uri.UriInfoImplPath;
-import org.apache.olingo.odata4.producer.core.uri.expression.ExceptionVisitExpression;
-import org.apache.olingo.odata4.producer.core.uri.expression.ExpressionVisitor;
-import org.apache.olingo.odata4.producer.core.uri.expression.Member;
-import org.apache.olingo.odata4.producer.core.uri.expression.SupportedBinaryOperators;
-import org.apache.olingo.odata4.producer.core.uri.expression.SupportedMethodCalls;
-import org.apache.olingo.odata4.producer.core.uri.expression.SupportedUnaryOperators;
+import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.SupportedBinaryOperators;
+import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.SupportedMethodCalls;
+import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.SupportedUnaryOperators;
+import org.apache.olingo.odata4.producer.core.uri.UriInfoImpl;
+import org.apache.olingo.odata4.producer.core.uri.queryoption.FilterOptionImpl;
+import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExceptionVisitExpression;
+import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExpressionVisitor;
+import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.MemberImpl;
+
 
 public class FilterTreeToText implements ExpressionVisitor<String> {
+  
+  public static String Serialize(FilterOptionImpl filter) throws ExceptionVisitExpression {
+    return filter.getExpression().accept(new FilterTreeToText());
+  }
 
   @Override
   public String visitBinaryOperator(SupportedBinaryOperators operator, String left, String right)
@@ -53,8 +59,7 @@ public class FilterTreeToText implements ExpressionVisitor<String> {
       text += parameters.get(i);
       i++;
     }
-    // TODO Auto-generated method stub
-    return text + ")";
+    return text + ")>";
   }
 
   @Override
@@ -63,22 +68,15 @@ public class FilterTreeToText implements ExpressionVisitor<String> {
   }
 
   @Override
-  public String visitMember(Member member) throws ExceptionVisitExpression {
+  public String visitMember(MemberImpl member) throws ExceptionVisitExpression {
     String ret = "";
     if (member.isIT()) {
       ret += "$it";
     }
 
-    UriInfoImplPath path = member.getPath();
+    UriInfoImpl path = (UriInfoImpl) member.getPath();
     if (path != null) {
-      /*
-       * if (member.isIT()) {
-       * ret +="/";
-       * }
-       */
-
       ret += path.toString();
-
     }
     return ret;
   }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/7955eadf/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/FilterValidator.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/FilterValidator.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/FilterValidator.java
index dadb9b1..43c562b 100644
--- a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/FilterValidator.java
+++ b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/FilterValidator.java
@@ -21,50 +21,164 @@ package org.apache.olingo.odata4.producer.core.testutil;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
-import org.apache.olingo.odata4.producer.core.uri.UriInfoImplPath;
-import org.apache.olingo.odata4.producer.core.uri.expression.ExceptionVisitExpression;
-import org.apache.olingo.odata4.producer.core.uri.expression.Expression;
-import org.apache.olingo.odata4.producer.core.uri.queryoption.Filter;
+import org.apache.olingo.odata4.commons.api.edm.Edm;
+import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
+import org.apache.olingo.odata4.producer.core.uri.ParserAdapter;
+import org.apache.olingo.odata4.producer.core.uri.UriInfoImpl;
+import org.apache.olingo.odata4.producer.core.uri.UriParserException;
+import org.apache.olingo.odata4.producer.core.uri.UriParseTreeVisitor;
+import org.apache.olingo.odata4.producer.core.uri.queryoption.FilterOptionImpl;
+import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExceptionVisitExpression;
 
-public class FilterValidator {
+public class FilterValidator implements Validator {
+  private Edm edm;
 
-  UriResourcePathValidator uriResourcePathValidator;
-  Filter filter;
+  private Validator invokedBy;
+  private FilterOptionImpl filter;
 
-  public FilterValidator(UriResourcePathValidator uriResourcePathValidator) {
+  private int logLevel;
 
-    this.uriResourcePathValidator = uriResourcePathValidator;
+  // --- Setup ---
+  public FilterValidator SetUriResourcePathValidator(UriResourcePathValidator uriResourcePathValidator) {
+    this.invokedBy = uriResourcePathValidator;
+    return this;
+  }
+
+  public FilterValidator setUriValidator(UriValidator uriValidator) {
+    this.invokedBy = uriValidator;
+    return this;
+  }
+
+  public FilterValidator setEdm(final Edm edm) {
+    this.edm = edm;
+    return this;
+  }
+
+  public FilterValidator setFilter(FilterOptionImpl filter) {
+    this.filter = filter;
+
+    if (filter.getExpression() == null) {
 
-    filter = ((UriInfoImplPath) uriResourcePathValidator.uriInfo).getFilter();
-    if (filter.getTree() == null) {
       fail("FilterValidator: no filter found");
     }
-    return;
+    return this;
+  }
+  
+  public FilterValidator log(final int logLevel) {
+    this.logLevel = logLevel;
+    return this;
+  }
+
+  // --- Execution ---
+  public FilterValidator runOnETTwoKeyNav(String filter) {
+    String uri = "SINav?$filter=" + filter.trim();
+    return runUri(uri);
+  }
+
+  public FilterValidator runOnETAllPrim(String filter) {
+    String uri = "ESAllPrim(1)?$filter=" + filter.trim(); 
+    return runUri(uri);
   }
 
-  // Validates the serialized filterTree against a given filterString
-  // The given filterString is compressed before to allow better readable code in the unit tests 
+  public FilterValidator runOnETKeyNav(String filter) {
+    String uri = "ESKeyNav(1)?$filter=" + filter.trim(); 
+    return runUri(uri);
+  }
+
+  
+  public FilterValidator runOnCTTwoPrim(String filter) {
+    String uri = "SINav/PropertyComplexTwoPrim?$filter=" + filter.trim(); 
+    return runUri(uri);
+  }
+  
+  public FilterValidator runOnString(String filter) {
+    String uri = "SINav/PropertyString?$filter=" + filter.trim(); 
+    return runUri(uri);
+  }
+  
+  public FilterValidator runOnInt32(String filter) {
+    String uri = "ESCollAllPrim(1)/CollPropertyInt32?$filter=" + filter.trim(); 
+    return runUri(uri);
+  }
+  
+  
+  public FilterValidator runOnDateTimeOffset(String filter) {
+    String uri = "ESCollAllPrim(1)/CollPropertyDateTimeOffset?$filter=" + filter.trim(); 
+    return runUri(uri);
+  }
+  
+  public FilterValidator runOnDuration(String filter) {
+    String uri = "ESCollAllPrim(1)/CollPropertyDuration?$filter=" + filter.trim(); 
+    return runUri(uri);
+  }
+  
+  public FilterValidator runOnTimeOfDay(String filter) {
+    String uri = "ESCollAllPrim(1)/CollPropertyTimeOfDay?$filter=" + filter.trim(); 
+    return runUri(uri);
+  }
+  
+  
+  public FilterValidator runESabc(String filter) {
+    String uri = "ESabc?$filter=" + filter.trim(); 
+    return runUri(uri);
+  }
+  
+  public FilterValidator runUri(String uri) { 
+  
+    UriInfoImpl uriInfo = null;
+    try {
+
+      uriInfo = ParserAdapter.parseUri(uri, new UriParseTreeVisitor(edm));
+    } catch (UriParserException e) {
+      fail("Exception occured while parsing the URI: " + uri + "\n"
+          + " Exception: " + e.getMessage());
+    }
+
+    if (uriInfo.getKind() != UriInfoKind.resource) {
+      fail("Filtervalidator can only be used on resourcePaths");
+    }
+
+    setFilter((FilterOptionImpl) uriInfo.getFilterOption());
+
+    return this;
+  }
+
+  // --- Navigation ---
+  public Validator goUp() {
+    return invokedBy;
+  }
+
+  // --- Validation ---
+
+  /**
+   * Validates the serialized filterTree against a given filterString
+   * The given filterString is compressed before to allow better readable code in the unit tests
+   * @param toBeCompr
+   * @return
+   */
   public FilterValidator isCompr(String toBeCompr) {
     return is(compress(toBeCompr));
   }
 
   public FilterValidator is(String expectedFilterAsString) {
     try {
-      String actualFilterAsText = filter.getTree().accept(new FilterTreeToText());
+      String actualFilterAsText = FilterTreeToText.Serialize((FilterOptionImpl) filter);
       assertEquals(expectedFilterAsString, actualFilterAsText);
     } catch (ExceptionVisitExpression e) {
       fail("Exception occured while converting the filterTree into text" + "\n"
           + " Exception: " + e.getMessage());
-
     }
 
     return this;
   }
 
+  // --- Helper ---
+
   private String compress(String expected) {
     String ret = expected.replaceAll("\\s+", " ");
     ret = ret.replaceAll("< ", "<");
     ret = ret.replaceAll(" >", ">");
     return ret;
   }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/7955eadf/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/ParserValidator.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/ParserValidator.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/ParserValidator.java
index 96f148f..658ccee 100644
--- a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/ParserValidator.java
+++ b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/ParserValidator.java
@@ -19,77 +19,44 @@
 package org.apache.olingo.odata4.producer.core.testutil;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
 
 import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.Collections;
 import java.util.List;
 
-import org.antlr.v4.runtime.ANTLRErrorListener;
 import org.antlr.v4.runtime.ANTLRInputStream;
 import org.antlr.v4.runtime.BailErrorStrategy;
 import org.antlr.v4.runtime.CommonTokenStream;
 import org.antlr.v4.runtime.DefaultErrorStrategy;
-import org.antlr.v4.runtime.Parser;
 import org.antlr.v4.runtime.ParserRuleContext;
-import org.antlr.v4.runtime.RecognitionException;
-import org.antlr.v4.runtime.Recognizer;
-import org.antlr.v4.runtime.Token;
-import org.antlr.v4.runtime.atn.ATNConfigSet;
 import org.antlr.v4.runtime.atn.PredictionMode;
-import org.antlr.v4.runtime.dfa.DFA;
-import org.antlr.v4.runtime.misc.Interval;
-import org.apache.olingo.odata4.producer.core.uri.antlr.UriLexer;
 import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser;
 import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.OdataRelativeUriEOFContext;
 
 // TODO extend to test also exception which can occure while paring
 public class ParserValidator {
-  
-  private List<Exception> exceptions = new ArrayList<Exception>();
-  private ParserRuleContext root;
 
   private String input = null;
-  private Exception curException = null;
-  // private int exceptionOnStage = -1;
-  // private Exception curWeakException = null;
-  private boolean allowFullContext;
-  private boolean allowContextSensitifity;
-  private boolean allowAmbiguity;
-  public int logLevel = 0;
+  private ParserRuleContext root;
+
+  int logLevel = 0;
   private int lexerLogLevel = 0;
 
-  // private int lexerLogLevel = 0;
+  boolean allowFullContext;
+  boolean allowContextSensitifity;
+  boolean allowAmbiguity;
 
-  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()).setLog(lexerLogLevel).run(input);
-    }
-    root = parseInput(uri);
-    // 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");
-      }
-    }
+  List<Exception> exceptions = new ArrayList<Exception>();
+  private Exception curException = null;
 
-    // reset for next test
-    allowFullContext = false;
-    allowContextSensitifity = false;
-    allowAmbiguity = false;
-    logLevel = 0;
+  // --- Setup ---
 
-    // exFirst();
+  public ParserValidator log(final int logLevel) {
+    this.logLevel = logLevel;
     return this;
   }
 
-  public ParserValidator log(final int logLevel) {
-    this.logLevel = logLevel;
+  public ParserValidator lexerLog(final int logLevel) {
+    this.lexerLogLevel = logLevel;
     return this;
   }
 
@@ -106,6 +73,7 @@ public class ParserValidator {
   }
 
   /**
+   * 
    * TODO verify
    * Used in fast LL Parsing:
    * Allows ContextSensitifity Errors which occur often when using the slower full context parsing
@@ -128,15 +96,72 @@ public class ParserValidator {
     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 text = ParseTreeToText.getTreeAsText(root, new UriParserParser(null).getRuleNames());
+    String actualTreeAsText = ParseTreeToText.getTreeAsText(root, new UriParserParser(null).getRuleNames());
 
-    assertEquals(expected, text);
+    assertEquals(expected, actualTreeAsText);
     return this;
   }
 
@@ -145,6 +170,8 @@ public class ParserValidator {
     return this;
   }
 
+  // --- Helper ---
+
   private OdataRelativeUriEOFContext parseInput(final String input) {
     UriParserParser parser = null;
     UriLexerWithTrace lexer = null;
@@ -158,31 +185,26 @@ public class ParserValidator {
     try {
       curException = null;
       exceptions.clear();
+
       // create parser
-      lexer = new UriLexerWithTrace( new ANTLRInputStream(input), this.lexerLogLevel);
+      lexer = new UriLexerWithTrace(new ANTLRInputStream(input), this.lexerLogLevel);
       parser = new UriParserParser(new CommonTokenStream(lexer));
 
-      // write single tokens to System.out
-      if (logLevel > 1) {
-        // can not be used because the listener is called before the mode changes
-        // TODO verify this
-        parser.addParseListener(new TokenWriter());
-      }
       // write always a error message in case of syntax errors
       // parser.addErrorListener(new TestErrorHandler<Object>());
       // check error message if whether they are allowed or not
-      parser.addErrorListener(new ErrorCollector(this));
+      //parser.addErrorListener(new ErrorCollector());
 
       // bail out of parser at first syntax error. --> proceed in catch block with step 2
       parser.setErrorHandler(new BailErrorStrategy());
 
-      // user the faster LL parsing
+      // user the faster SLL parsing
       parser.getInterpreter().setPredictionMode(PredictionMode.SLL);
 
       // parse
-      if (logLevel > 1) {
+      if (logLevel > 0) {
         System.out.println("Step 1");
-        System.out.println(" PrectictionMode: " + parser.getInterpreter().getPredictionMode() + ")");
+        System.out.println(" PrectictionMode: " + parser.getInterpreter().getPredictionMode());
       }
       ret = parser.odataRelativeUriEOF();
 
@@ -197,15 +219,10 @@ public class ParserValidator {
         lexer = new UriLexerWithTrace(new ANTLRInputStream(input), this.lexerLogLevel);
         parser = new UriParserParser(new CommonTokenStream(lexer));
 
-        // write single tokens to System.out
-        if (logLevel > 1) {
-          parser.addParseListener(new TokenWriter());
-        }
-
         // write always a error message in case of syntax errors
-        parser.addErrorListener(new ErrorCollector(this));
+        //parser.addErrorListener(new ErrorCollector(this));
         // check error message if whether they are allowed or not
-        parser.addErrorListener(new ErrorCollector(this));
+        //parser.addErrorListener(new ErrorCollector(this));
 
         // Used default error strategy
         parser.setErrorHandler(new DefaultErrorStrategy());
@@ -229,144 +246,4 @@ public class ParserValidator {
     return ret;
   }
 
-  private static class ErrorCollector implements ANTLRErrorListener {
-    private ParserValidator tokenValidator;
-
-    public ErrorCollector(final ParserValidator tokenValidator) {
-      this.tokenValidator = tokenValidator;
-    }
-
-    @Override
-    public void syntaxError(final Recognizer<?, ?> recognizer, final Object offendingSymbol, final int line,
-        final int charPositionInLine,
-        final String msg, final RecognitionException e) {
-
-      // Collect the exception
-      // TODO needs to be improved
-      tokenValidator.exceptions.add(e);
-      System.out.println("syntaxError");
-      trace(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
-
-      fail("syntaxError");
-    }
-
-    @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) {
-
-      if (tokenValidator.logLevel > 0) {
-        System.out.println("reportAmbiguity: ");
-        System.out.println(" ambigAlts: " + ambigAlts);
-        System.out.println(" configs: " + configs);
-        System.out.println(" input: " + recognizer.getTokenStream().getText(Interval.of(startIndex, stopIndex)));
-      }
-
-      if (!tokenValidator.allowAmbiguity) {
-        printStack(recognizer);
-        fail("reportAmbiguity");
-      }
-    }
-
-    @Override
-    public void reportAttemptingFullContext(final Parser recognizer, final DFA dfa, final int startIndex,
-        final int stopIndex,
-        final BitSet conflictingAlts, final ATNConfigSet configs) {
-
-      // The grammar should be written in order to avoid attempting a full context parse because its negative
-      // impact on the performance, so trace and stop here
-      if (tokenValidator.logLevel > 0) {
-        System.out.println("allowed AttemptingFullContext");
-      }
-
-      if (!tokenValidator.allowFullContext) {
-        printStack(recognizer);
-        fail("reportAttemptingFullContext");
-      }
-    }
-
-    @Override
-    public void reportContextSensitivity(final Parser recognizer, final DFA dfa, final int startIndex,
-        final int stopIndex, final int prediction,
-        final ATNConfigSet configs) {
-
-      if (tokenValidator.logLevel > 0) {
-        System.out.println("allowed ContextSensitivity");
-      }
-
-      if (!tokenValidator.allowContextSensitifity) {
-        printStack(recognizer);
-        fail("reportContextSensitivity");
-      }
-    }
-
-    /*
-     * private void printStack(final Parser recognizer) {
-     * List<String> stack = ((Parser) recognizer).getRuleInvocationStack();
-     * Collections.reverse(stack);
-     * 
-     * System.out.println(" Rule stack: " + stack);
-     * }
-     */
-    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.err.println("-");
-      // TODO check also http://stackoverflow.com/questions/14747952/ll-exact-ambig-detection-interpetation
-
-      printStack(recognizer);
-
-      if (e != null && e.getOffendingToken() != null) {
-
-        //String lexerTokenName = TestSuiteLexer.tokenNames[e.getOffendingToken().getType()];
-        String lexerTokenName = "";
-        try {
-          lexerTokenName = UriLexer.tokenNames[e.getOffendingToken().getType()];
-        } catch (ArrayIndexOutOfBoundsException es) {
-          lexerTokenName = "token error";
-        }
-        System.err.println(" line " + line + ":" + charPositionInLine + " at " +
-            offendingSymbol + "/" + lexerTokenName + ": " + msg);
-      } else {
-        System.err.println(" line " + line + ":" + charPositionInLine + " at " + offendingSymbol + ": " + msg);
-      }
-    }
-
-  }
-
-  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;
-  }
-
-  public ParserValidator lexerLog(final int i) {
-    lexerLogLevel = i;
-    return this;
-  }
-
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/7955eadf/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/TokenValidator.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/TokenValidator.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/TokenValidator.java
index 6140a0c..3e3b2fa 100644
--- a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/TokenValidator.java
+++ b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/TokenValidator.java
@@ -19,36 +19,37 @@
 package org.apache.olingo.odata4.producer.core.testutil;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
 
-import java.util.ArrayList;
-import java.util.BitSet;
 import java.util.List;
 
-import org.antlr.v4.runtime.ANTLRErrorListener;
 import org.antlr.v4.runtime.ANTLRInputStream;
-import org.antlr.v4.runtime.CharStream;
-import org.antlr.v4.runtime.Parser;
-import org.antlr.v4.runtime.RecognitionException;
-import org.antlr.v4.runtime.Recognizer;
 import org.antlr.v4.runtime.Token;
-import org.antlr.v4.runtime.atn.ATNConfigSet;
-import org.antlr.v4.runtime.dfa.DFA;
 import org.apache.olingo.odata4.producer.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 List<Exception> exceptions = new ArrayList<Exception>();
   private Token curToken = null;
   private Exception curException = null;
-  private String input = null;
+
+  private int startMode;
   private int logLevel = 0;
-  private int mode;
+
+  // --- Setup ---
+
+  public TokenValidator log(final int logLevel) {
+    this.logLevel = logLevel;
+    return this;
+  }
+
+  // --- Execution ---
 
   public TokenValidator run(final String uri) {
     input = uri;
-    exceptions.clear();
+
     tokens = parseInput(uri);
     if (logLevel > 0) {
       showTokens();
@@ -57,43 +58,11 @@ public class TokenValidator {
     first();
     exFirst();
     logLevel = 0;
-    return this;
-  }
-
-  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;
-  }
 
-  public TokenValidator setLog(final int logLevel) {
-    this.logLevel = logLevel;
     return this;
   }
 
-  private List<? extends Token> parseInput(final String input) {
-    ANTLRInputStream inputStream = new ANTLRInputStream(input);
-
-    UriLexer lexer = new UriLexerWithTrace(inputStream, logLevel, mode);
-    lexer.addErrorListener(new ErrorCollector(this));
-    return lexer.getAllTokens();
-  }
+  // --- Navigation ---
 
   // navigate within the tokenlist
   public TokenValidator first() {
@@ -120,14 +89,14 @@ public class TokenValidator {
   }
 
   public TokenValidator exLast() {
-    curException = exceptions.get(exceptions.size() - 1);
+    //curException = exceptions.get(exceptions.size() - 1);
     return this;
   }
 
   // navigate within the exception list
   public TokenValidator exFirst() {
     try {
-      curException = exceptions.get(0);
+      //curException = exceptions.get(0);
     } catch (IndexOutOfBoundsException ex) {
       curException = null;
     }
@@ -137,14 +106,15 @@ public class TokenValidator {
 
   public TokenValidator exAt(final int index) {
     try {
-      curException = exceptions.get(index);
+      //curException = exceptions.get(index);
     } catch (IndexOutOfBoundsException ex) {
       curException = null;
     }
     return this;
   }
 
-  // test functions
+  // --- Validation ---
+  
   public TokenValidator isText(final String expected) {
     assertEquals(expected, curToken.getText());
     return this;
@@ -185,46 +155,40 @@ public class TokenValidator {
     return this;
   }
 
-  // TODO create ErrorCollector for both ParserValidator and LexerValidator
-  private static class ErrorCollector implements ANTLRErrorListener {
-    TokenValidator tokenValidator;
-
-    public ErrorCollector(final TokenValidator tokenValidator) {
-      this.tokenValidator = tokenValidator;
-    }
-
-    @Override
-    public void syntaxError(final Recognizer<?, ?> recognizer, final Object offendingSymbol, final int line,
-        final int charPositionInLine,
-        final String msg, final RecognitionException e) {
-      tokenValidator.exceptions.add(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) {
-      fail("reportAmbiguity");
-    }
+  public void globalMode(final int mode) {
+    this.startMode = mode;
+  }
 
-    @Override
-    public void reportAttemptingFullContext(final Parser recognizer, final DFA dfa, final int startIndex,
-        final int stopIndex,
-        final BitSet conflictingAlts, final ATNConfigSet configs) {
-      fail("reportAttemptingFullContext");
-    }
+  // --- Helper ---
 
-    @Override
-    public void reportContextSensitivity(final Parser recognizer, final DFA dfa, final int startIndex,
-        final int stopIndex, final int prediction,
-        final ATNConfigSet configs) {
-      fail("reportContextSensitivity");
-    }
+  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 void globalMode(final int mode) {
-    this.mode = mode;
+  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;
   }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/7955eadf/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/TokenWriter.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/TokenWriter.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/TokenWriter.java
deleted file mode 100644
index ee9efbd..0000000
--- a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/TokenWriter.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * L icensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.odata4.producer.core.testutil;
-
-import org.antlr.v4.runtime.ParserRuleContext;
-import org.antlr.v4.runtime.tree.ErrorNode;
-import org.antlr.v4.runtime.tree.ParseTreeListener;
-import org.antlr.v4.runtime.tree.TerminalNode;
-
-public class TokenWriter implements ParseTreeListener {
-
-  @Override
-  public void visitTerminal(final TerminalNode node) {
-    /*
-     * String out = String.format("%1$-" + 20 + "s", node.getText()); ;
-     * int tokenType = node.getSymbol().getType();
-     * if (tokenType == -1 ) {
-     * out += "-1/EOF";
-     * } else {
-     * out += UriLexer.tokenNames[tokenType];
-     * }
-     * System.out.println(out);
-     */
-  }
-
-  @Override
-  public void visitErrorNode(final ErrorNode node) {
-    // TODO Auto-generated method stub
-
-  }
-
-  @Override
-  public void enterEveryRule(final ParserRuleContext ctx) {
-    // TODO Auto-generated method stub
-
-  }
-
-  @Override
-  public void exitEveryRule(final ParserRuleContext ctx) {
-    // TODO Auto-generated method stub
-
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/7955eadf/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriLexerWithTrace.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriLexerWithTrace.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriLexerWithTrace.java
index c333b6c..463ac34 100644
--- a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriLexerWithTrace.java
+++ b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriLexerWithTrace.java
@@ -64,7 +64,7 @@ public class UriLexerWithTrace extends UriLexer{
     out += UriLexer.modeNames[_mode];
 
     if (logLevel > 1) {
-      System.out.print(out + "            ");
+      System.out.println(out + "            ");
     }
   }
 
@@ -78,7 +78,7 @@ public class UriLexerWithTrace extends UriLexer{
     out += UriLexer.modeNames[_mode];
 
     if (logLevel > 1) {
-      System.out.print(out + "            ");
+      System.out.println(out + "            ");
     }
 
     return m;

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/7955eadf/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriResourcePathValidator.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriResourcePathValidator.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriResourcePathValidator.java
index d3f6060..0aa9761 100644
--- a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriResourcePathValidator.java
+++ b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriResourcePathValidator.java
@@ -28,102 +28,135 @@ import org.apache.olingo.odata4.commons.api.edm.Edm;
 import org.apache.olingo.odata4.commons.api.edm.EdmElement;
 import org.apache.olingo.odata4.commons.api.edm.EdmType;
 import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
+import org.apache.olingo.odata4.producer.api.uri.UriInfo;
 import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
-import org.apache.olingo.odata4.producer.api.uri.UriPathInfoKind;
+import org.apache.olingo.odata4.producer.api.uri.UriInfoResource;
+import org.apache.olingo.odata4.producer.api.uri.UriParameter;
+import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
+import org.apache.olingo.odata4.producer.api.uri.queryoption.CustomQueryOption;
+import org.apache.olingo.odata4.producer.core.uri.ParserAdapter;
 import org.apache.olingo.odata4.producer.core.uri.UriInfoImpl;
-import org.apache.olingo.odata4.producer.core.uri.UriInfoImplPath;
-import org.apache.olingo.odata4.producer.core.uri.UriKeyPredicateList;
 import org.apache.olingo.odata4.producer.core.uri.UriParserException;
-import org.apache.olingo.odata4.producer.core.uri.UriParserImpl;
-import org.apache.olingo.odata4.producer.core.uri.UriPathInfoImpl;
-import org.apache.olingo.odata4.producer.core.uri.UriPathInfoEntitySetImpl;
-import org.apache.olingo.odata4.producer.core.uri.expression.ExceptionVisitExpression;
-import org.apache.olingo.odata4.producer.core.uri.expression.Expression;
-
-public class UriResourcePathValidator {
+import org.apache.olingo.odata4.producer.core.uri.UriResourceComplexPropertyImpl;
+import org.apache.olingo.odata4.producer.core.uri.UriResourceFunctionImpl;
+import org.apache.olingo.odata4.producer.core.uri.UriResourceImplKeyPred;
+import org.apache.olingo.odata4.producer.core.uri.UriResourceImplTyped;
+import org.apache.olingo.odata4.producer.core.uri.UriResourceNavigationPropertyImpl;
+import org.apache.olingo.odata4.producer.core.uri.UriResourcePartImpl;
+import org.apache.olingo.odata4.producer.core.uri.UriResourceEntitySetImpl;
+import org.apache.olingo.odata4.producer.core.uri.UriParseTreeVisitor;
+import org.apache.olingo.odata4.producer.core.uri.UriResourcePropertyImpl;
+import org.apache.olingo.odata4.producer.core.uri.queryoption.CustomQueryOptionImpl;
+import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExceptionVisitExpression;
+import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExpressionImpl;
+
+public class UriResourcePathValidator implements Validator {
   private Edm edm;
-  // this validator can only be used on resourcePaths
-  public UriInfoImplPath uriInfo = null;
-  private UriPathInfoImpl uriPathInfo = null;
+  private Validator invokedBy;
+  private UriInfo uriInfo = null;
+
+  private UriResourcePartImpl uriPathInfo = null;
+
+  // --- Setup ---
+
+  public UriResourcePathValidator setUriValidator(UriValidator uriValidator) {
+    invokedBy = uriValidator;
+    return this;
+  }
+
+  public UriResourcePathValidator setEdm(final Edm edm) {
+    this.edm = edm;
+    return this;
+  }
+
+  public UriResourcePathValidator setUriInfoImplPath(UriInfoImpl uriInfoPath) {
+    this.uriInfo = uriInfoPath;
+    last();
+    return this;
+  }
+
+  // --- Execution ---
 
   public UriResourcePathValidator run(String uri) {
     UriInfoImpl uriInfoTmp = null;
     uriPathInfo = null;
     try {
-      uriInfoTmp = new UriParserImpl(edm).ParseUri(uri);
+      uriInfoTmp = ParserAdapter.parseUri(uri, new UriParseTreeVisitor(edm));
     } catch (UriParserException e) {
       fail("Exception occured while parsing the URI: " + uri + "\n"
           + " Exception: " + e.getMessage());
     }
 
-    if (!(uriInfoTmp instanceof UriInfoImplPath)) {
+    if (uriInfoTmp.getKind() != UriInfoKind.resource) {
       fail("Validator can only be used on resourcePaths");
     }
-    this.uriInfo = (UriInfoImplPath) uriInfoTmp;
+    this.uriInfo = uriInfoTmp;
 
-    last();
+    first();
     return this;
   }
-  
-  
-  // short cut which avoid adding the ESabc?$filter when testing filter to each URI
-  public FilterValidator runFilter(String filter) {
-    String uri = "ESabc?$filter=" + filter.trim(); // TODO check what to do with trailing spaces in the URI
-    this.run(uri);
-    return new FilterValidator(this);
-  }
-  
-  public UriResourcePathValidator setEdm(final Edm edm) {
-    this.edm = edm;
-    return this;
+
+  // --- Navigation ---
+
+  public UriValidator goUpUriValidator() {
+    return (UriValidator) invokedBy;
   }
 
-  // navigation for uriPathInfo
   public UriResourcePathValidator at(int index) {
     try {
-      uriPathInfo = uriInfo.getUriPathInfo(index);
+      uriPathInfo = (UriResourcePartImpl) uriInfo.getUriResourceParts().get(index);
     } catch (IndexOutOfBoundsException ex) {
-      uriPathInfo = null;
+      fail("not enought segemnts");
     }
-
     return this;
   }
 
   public UriResourcePathValidator first() {
     try {
-      uriPathInfo = ((UriInfoImplPath) uriInfo).getUriPathInfo(0);
+      uriPathInfo = (UriResourcePartImpl) uriInfo.getUriResourceParts().get(0);
     } catch (IndexOutOfBoundsException ex) {
-      uriPathInfo = null;
+      fail("not enought segemnts");
     }
     return this;
   }
 
   public UriResourcePathValidator last() {
-    if (uriInfo instanceof UriInfoImplPath) {
-      uriPathInfo = ((UriInfoImplPath) uriInfo).getLastUriPathInfo();
-    } else {
-      fail("UriInfo not instanceof UriInfoImplPath");
+    try {
+      uriPathInfo = (UriResourcePartImpl) uriInfo.getUriResourceParts().get(uriInfo.getUriResourceParts().size() - 1);
+    } catch (IndexOutOfBoundsException ex) {
+      fail("not enought segemnts");
     }
 
     return this;
   }
 
-  // check types
+  // --- Validation ---
+
+  public UriResourcePathValidator isTypeFilter(FullQualifiedName expectedType) {
+    
+    if (uriPathInfo.getKind() != UriResourceKind.complexProperty) {
+      fail("type wrong ujriResourceKind ( you may also check isTypeFilterOnEntry or isTypeFilterOnCollection");
+    } 
+    
+    EdmType actualType= ((UriResourceComplexPropertyImpl) uriPathInfo).getComplexTypeFilter();
 
-  public UriResourcePathValidator isInitialType(FullQualifiedName expectedType) {
-    EdmType actualType = uriPathInfo.getInitialType();
     if (actualType == null) {
-      fail("isInitialType: actualType == null");
+      fail("type information not set");
     }
 
-    FullQualifiedName actualTypeName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
+    FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
 
-    assertEquals(expectedType.toString(), actualTypeName.toString());
+    assertEquals(expectedType.toString(), actualName.toString());
     return this;
   }
 
   public UriResourcePathValidator isType(FullQualifiedName type) {
-    EdmType actualType = uriPathInfo.getType();
+    if (!(uriPathInfo instanceof UriResourceImplTyped)) {
+      fail("not typed");
+    }
+    UriResourceImplTyped uriPathInfoTyped = (UriResourceImplTyped) uriPathInfo;
+
+    EdmType actualType = uriPathInfoTyped.getType();
     if (actualType == null) {
       fail("type information not set");
     }
@@ -134,9 +167,14 @@ public class UriResourcePathValidator {
     return this;
   }
 
-  public UriResourcePathValidator isSingleTypeFilter(FullQualifiedName type) {
+  public UriResourcePathValidator isTypeFilterOnEntry(FullQualifiedName type) {
+    if (!(uriPathInfo instanceof UriResourceImplKeyPred)) {
+      fail("not typed");
+    }
+    UriResourceImplKeyPred uriPathInfoKeyPred = (UriResourceImplKeyPred) uriPathInfo;
+
     // input parameter type may be null in order to assert that the singleTypeFilter is not set
-    EdmType actualType = uriPathInfo.getSingleTypeFilter();
+    EdmType actualType = uriPathInfoKeyPred.getTypeFilterOnEntry();
     if (type == null) {
       assertEquals(type, actualType);
     } else {
@@ -146,9 +184,14 @@ public class UriResourcePathValidator {
     return this;
   }
 
-  public UriResourcePathValidator isCollectionTypeFilter(FullQualifiedName expectedType) {
+  public UriResourcePathValidator isTypeFilterOnCollection(FullQualifiedName expectedType) {
+    if (!(uriPathInfo instanceof UriResourceImplKeyPred)) {
+      fail("not typed");
+    }
+    UriResourceImplKeyPred uriPathInfoKeyPred = (UriResourceImplKeyPred) uriPathInfo;
+
     // input parameter type may be null in order to assert that the collectionTypeFilter is not set
-    EdmType actualType = uriPathInfo.getCollectionTypeFilter();
+    EdmType actualType = uriPathInfoKeyPred.getTypeFilterOnCollection();
     if (expectedType == null) {
       assertEquals(expectedType, actualType);
     } else {
@@ -160,27 +203,39 @@ public class UriResourcePathValidator {
   }
 
   // other functions
-  public UriResourcePathValidator hasQueryParameter(String parameter, int count) {
+  public UriResourcePathValidator checkCustomParameter(int index, String name, String value) {
     if (uriInfo == null) {
       fail("hasQueryParameter: uriInfo == null");
     }
 
-    int actualCount = uriInfo.getQueryParameters(parameter).size();
-    assertEquals(count, actualCount);
+    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 UriResourcePathValidator isCollection(boolean isCollection) {
-    EdmType type = uriPathInfo.getType();
+    if (!(uriPathInfo instanceof UriResourceImplTyped)) {
+      fail("not typed");
+    }
+    UriResourceImplTyped uriPathInfoTyped = (UriResourceImplTyped) uriPathInfo;
+
+    EdmType type = uriPathInfoTyped.getType();
     if (type == null) {
       fail("isCollection: type == null");
     }
-    assertEquals(isCollection, uriPathInfo.isCollection());
+    assertEquals(isCollection, uriPathInfoTyped.isCollection());
     return this;
   }
 
   public UriResourcePathValidator isFilterString(String expectedFilterTreeAsString) {
-    Expression filterTree = this.uriInfo.getFilter().getTree();
+
+    ExpressionImpl filterTree = (ExpressionImpl) this.uriInfo.getFilterOption().getExpression();
     try {
       String filterTreeAsString = filterTree.accept(new FilterTreeToText());
       assertEquals(expectedFilterTreeAsString, filterTreeAsString);
@@ -192,15 +247,15 @@ public class UriResourcePathValidator {
   }
 
   public UriResourcePathValidator isKeyPredicate(int index, String name, String value) {
-    if (!(uriPathInfo instanceof UriPathInfoEntitySetImpl)) {
-      //TODO add and "or" for FunctionImports 
+    if (!(uriPathInfo instanceof UriResourceEntitySetImpl)) {
+      // TODO add and "or" for FunctionImports
       fail("isKeyPredicate: uriPathInfo is not instanceof UriPathInfoEntitySetImpl");
     }
 
-    UriPathInfoEntitySetImpl info = (UriPathInfoEntitySetImpl) uriPathInfo;
-    UriKeyPredicateList keyPredicates = info.getKeyPredicates();
-    assertEquals(name, keyPredicates.getName(index));
-    assertEquals(value, keyPredicates.getValue(index));
+    UriResourceEntitySetImpl info = (UriResourceEntitySetImpl) uriPathInfo;
+    List<UriParameter> keyPredicates = info.getKeyPredicates();
+    assertEquals(name, keyPredicates.get(index).getName());
+    assertEquals(value, keyPredicates.get(index).getText());
     return this;
 
   }
@@ -210,39 +265,54 @@ public class UriResourcePathValidator {
     return this;
   }
 
-  public UriResourcePathValidator isProperties(List<String> asList) {
-    assertNotNull(uriPathInfo);
-
-    int index = 0;
-    while (index < asList.size()) {
-      String propertyName = uriPathInfo.getProperty(index).getName();
+  public UriResourcePathValidator isProperty(String name, FullQualifiedName type) {
+    if (!(uriPathInfo instanceof UriResourcePropertyImpl)) {
+      // TODO add and "or" for FunctionImports
+      fail("not a property");
+    }
 
-      assertEquals(asList.get(index), propertyName);
+    UriResourcePropertyImpl uriPathInfoProp = (UriResourcePropertyImpl) uriPathInfo;
 
-      index++;
-    }
+    EdmElement property = uriPathInfoProp.getProperty();
 
+    assertEquals(name, property.getName());
+    assertEquals(type, new FullQualifiedName(property.getType().getNamespace(), property.getType().getName()));
     return this;
   }
 
-  public UriResourcePathValidator isProperty(int index, String name, FullQualifiedName type) {
-    if (index >= uriPathInfo.getPropertyCount()) {
-      fail("isProperty: invalid index");
+  public UriResourcePathValidator isComplexProperty(int index, String name, FullQualifiedName type) {
+    if (!(uriPathInfo instanceof UriResourceComplexPropertyImpl)) {
+      // TODO add and "or" for FunctionImports
+      fail("not a property");
     }
 
-    EdmElement property = uriPathInfo.getProperty(index);
+    UriResourceComplexPropertyImpl uriPathInfoProp = (UriResourceComplexPropertyImpl) uriPathInfo;
+
+    EdmElement property = uriPathInfoProp.getProperty();
 
     assertEquals(name, property.getName());
     assertEquals(type, new FullQualifiedName(property.getType().getNamespace(), property.getType().getName()));
     return this;
   }
 
-  public UriResourcePathValidator isUriPathInfoKind(UriPathInfoKind infoType) {
+  public UriResourcePathValidator isUriPathInfoKind(UriResourceKind infoType) {
     assertNotNull(uriPathInfo);
     assertEquals(infoType, uriPathInfo.getKind());
     return this;
   }
 
-  
+  public UriResourcePathValidator isNav(String name, FullQualifiedName type) {
+    if (!(uriPathInfo instanceof UriResourceNavigationPropertyImpl)) {
+      // TODO add and "or" for FunctionImports
+      fail("not a property");
+    }
 
+    UriResourceNavigationPropertyImpl uriPathInfoProp = (UriResourceNavigationPropertyImpl) uriPathInfo;
+
+    EdmElement property = uriPathInfoProp.getNavigationProperty();
+
+    assertEquals(name, property.getName());
+    assertEquals(type, new FullQualifiedName(property.getType().getNamespace(), property.getType().getName()));
+    return this;
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/7955eadf/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriValidator.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriValidator.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriValidator.java
new file mode 100644
index 0000000..ed9413a
--- /dev/null
+++ b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriValidator.java
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata4.producer.core.testutil;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.List;
+
+import org.apache.olingo.odata4.commons.api.edm.Edm;
+import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
+import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
+import org.apache.olingo.odata4.producer.api.uri.queryoption.CustomQueryOption;
+import org.apache.olingo.odata4.producer.core.uri.ParserAdapter;
+import org.apache.olingo.odata4.producer.core.uri.UriInfoImpl;
+import org.apache.olingo.odata4.producer.core.uri.UriParseTreeVisitor;
+import org.apache.olingo.odata4.producer.core.uri.UriParserException;
+import org.apache.olingo.odata4.producer.core.uri.queryoption.CustomQueryOptionImpl;
+import org.apache.olingo.odata4.producer.core.uri.queryoption.FilterOptionImpl;
+
+public class UriValidator implements Validator {
+  private Edm edm;
+
+  private UriInfoImpl uriInfo;
+
+  // Setup
+  public UriValidator setEdm(final Edm edm) {
+    this.edm = edm;
+    return this;
+  }
+
+  // Execution
+  public UriValidator run(String uri) {
+    uriInfo = null;
+    try {
+      // uriInfoTmp = new UriParserImpl(edm).ParseUri(uri);
+      uriInfo = (UriInfoImpl) ParserAdapter.parseUri(uri, new UriParseTreeVisitor(edm));
+    } catch (UriParserException e) {
+      fail("Exception occured while parsing the URI: " + uri + "\n"
+          + " Exception: " + e.getMessage());
+    }
+
+    return this;
+  }
+
+  // Navigation
+  public UriResourcePathValidator goPath() {
+    if (uriInfo.getKind() != UriInfoKind.resource) {
+      fail("goPath can only be used on resourcePaths");
+    }
+
+    return new UriResourcePathValidator()
+        .setUriValidator(this)
+        .setEdm(edm)
+        .setUriInfoImplPath(uriInfo);
+  }
+
+  public FilterValidator goFilter(int index) {
+    FilterOptionImpl filter = (FilterOptionImpl) uriInfo.getFilterOption();
+    if (filter == null) {
+      fail("no filter found");
+    }
+    return new FilterValidator().setUriValidator(this).setFilter(filter);
+
+  }
+
+  // Validation
+  public UriValidator isKind(UriInfoKind kind) {
+    assertEquals(kind, uriInfo.getKind());
+    return this;
+  }
+
+  public UriValidator isCustomParameter(int index, String name, 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(List<String> entitySets) {
+    if (uriInfo.getKind() != UriInfoKind.crossjoin) {
+      fail("isKeyPredicate: uriPathInfo is not instanceof UriInfoImplCrossjoin");
+    }
+
+    int i = 0;
+    for (String entitySet : entitySets) {
+      assertEquals(entitySet, uriInfo.getEntitySetNames().get(i));
+      i++;
+    }
+
+  }
+
+  public UriValidator isSQO_Id(String text) {
+    assertEquals(text, uriInfo.getIdOption().getText());
+    return this;
+  }
+
+  public UriValidator isSQO_Format(String text) {
+    assertEquals(text, uriInfo.getFormatOption().getText());
+    return this;
+  }
+
+  public UriValidator isEntityType(FullQualifiedName nameetbase) {
+    if (uriInfo.getKind() != UriInfoKind.entityId) {
+      fail("isKeyPredicate: uriPathInfo is not instanceof UriInfoImplCrossjoin");
+    }
+ 
+    assertEquals(nameetbase.toString(), uriInfo.getEntityTypeCast().toString()); 
+    return this;
+  }
+  
+  
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/7955eadf/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/Validator.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/Validator.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/Validator.java
new file mode 100644
index 0000000..11706a6
--- /dev/null
+++ b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/Validator.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.odata4.producer.core.testutil;
+
+public interface Validator {
+
+}