Repository: olingo-odata4
Updated Branches:
  refs/heads/OLINGO-834_RefactorUriParsing [created] 927ecb93e


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/927ecb93/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
----------------------------------------------------------------------
diff --git 
a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
 
b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
index 9011bc4..e6612ff 100644
--- 
a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
+++ 
b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
@@ -28,7 +28,6 @@ import org.apache.olingo.server.api.edmx.EdmxReference;
 import org.apache.olingo.server.api.uri.UriInfoKind;
 import org.apache.olingo.server.api.uri.UriResourceKind;
 import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
-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.testutil.FilterValidator;
@@ -186,11 +185,11 @@ public class TestUriParserImpl {
     .isType(EntityTypeProvider.nameETTwoKeyTwoPrim, false);
 
     testUri.runEx(ContainerProvider.AIRT_STRING + "/invalidElement")
-        
.isExSemantic(UriParserSemanticException.MessageKeys.RESOURCE_PART_ONLY_FOR_TYPED_PARTS);
+        
.isExValidation(UriValidationException.MessageKeys.UNALLOWED_RESOURCE_PATH);
   }
 
   @Test
-  public void runCount() {
+  public void count() {
 
     // count entity set
     testRes.run("ESAllPrim/$count")
@@ -338,7 +337,7 @@ public class TestUriParserImpl {
     .isKeyPredicate(0, "PropertyInt16", "1");
 
     // with two keys
-    testRes.run("ESTwoKeyTwoPrim(PropertyInt16=1, PropertyString='ABC')")
+    testRes.run("ESTwoKeyTwoPrim(PropertyInt16=1,PropertyString='ABC')")
     .isEntitySet("ESTwoKeyTwoPrim")
     .isKeyPredicate(0, "PropertyInt16", "1")
     .isKeyPredicate(1, "PropertyString", "'ABC'");
@@ -562,14 +561,14 @@ public class TestUriParserImpl {
   }
 
   @Test
-  public void testUnary() throws UriParserException {
+  public void unary() throws Exception {
     testFilter.runOnETAllPrim("not PropertyBoolean").isCompr("<not 
<PropertyBoolean>>");
     testFilter.runOnETAllPrim("- PropertyInt16 eq PropertyInt16").isCompr("<<- 
<PropertyInt16>> eq <PropertyInt16>>");
     testFilter.runOnETAllPrim("-PropertyInt16 eq PropertyInt16").isCompr("<<- 
<PropertyInt16>> eq <PropertyInt16>>");
   }
 
   @Test
-  public void testFilterComplexMixedPriority() throws UriParserException {
+  public void filterComplexMixedPriority() throws Exception {
     testFilter.runOnETAllPrim("PropertyInt16 or PropertyInt32 and 
PropertyInt64")
         .isCompr("<<PropertyInt16> or <<PropertyInt32> and <PropertyInt64>>>");
     testFilter.runOnETAllPrim("PropertyInt16 or PropertyInt32 and 
PropertyInt64 eq PropertyByte")
@@ -594,7 +593,7 @@ public class TestUriParserImpl {
   }
 
   @Test
-  public void testFilterSimpleSameBinaryBinaryBinaryPriority() throws 
UriParserException {
+  public void filterSimpleSameBinaryBinaryBinaryPriority() throws Exception {
     testFilter.runOnETAllPrim("1 add 2 add 3 add 4").isCompr("<<< <1> add   
<2>> add  <3>>  add <4>>");
     testFilter.runOnETAllPrim("1 add 2 add 3 div 4").isCompr("<<  <1> add   
<2>> add <<3>   div <4>>>");
     testFilter.runOnETAllPrim("1 add 2 div 3 add 4").isCompr("<<  <1> add  
<<2>  div  <3>>> add <4>>");
@@ -1101,7 +1100,7 @@ public class TestUriParserImpl {
   }
 
   @Test
-  public void testGeo() throws UriParserException {
+  public void geo() throws Exception {
     testFilter.runOnETAllPrim("geo.distance(PropertySByte,PropertySByte)")
     .is("<geo.distance(<PropertySByte>,<PropertySByte>)>")
     .isMethod(MethodKind.GEODISTANCE, 2);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/927ecb93/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/ParserTest.java
----------------------------------------------------------------------
diff --git 
a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/ParserTest.java
 
b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/ParserTest.java
index 3d67c48..f54ad04 100644
--- 
a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/ParserTest.java
+++ 
b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/ParserTest.java
@@ -55,7 +55,7 @@ public class ParserTest {
     EdmEntityType productsType = Mockito.mock(EdmEntityType.class);
 
     final FullQualifiedName nameProducts = new FullQualifiedName("NS", 
"Products");
-    Mockito.when(mockEdm.getEntityContainer(null)).thenReturn(container);
+    Mockito.when(mockEdm.getEntityContainer()).thenReturn(container);
     Mockito.when(typeCategory.getName()).thenReturn("Category");
     Mockito.when(typeCategory.getNamespace()).thenReturn("NS");
     Mockito.when(esCategory.getEntityType()).thenReturn(typeCategory);
@@ -97,7 +97,7 @@ public class ParserTest {
     EdmEntityType typeProduct = Mockito.mock(EdmEntityType.class);
     FullQualifiedName fqnProduct = new FullQualifiedName("NS", "Products");
 
-    Mockito.when(mockEdm.getEntityContainer(null)).thenReturn(container);
+    Mockito.when(mockEdm.getEntityContainer()).thenReturn(container);
     Mockito.when(typeCategory.getName()).thenReturn(fqnCategory.getName());
     
Mockito.when(typeCategory.getNamespace()).thenReturn(fqnCategory.getNamespace());
     Mockito.when(typeCategory.getFullQualifiedName()).thenReturn(fqnCategory);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/927ecb93/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java
----------------------------------------------------------------------
diff --git 
a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java
 
b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java
index 309a25f..0800dd0 100644
--- 
a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java
+++ 
b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java
@@ -28,7 +28,9 @@ import java.util.List;
 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.OData;
 import org.apache.olingo.server.api.ODataApplicationException;
+import org.apache.olingo.server.api.ODataLibraryException;
 import org.apache.olingo.server.api.uri.UriInfo;
 import org.apache.olingo.server.api.uri.UriInfoKind;
 import org.apache.olingo.server.api.uri.UriResource;
@@ -51,8 +53,10 @@ 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.expression.MemberImpl;
 import org.apache.olingo.server.core.uri.queryoption.expression.MethodImpl;
+import org.apache.olingo.server.core.uri.validator.UriValidationException;
 
 public class FilterValidator implements TestValidator {
+  private final OData odata = OData.newInstance();
   private Edm edm;
 
   private TestValidator invokedByValidator;
@@ -62,7 +66,7 @@ public class FilterValidator implements TestValidator {
   private Expression curExpression;
   private Expression rootExpression;
 
-  private UriParserException exception;
+  private ODataLibraryException exception;
 
   // --- Setup ---
   public FilterValidator setUriResourcePathValidator(final ResourceValidator 
uriResourcePathValidator) {
@@ -107,15 +111,18 @@ public class FilterValidator implements TestValidator {
 
   // --- Execution ---
 
-  public FilterValidator runOrderByOnETAllPrim(final String orderBy) throws 
UriParserException {
+  public FilterValidator runOrderByOnETAllPrim(final String orderBy)
+      throws UriParserException, UriValidationException {
     return runUriOrderBy("ESAllPrim", "$orderby=" + orderBy.trim());
   }
 
-  public FilterValidator runOrderByOnETTwoKeyNav(final String orderBy) throws 
UriParserException {
+  public FilterValidator runOrderByOnETTwoKeyNav(final String orderBy)
+      throws UriParserException, UriValidationException {
     return runUriOrderBy("ESTwoKeyNav", "$orderby=" + orderBy.trim());
   }
 
-  public FilterValidator runOrderByOnETMixEnumDefCollComp(final String 
orderBy) throws UriParserException {
+  public FilterValidator runOrderByOnETMixEnumDefCollComp(final String orderBy)
+      throws UriParserException, UriValidationException {
     return runUriOrderBy("ESMixEnumDefCollComp", "$orderby=" + orderBy.trim());
   }
 
@@ -123,15 +130,17 @@ public class FilterValidator implements TestValidator {
     return runUriOrderByEx("ESTwoKeyNav", "$orderby=" + orderBy.trim());
   }
 
-  public FilterValidator runOnETTwoKeyNav(final String filter) throws 
UriParserException {
+  public FilterValidator runOnETTwoKeyNav(final String filter) throws 
UriParserException, UriValidationException {
     return runUri("ESTwoKeyNav", "$filter=" + filter.trim());
   }
 
-  public FilterValidator runOnETMixEnumDefCollComp(final String filter) throws 
UriParserException {
+  public FilterValidator runOnETMixEnumDefCollComp(final String filter)
+      throws UriParserException, UriValidationException {
     return runUri("ESMixEnumDefCollComp", "$filter=" + filter.trim());
   }
 
-  public FilterValidator runOnETTwoKeyNavSingle(final String filter) throws 
UriParserException {
+  public FilterValidator runOnETTwoKeyNavSingle(final String filter)
+      throws UriParserException, UriValidationException {
     return runUri("SINav", "$filter=" + filter.trim());
   }
 
@@ -139,11 +148,11 @@ public class FilterValidator implements TestValidator {
     return runUriEx("ESTwoKeyNav", "$filter=" + filter.trim());
   }
 
-  public FilterValidator runOnETAllPrim(final String filter) throws 
UriParserException {
+  public FilterValidator runOnETAllPrim(final String filter) throws 
UriParserException, UriValidationException {
     return runUri("ESAllPrim(1)", "$filter=" + filter.trim());
   }
 
-  public FilterValidator runOnETKeyNav(final String filter) throws 
UriParserException {
+  public FilterValidator runOnETKeyNav(final String filter) throws 
UriParserException, UriValidationException {
     return runUri("ESKeyNav(1)", "$filter=" + filter.trim());
   }
 
@@ -151,35 +160,36 @@ public class FilterValidator implements TestValidator {
     return runUriEx("ESKeyNav(1)", "$filter=" + filter.trim());
   }
 
-  public FilterValidator runOnCTTwoPrim(final String filter) throws 
UriParserException {
+  public FilterValidator runOnCTTwoPrim(final String filter) throws 
UriParserException, UriValidationException {
     return runUri("SINav/PropertyCompTwoPrim", "$filter=" + filter.trim());
   }
 
-  public FilterValidator runOnString(final String filter) throws 
UriParserException {
+  public FilterValidator runOnString(final String filter) throws 
UriParserException, UriValidationException {
     return runUri("SINav/PropertyString", "$filter=" + filter.trim());
   }
 
-  public FilterValidator runOnInt32(final String filter) throws 
UriParserException {
+  public FilterValidator runOnInt32(final String filter) throws 
UriParserException, UriValidationException {
     return runUri("ESCollAllPrim(1)/CollPropertyInt32", "$filter=" + 
filter.trim());
   }
 
-  public FilterValidator runOnDateTimeOffset(final String filter) throws 
UriParserException {
+  public FilterValidator runOnDateTimeOffset(final String filter) throws 
UriParserException, UriValidationException {
     return runUri("ESCollAllPrim(1)/CollPropertyDateTimeOffset", "$filter=" + 
filter.trim());
   }
 
-  public FilterValidator runOnDuration(final String filter) throws 
UriParserException {
+  public FilterValidator runOnDuration(final String filter) throws 
UriParserException, UriValidationException {
     return runUri("ESCollAllPrim(1)/CollPropertyDuration", "$filter=" + 
filter.trim());
   }
 
-  public FilterValidator runOnTimeOfDay(final String filter) throws 
UriParserException {
+  public FilterValidator runOnTimeOfDay(final String filter) throws 
UriParserException, UriValidationException {
     return runUri("ESCollAllPrim(1)/CollPropertyTimeOfDay", "$filter=" + 
filter.trim());
   }
 
-  public FilterValidator runUri(final String path, final String query) throws 
UriParserException {
-    Parser parser = new Parser();
+  public FilterValidator runUri(final String path, final String query)
+      throws UriParserException, UriValidationException {
+    Parser parser = new Parser(edm, odata);
     UriInfo uriInfo = null;
 
-    uriInfo = parser.parseUri(path, query, null, edm);
+    uriInfo = parser.parseUri(path, query, null);
 
     if (uriInfo.getKind() != UriInfoKind.resource) {
       fail("Filtervalidator can only be used on resourcePaths");
@@ -193,19 +203,19 @@ public class FilterValidator implements TestValidator {
   public FilterValidator runUriEx(final String path, final String query) {
     exception = null;
     try {
-      new Parser().parseUri(path, query, null, edm);
+      new Parser(edm, odata).parseUri(path, query, null);
       fail("Expected exception not thrown.");
     } catch (final UriParserException e) {
       exception = e;
+    } catch (final UriValidationException e) {
+      exception = e;
     }
     return this;
   }
 
-  public FilterValidator runUriOrderBy(final String path, final String query) 
throws UriParserException {
-    Parser parser = new Parser();
-    UriInfo uriInfo = null;
-
-    uriInfo = parser.parseUri(path, query, null, edm);
+  public FilterValidator runUriOrderBy(final String path, final String query)
+      throws UriParserException, UriValidationException {
+    final UriInfo uriInfo = new Parser(edm, odata).parseUri(path, query, null);
 
     if (uriInfo.getKind() != UriInfoKind.resource) {
       fail("Filtervalidator can only be used on resourcePaths");
@@ -218,10 +228,12 @@ public class FilterValidator implements TestValidator {
   public FilterValidator runUriOrderByEx(final String path, final String 
query) {
     exception = null;
     try {
-      new Parser().parseUri(path, query, null, edm);
+      new Parser(edm, odata).parseUri(path, query, null);
       fail("Expected exception not thrown.");
     } catch (final UriParserException e) {
       exception = e;
+    } catch (final UriValidationException e) {
+      exception = e;
     }
     return this;
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/927ecb93/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserWithLogging.java
----------------------------------------------------------------------
diff --git 
a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserWithLogging.java
 
b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserWithLogging.java
index 6b2b0df..5ebc57e 100644
--- 
a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserWithLogging.java
+++ 
b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserWithLogging.java
@@ -20,6 +20,8 @@ package org.apache.olingo.server.core.uri.testutil;
 
 import org.antlr.v4.runtime.DefaultErrorStrategy;
 import org.antlr.v4.runtime.DiagnosticErrorListener;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.core.uri.antlr.UriParserParser;
 import org.apache.olingo.server.core.uri.parser.Parser;
 
@@ -27,7 +29,8 @@ public class ParserWithLogging extends Parser {
   TestErrorLogger errorCollector1;
   TestErrorLogger errorCollector2;
 
-  public ParserWithLogging() {
+  public ParserWithLogging(final Edm edm, final OData odata) {
+    super(edm, odata);
     errorCollector1 = new TestErrorLogger("Stage 1", 1);
     errorCollector2 = new TestErrorLogger("Stage 2", 1);
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/927ecb93/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java
----------------------------------------------------------------------
diff --git 
a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java
 
b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java
index 994b6b2..d70b204 100644
--- 
a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java
+++ 
b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java
@@ -30,6 +30,8 @@ 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.commons.api.http.HttpMethod;
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataLibraryException;
 import org.apache.olingo.server.api.uri.UriInfo;
 import org.apache.olingo.server.api.uri.UriInfoKind;
 import org.apache.olingo.server.api.uri.UriInfoResource;
@@ -50,11 +52,11 @@ import 
org.apache.olingo.server.api.uri.queryoption.ExpandOption;
 import org.apache.olingo.server.api.uri.queryoption.SelectItem;
 import org.apache.olingo.server.api.uri.queryoption.SelectOption;
 import org.apache.olingo.server.core.uri.UriResourceWithKeysImpl;
-import org.apache.olingo.server.core.uri.parser.UriParserException;
 import org.apache.olingo.server.core.uri.validator.UriValidationException;
 import org.apache.olingo.server.core.uri.validator.UriValidator;
 
 public class ResourceValidator implements TestValidator {
+  private final OData odata = OData.newInstance();
   private Edm edm;
   private TestValidator invokedBy;
   private UriInfo uriInfo = null;
@@ -83,13 +85,13 @@ public class ResourceValidator implements TestValidator {
   // --- Execution ---
 
   public ResourceValidator run(final String path) {
-    ParserWithLogging testParser = new ParserWithLogging();
+    ParserWithLogging testParser = new ParserWithLogging(edm, odata);
 
     UriInfo uriInfoTmp = null;
     uriPathInfo = null;
     try {
-      uriInfoTmp = testParser.parseUri(path, null, null, edm);
-    } catch (final UriParserException e) {
+      uriInfoTmp = testParser.parseUri(path, null, null);
+    } catch (final ODataLibraryException e) {
       fail("Exception occurred while parsing the URI: " + path + "\n"
           + " Message: " + e.getMessage());
     }
@@ -279,7 +281,8 @@ public class ResourceValidator implements TestValidator {
 
     // input parameter type may be null in order to assert that the 
collectionTypeFilter is not set
     EdmType actualType = uriPathInfoKeyPred.getTypeFilterOnCollection();
-    assertEquals(expectedType, expectedType == null ? actualType : 
actualType.getFullQualifiedName());
+    assertEquals(expectedType,
+        expectedType == null || actualType == null ? actualType : 
actualType.getFullQualifiedName());
 
     return this;
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/927ecb93/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java
----------------------------------------------------------------------
diff --git 
a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java
 
b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java
index 0d5fb4a..1dbe62b 100644
--- 
a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java
+++ 
b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java
@@ -28,6 +28,7 @@ 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.commons.api.http.HttpMethod;
+import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataLibraryException;
 import org.apache.olingo.server.api.uri.UriInfo;
 import org.apache.olingo.server.api.uri.UriInfoKind;
@@ -44,6 +45,7 @@ import 
org.apache.olingo.server.core.uri.validator.UriValidationException;
 import org.apache.olingo.server.core.uri.validator.UriValidator;
 
 public class TestUriValidator implements TestValidator {
+  private final OData odata = OData.newInstance();
   private Edm edm;
 
   private UriInfo uriInfo;
@@ -62,17 +64,14 @@ public class TestUriValidator implements TestValidator {
 
   public TestUriValidator run(final String path, final String query)
       throws UriParserException, UriValidationException {
-    Parser parser = new Parser();
-    UriValidator validator = new UriValidator();
-
-    uriInfo = parser.parseUri(path, query, null, edm);
-    validator.validate(uriInfo, HttpMethod.GET);
+    uriInfo = new Parser(edm, odata).parseUri(path, query, null);
+    new UriValidator().validate(uriInfo, HttpMethod.GET);
     return this;
   }
 
   public TestUriValidator run(final String path, final String query, final 
String fragment)
       throws UriParserException, UriValidationException {
-    uriInfo = new Parser().parseUri(path, query, fragment, edm);
+    uriInfo = new Parser(edm, odata).parseUri(path, query, fragment);
     new UriValidator().validate(uriInfo, HttpMethod.GET);
     return this;
   }
@@ -82,10 +81,9 @@ public class TestUriValidator implements TestValidator {
   }
 
   public TestUriValidator runEx(final String path, final String query) {
-    Parser parser = new Parser();
     uriInfo = null;
     try {
-      uriInfo = parser.parseUri(path, query, null, edm);
+      uriInfo = new Parser(edm, odata).parseUri(path, query, null);
       new UriValidator().validate(uriInfo, HttpMethod.GET);
       fail("Exception expected");
     } catch (UriParserException e) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/927ecb93/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java
----------------------------------------------------------------------
diff --git 
a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java
 
b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java
index 0e8b2e6..868f9b8 100644
--- 
a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java
+++ 
b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java
@@ -323,7 +323,8 @@ public class UriValidatorTest {
       { URI_ACTION_ES, QO_ID }
   };
 
-  private static final Edm edm = OData.newInstance().createServiceMetadata(
+  private static final OData odata = OData.newInstance();
+  private static final Edm edm = odata.createServiceMetadata(
       new EdmTechProvider(), Collections.<EdmxReference> emptyList()).getEdm();
 
   @Test
@@ -419,24 +420,24 @@ public class UriValidatorTest {
   public void checkKeys() throws Exception {
     final TestUriValidator testUri = new TestUriValidator().setEdm(edm);
 
-    testUri.run("ESTwoKeyNav(PropertyInt16=1, PropertyString='abc')");
+    testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='abc')");
 
-    testUri.runEx("ESTwoKeyNav(xxx=1, yyy='abc')")
+    testUri.runEx("ESTwoKeyNav(xxx=1,yyy='abc')")
         
.isExValidation(UriValidationException.MessageKeys.INVALID_KEY_PROPERTY);
     
testUri.runEx("ESCollAllPrim(null)").isExValidation(UriValidationException.MessageKeys.INVALID_KEY_PROPERTY);
     testUri.runEx("ESAllPrim(PropertyInt16='1')")
-        
.isExValidation(UriValidationException.MessageKeys.INVALID_KEY_PROPERTY);
+        
.isExSemantic(UriParserSemanticException.MessageKeys.INVALID_KEY_VALUE);
     testUri.runEx("ESAllPrim(12345678901234567890)")
         
.isExValidation(UriValidationException.MessageKeys.INVALID_KEY_PROPERTY);
     testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString=1)")
-        
.isExValidation(UriValidationException.MessageKeys.INVALID_KEY_PROPERTY);
+        
.isExSemantic(UriParserSemanticException.MessageKeys.INVALID_KEY_VALUE);
     testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyInt16=1)")
         
.isExValidation(UriValidationException.MessageKeys.DOUBLE_KEY_PROPERTY);
 
     testUri.runEx("ESAllPrim(0)/NavPropertyETTwoPrimMany(xxx=42)")
         
.isExValidation(UriValidationException.MessageKeys.INVALID_KEY_PROPERTY);
     testUri.runEx("ESAllPrim(0)/NavPropertyETTwoPrimMany(PropertyInt16='1')")
-        
.isExValidation(UriValidationException.MessageKeys.INVALID_KEY_PROPERTY);
+        
.isExSemantic(UriParserSemanticException.MessageKeys.INVALID_KEY_VALUE);
   }
 
   @Test
@@ -499,7 +500,7 @@ public class UriValidatorTest {
 
   private void validate(final String path, final String query, final 
HttpMethod method) {
     try {
-      new UriValidator().validate(new Parser().parseUri(path, query, null, 
edm), method);
+      new UriValidator().validate(new Parser(edm, odata).parseUri(path, query, 
null), method);
     } catch (final UriParserException e) {
       fail("Failed for uri: " + path + '?' + query);
     } catch (final UriValidationException e) {
@@ -510,7 +511,7 @@ public class UriValidatorTest {
   private void validateWrong(final String path, final String query, final 
HttpMethod method,
       final UriValidationException.MessageKeys expectedMessageKey) {
     try {
-      new UriValidator().validate(new Parser().parseUri(path, query, null, 
edm), method);
+      new UriValidator().validate(new Parser(edm, odata).parseUri(path, query, 
null), method);
       fail("Validation Exception not thrown: " + method + ' ' + path + '?' + 
query);
     } catch (final UriParserException e) {
       fail("Wrong Exception thrown: " + method + ' ' + path + '?' + query);

Reply via email to