olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject [1/2] git commit: [OLINGO-356] URIParser untit tests check error message key
Date Thu, 07 Aug 2014 13:39:10 GMT
Repository: olingo-odata4
Updated Branches:
  refs/heads/master d19afa013 -> 266c7b4ae


[OLINGO-356] URIParser untit tests check error message key


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

Branch: refs/heads/master
Commit: 9048d725a2f7d0c70064d897cf44300e490f078f
Parents: d19afa0
Author: Michael Bolz <michael.bolz@sap.com>
Authored: Thu Aug 7 13:31:50 2014 +0200
Committer: Michael Bolz <michael.bolz@sap.com>
Committed: Thu Aug 7 13:31:50 2014 +0200

----------------------------------------------------------------------
 .../server/core/uri/validator/UriValidator.java |   1 -
 .../core/uri/antlr/TestFullResourcePath.java    | 144 +++++++++++--------
 .../core/uri/antlr/TestUriParserImpl.java       |  13 +-
 .../core/uri/testutil/ExpandValidator.java      |  31 ++--
 .../core/uri/testutil/FilterValidator.java      |   6 +-
 .../core/uri/testutil/ResourceValidator.java    |   6 +-
 .../core/uri/testutil/TestUriValidator.java     |  44 +++---
 7 files changed, 136 insertions(+), 109 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9048d725/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java
b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java
index 0cbabbc..24c9462 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java
@@ -41,7 +41,6 @@ import org.apache.olingo.server.api.uri.UriResourceKind;
 import org.apache.olingo.server.api.uri.UriResourceNavigation;
 import org.apache.olingo.server.api.uri.UriResourcePartTyped;
 import org.apache.olingo.server.api.uri.UriResourceSingleton;
-import org.apache.olingo.server.api.uri.queryoption.CustomQueryOption;
 import org.apache.olingo.server.api.uri.queryoption.SystemQueryOption;
 import org.apache.olingo.server.api.uri.queryoption.SystemQueryOptionKind;
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9048d725/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
index 37da223..0238a20 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
@@ -28,6 +28,9 @@ import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitEx
 import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
 import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
 import org.apache.olingo.server.core.uri.parser.UriParserException;
+import org.apache.olingo.server.core.uri.parser.UriParserSemanticException;
+import org.apache.olingo.server.core.uri.parser.UriParserSyntaxException;
+import org.apache.olingo.server.core.uri.validator.UriValidationException;
 import org.apache.olingo.server.core.uri.testutil.EdmTechTestProvider;
 import org.apache.olingo.server.core.uri.testutil.FilterValidator;
 import org.apache.olingo.server.core.uri.testutil.ResourceValidator;
@@ -896,10 +899,11 @@ public class TestFullResourcePath {
 
   @Test
   public void runCrossjoinError() throws Exception {
-    testUri.runEx("$crossjoin").isExSyntax(0);
-    testUri.runEx("$crossjoin/error").isExSyntax(0);
-    testUri.runEx("$crossjoin()").isExSyntax(0);
-    // testUri.runEx("$crossjoin(ESKeyNav, ESTwoKeyNav)/invalid").isExSyntax(0);
+    testUri.runEx("$crossjoin").isExSyntax(UriParserSyntaxException.MessageKeys.TEST);
+    testUri.runEx("$crossjoin/error").isExSyntax(UriParserSyntaxException.MessageKeys.TEST);
+    testUri.runEx("$crossjoin()").isExSyntax(UriParserSyntaxException.MessageKeys.TEST);
+    // testUri.runEx("$crossjoin(ESKeyNav, ESTwoKeyNav)/invalid")
+    //     .isExSyntax(UriParserSyntaxException.MessageKeys.TEST);
   }
 
   @Test
@@ -942,43 +946,44 @@ public class TestFullResourcePath {
   @Test
   public void runEsNameError() {
 
-    testUri.runEx("ESAllPrim/$count/$ref").isExSemantic(0);
-    testUri.runEx("ESAllPrim/$ref/$count").isExSemantic(0);
-    testUri.runEx("ESAllPrim/$ref/invalid").isExSemantic(0);
-    testUri.runEx("ESAllPrim/$count/invalid").isExSemantic(0);
-    testUri.runEx("ESAllPrim(1)/whatever").isExSemantic(0);
-    // testUri.runEx("ESAllPrim(PropertyInt16='1')").isExSemantic(0);
-    testUri.runEx("ESAllPrim(PropertyInt16)").isExSemantic(0);
-    testUri.runEx("ESAllPrim(PropertyInt16=)").isExSyntax(0);
-    testUri.runEx("ESAllPrim(PropertyInt16=1,Invalid='1')").isExSemantic(0);
+    testUri.runEx("ESAllPrim/$count/$ref").isExSemantic(UriParserSemanticException.MessageKeys.TEST);
+    testUri.runEx("ESAllPrim/$ref/$count").isExSemantic(UriParserSemanticException.MessageKeys.TEST);
+    testUri.runEx("ESAllPrim/$ref/invalid").isExSemantic(UriParserSemanticException.MessageKeys.TEST);
+    testUri.runEx("ESAllPrim/$count/invalid").isExSemantic(UriParserSemanticException.MessageKeys.TEST);
+    testUri.runEx("ESAllPrim(1)/whatever").isExSemantic(UriParserSemanticException.MessageKeys.TEST);
+    // testUri.runEx("ESAllPrim(PropertyInt16='1')").isExSemantic(UriParserSemanticException.MessageKeys.TEST);
+    testUri.runEx("ESAllPrim(PropertyInt16)").isExSemantic(UriParserSemanticException.MessageKeys.TEST);
+    testUri.runEx("ESAllPrim(PropertyInt16=)").isExSyntax(UriParserSyntaxException.MessageKeys.TEST);
+    testUri.runEx("ESAllPrim(PropertyInt16=1,Invalid='1')").isExSemantic(UriParserSemanticException.MessageKeys.TEST);
 
     testUri.runEx("ETBaseTwoKeyTwoPrim/com.sap.odata.test1.ETBaseTwoKeyTwoPrim"
-        + "/com.sap.odata.test1.ETTwoBaseTwoKeyTwoPrim").isExSemantic(0);
+        + "/com.sap.odata.test1.ETTwoBaseTwoKeyTwoPrim").isExSemantic(UriParserSemanticException.MessageKeys.TEST);
 
     testUri.runEx("ETBaseTwoKeyTwoPrim/com.sap.odata.test1.ETBaseTwoKeyTwoPrim(1)/com.sap.odata.test1.ETAllKey")
-        .isExSemantic(0);
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
 
     testUri.runEx("ETBaseTwoKeyTwoPrim(1)/com.sap.odata.test1.ETBaseTwoKeyTwoPrim('1')/com.sap.odata.test1.ETAllKey")
-        .isExSemantic(0);
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
 
     testUri.runEx("ETBaseTwoKeyTwoPrim(1)/com.sap.odata.test1.ETBaseTwoKeyTwoPrim"
         + "/com.sap.odata.test1.ETTwoBaseTwoKeyTwoPrim")
-        .isExSemantic(0);
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
 
     testUri.runEx("ETBaseTwoKeyTwoPrim/com.sap.odata.test1.ETBaseTwoKeyTwoPrim"
         + "/com.sap.odata.test1.ETTwoBaseTwoKeyTwoPrim(1)")
-        .isExSemantic(0);
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
 
     testUri.runEx("ETBaseTwoKeyTwoPrim/com.sap.odata.test1.ETAllKey")
-        .isExSemantic(0);
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
 
     testUri.runEx("ETBaseTwoKeyTwoPrim()")
-        .isExSemantic(0);
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
 
     testUri.runEx("ESAllNullable(1)/CollPropertyString/$value")
-        .isExSemantic(0);
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
 
-    testUri.runEx("ETMixPrimCollComp(1)/ComplexProperty/$value").isExSemantic(0);
+    testUri.runEx("ETMixPrimCollComp(1)/ComplexProperty/$value")
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
   }
 
   @Test
@@ -1067,7 +1072,7 @@ public class TestFullResourcePath {
         .isKeyPredicate(2, "KeyAlias2", "'3'")
         .isKeyPredicate(3, "KeyAlias3", "'4'");
 
-    testUri.runEx("ESCollAllPrim(null)").isExValidation("");
+    testUri.runEx("ESCollAllPrim(null)").isExValidation(UriValidationException.MessageKeys.INVALID_KEY_PROPERTY);
   }
 
   @Test
@@ -1800,8 +1805,8 @@ public class TestFullResourcePath {
 
   @Test
   public void runFunctionImpError() {
-    testUri.runEx("FICRTCollCTTwoPrimParam()").isExSemantic(0);
-    testUri.runEx("FICRTCollCTTwoPrimParam(invalidParam=2)").isExSemantic(0);
+    testUri.runEx("FICRTCollCTTwoPrimParam()").isExSemantic(UriParserSemanticException.MessageKeys.TEST);
+    testUri.runEx("FICRTCollCTTwoPrimParam(invalidParam=2)").isExSemantic(UriParserSemanticException.MessageKeys.TEST);
   }
 
   @Test
@@ -2049,18 +2054,18 @@ public class TestFullResourcePath {
     testUri.run("ESKeyNav(1)?$expand=*")
         .isKind(UriInfoKind.resource).goPath().goExpand()
         .first()
-        .isSegmentStar(0);
+        .isSegmentStar();
 
     testUri.run("ESKeyNav(1)?$expand=*/$ref")
         .isKind(UriInfoKind.resource).goPath().goExpand()
         .first()
-        .isSegmentStar(0)
-        .isSegmentRef(1);
+        .isSegmentStar()
+        .isSegmentRef();
 
     testUri.run("ESKeyNav(1)?$expand=*/$ref,NavPropertyETKeyNavMany")
         .isKind(UriInfoKind.resource).goPath().goExpand()
         .first()
-        .isSegmentStar(0).isSegmentRef(1)
+        .isSegmentStar().isSegmentRef()
         .next()
         .goPath().first()
         .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true);
@@ -2068,13 +2073,13 @@ public class TestFullResourcePath {
     testUri.run("ESKeyNav(1)?$expand=*($levels=3)")
         .isKind(UriInfoKind.resource).goPath().goExpand()
         .first()
-        .isSegmentStar(0)
+        .isSegmentStar()
         .isLevelText("3");
 
     testUri.run("ESKeyNav(1)?$expand=*($levels=max)")
         .isKind(UriInfoKind.resource).goPath().goExpand()
         .first()
-        .isSegmentStar(0)
+        .isSegmentStar()
         .isLevelText("max");
 
     testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref")
@@ -2882,14 +2887,19 @@ public class TestFullResourcePath {
         .root().right()
         .isLiteral("'SomeString'");
 
-    testFilter.runOnETTwoKeyNavEx("invalid").isExSemantic(0);
-    testFilter.runOnETTwoKeyNavEx("PropertyComp/invalid").isExSemantic(0);
-    testFilter.runOnETTwoKeyNavEx("concat('a','b')/invalid").isExSyntax(0);
-    testFilter.runOnETTwoKeyNavEx("PropertyComp/concat('a','b')").isExSyntax(0);
-    testFilter.runOnETTwoKeyNavEx("PropertyCompAllPrim/PropertyInt16 eq '1'").isExSemantic(0);
-    testFilter.runOnETTwoKeyNavEx("PropertyCompAllPrim/PropertyDate eq 1").isExSemantic(0);
-    testFilter.runOnETTwoKeyNavEx("PropertyCompAllPrim/PropertyString eq 1").isExSemantic(0);
-    testFilter.runOnETTwoKeyNavEx("PropertyCompAllPrim/PropertyDate eq 1").isExSemantic(0);
+    testFilter.runOnETTwoKeyNavEx("invalid").isExSemantic(UriParserSemanticException.MessageKeys.TEST);
+    testFilter.runOnETTwoKeyNavEx("PropertyComp/invalid").isExSemantic(UriParserSemanticException.MessageKeys.TEST);
+    testFilter.runOnETTwoKeyNavEx("concat('a','b')/invalid").isExSyntax(UriParserSyntaxException.MessageKeys.TEST);
+    testFilter.runOnETTwoKeyNavEx("PropertyComp/concat('a','b')")
+        .isExSyntax(UriParserSyntaxException.MessageKeys.TEST);
+    testFilter.runOnETTwoKeyNavEx("PropertyCompAllPrim/PropertyInt16 eq '1'")
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
+    testFilter.runOnETTwoKeyNavEx("PropertyCompAllPrim/PropertyDate eq 1")
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
+    testFilter.runOnETTwoKeyNavEx("PropertyCompAllPrim/PropertyString eq 1")
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
+    testFilter.runOnETTwoKeyNavEx("PropertyCompAllPrim/PropertyDate eq 1")
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
 
     testFilter.runOnETAllPrim("PropertySByte eq PropertySByte")
         .is("<<PropertySByte> eq <PropertySByte>>")
@@ -4087,7 +4097,8 @@ public class TestFullResourcePath {
         .goUpFilterValidator().root()
         .goParameter(1).isTypedLiteral(EntityTypeProvider.nameETKeyPrimNav);
 
-    testFilter.runOnETKeyNavEx("cast(NavPropertyETKeyPrimNavOne,com.sap.odata.test1.ETKeyNav)").isExSemantic(0);
+    testFilter.runOnETKeyNavEx("cast(NavPropertyETKeyPrimNavOne,com.sap.odata.test1.ETKeyNav)")
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
     testFilter.runOnETKeyNav("any()")
         .isMember().goPath().first().isUriPathInfoKind(UriResourceKind.lambdaAny);
 
@@ -5000,10 +5011,14 @@ public class TestFullResourcePath {
         .goOrder(0).left().goPath().isComplex("PropertyEnumString").goUpFilterValidator()
         .goOrder(0).right().isEnum(EnumTypeProvider.nameENString, Arrays.asList("String1"));
 
-    testFilter.runOrderByOnETTwoKeyNavEx("PropertyInt16 1").isExSyntax(0);
-    testFilter.runOrderByOnETTwoKeyNavEx("PropertyInt16, PropertyInt32 PropertyDuration").isExSyntax(0);
-    testFilter.runOrderByOnETTwoKeyNavEx("PropertyInt16 PropertyInt32, PropertyDuration desc").isExSyntax(0);
-    testFilter.runOrderByOnETTwoKeyNavEx("PropertyInt16 asc, PropertyInt32 PropertyDuration
desc").isExSyntax(0);
+    testFilter.runOrderByOnETTwoKeyNavEx("PropertyInt16 1")
+        .isExSyntax(UriParserSyntaxException.MessageKeys.TEST);
+    testFilter.runOrderByOnETTwoKeyNavEx("PropertyInt16, PropertyInt32 PropertyDuration")
+        .isExSyntax(UriParserSyntaxException.MessageKeys.TEST);
+    testFilter.runOrderByOnETTwoKeyNavEx("PropertyInt16 PropertyInt32, PropertyDuration desc")
+        .isExSyntax(UriParserSyntaxException.MessageKeys.TEST);
+    testFilter.runOrderByOnETTwoKeyNavEx("PropertyInt16 asc, PropertyInt32 PropertyDuration
desc")
+        .isExSyntax(UriParserSyntaxException.MessageKeys.TEST);
   }
 
   @Test
@@ -5045,43 +5060,53 @@ public class TestFullResourcePath {
 
   @Test
   public void testErrors() {
-    testUri.runEx("FICRTString(wrong1='ABC')/com.sap.odata.test1.BFCStringRTESTwoKeyNav()").isExSemantic(0);
-    testUri.runEx("FICRTString(wrong1='ABC', wrong2=1)/com.sap.odata.test1.BFCStringRTESTwoKeyNav()").isExSemantic(0);
+    testUri.runEx("FICRTString(wrong1='ABC')/com.sap.odata.test1.BFCStringRTESTwoKeyNav()")
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
+    testUri.runEx("FICRTString(wrong1='ABC', wrong2=1)/com.sap.odata.test1.BFCStringRTESTwoKeyNav()")
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
 
     // type filter for entity incompatible
-    testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBase").isExSemantic(0);
+    testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBase")
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
 
     // type filter for entity double on entry
     testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')"
-        + "/com.sap.odata.test1.ETBaseTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav").isExSemantic(0);
+        + "/com.sap.odata.test1.ETBaseTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav")
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
     // type filter for entity double on collection
     testUri.runEx("ESTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav")
-        .isExSemantic(0);
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
     // type filter for entity double on non key pred
-    testUri.runEx("SINav/com.sap.odata.test1.ETBaseTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav").isExSemantic(0);
+    testUri.runEx("SINav/com.sap.odata.test1.ETBaseTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav")
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
 
     // type filter for complex incompatible
     testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyCompTwoPrim"
-        + "/com.sap.odata.test1.CTCollAllPrim").isExSemantic(0);
+        + "/com.sap.odata.test1.CTCollAllPrim").isExSemantic(UriParserSemanticException.MessageKeys.TEST);
 
     // type filter for complex double on entry
     testUri.runEx("FICRTCTTwoPrimParam(ParameterInt16=1,ParameterString='2')"
-        + "/com.sap.odata.test1.CTBase/com.sap.odata.test1.CTBase").isExSemantic(0);
+        + "/com.sap.odata.test1.CTBase/com.sap.odata.test1.CTBase")
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
 
     // type filter for complex double on collection
     testUri.runEx("FICRTCollCTTwoPrimParam(ParameterInt16=1,ParameterString='2')"
-        + "/com.sap.odata.test1.CTBase/com.sap.odata.test1.CTBase").isExSemantic(0);
+        + "/com.sap.odata.test1.CTBase/com.sap.odata.test1.CTBase")
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
 
     // type filter for complex double on non key pred
     testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyCompTwoPrim"
-        + "/com.sap.odata.test1.CTBase/com.sap.odata.test1.CTBase").isExSemantic(0);
+        + "/com.sap.odata.test1.CTBase/com.sap.odata.test1.CTBase")
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
 
-    testUri.runEx("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav").isExSemantic(0);
+    testUri.runEx("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav")
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
 
     // $ref
-    testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyCompTwoPrim/$ref").isExSemantic(0);
-    testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyCompTwoPrim/$count").isExSemantic(0);
-
+    testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyCompTwoPrim/$ref")
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
+    testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyCompTwoPrim/$count")
+        .isExSemantic(UriParserSemanticException.MessageKeys.TEST);
   }
 
   @Test
@@ -5092,12 +5117,9 @@ public class TestFullResourcePath {
         .isInAliasToValueMap("@A", "'2'")
         .goUpUriValidator()
         .isCustomParameter(0, "@A", "'2'");
-
   }
 
   public static String encode(final String decoded) throws UnsupportedEncodingException {
     return Encoder.encode(decoded);
-
   }
-
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9048d725/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 bd91666..e4f771b 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
@@ -18,6 +18,10 @@
  */
 package org.apache.olingo.server.core.uri.antlr;
 
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.Arrays;
+
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.server.api.uri.UriInfoKind;
@@ -25,6 +29,7 @@ import org.apache.olingo.server.api.uri.UriResourceKind;
 import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
 import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
 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.testutil.EdmTechTestProvider;
 import org.apache.olingo.server.core.uri.testutil.FilterValidator;
 import org.apache.olingo.server.core.uri.testutil.ResourceValidator;
@@ -35,10 +40,6 @@ import org.apache.olingo.server.tecsvc.provider.EntityTypeProvider;
 import org.apache.olingo.server.tecsvc.provider.PropertyProvider;
 import org.junit.Test;
 
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.Arrays;
-
 public class TestUriParserImpl {
   Edm edm = null;
   private final String PropertyBoolean = "PropertyBoolean=true";
@@ -188,7 +189,7 @@ public class TestUriParserImpl {
         .isAction("UARTETParam")
         .isType(EntityTypeProvider.nameETTwoKeyTwoPrim, false);
 
-    testUri.runEx("AIRTPrimParam/invalidElement").isExSemantic(0);
+    testUri.runEx("AIRTPrimParam/invalidElement").isExSemantic(UriParserSemanticException.MessageKeys.TEST);
   }
 
   @Test
@@ -316,7 +317,7 @@ public class TestUriParserImpl {
         .isEntityType(EntityTypeProvider.nameETBase)
         .isIdText("ESTwoPrim")
         .isExpandText("*")
-        .goExpand().first().isSegmentStar(0);
+        .goExpand().first().isSegmentStar();
 
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9048d725/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java
b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java
index 82b5853..d79dfd3 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java
@@ -24,16 +24,19 @@ import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.server.api.ODataApplicationException;
 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.FilterOption;
+import org.apache.olingo.server.api.uri.queryoption.QueryOption;
 import org.apache.olingo.server.api.uri.queryoption.SelectItem;
+import org.apache.olingo.server.api.uri.queryoption.SelectOption;
 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;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 public class ExpandValidator implements TestValidator {
@@ -127,19 +130,19 @@ public class ExpandValidator implements TestValidator {
     try {
       expandItem = expandOption.getExpandItems().get(expandItemIndex);
     } catch (IndexOutOfBoundsException ex) {
-      fail("not enought segments");
+      fail("not enough segments");
     }
     return this;
 
   }
 
-  public ExpandValidator isSegmentStar(final int index) {
-    assertEquals(true, expandItem.isStar());
+  public ExpandValidator isSegmentStar() {
+    assertTrue(expandItem.isStar());
     return this;
   }
 
-  public ExpandValidator isSegmentRef(final int index) {
-    assertEquals(true, expandItem.isRef());
+  public ExpandValidator isSegmentRef() {
+    assertTrue(expandItem.isRef());
     return this;
   }
 
@@ -174,38 +177,36 @@ public class ExpandValidator implements TestValidator {
   }
 
   public ExpandValidator isSelectItemStar(final int index) {
-    SelectOptionImpl select = (SelectOptionImpl) expandItem.getSelectOption();
-
+    SelectOption select = expandItem.getSelectOption();
     SelectItem item = select.getSelectItems().get(index);
-    assertEquals(true, item.isStar());
+    assertTrue(item.isStar());
     return this;
   }
 
   public ExpandValidator isSelectItemAllOperations(final int index, final FullQualifiedName
fqn) {
-    SelectOptionImpl select = (SelectOptionImpl) expandItem.getSelectOption();
-
+    SelectOption select = 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();
+    QueryOption option = expandItem.getFilterOption();
     assertEquals(text, option.getText());
     return this;
   }
 
   public ExpandValidator isFilterSerialized(final String serialized) {
-    FilterOptionImpl filter = (FilterOptionImpl) expandItem.getFilterOption();
+    FilterOption filter = expandItem.getFilterOption();
 
     try {
       String tmp = FilterTreeToText.Serialize(filter);
       assertEquals(serialized, tmp);
     } catch (ExpressionVisitException e) {
-      fail("Exception occured while converting the filterTree into text" + "\n"
+      fail("Exception occurred while converting the filterTree into text" + "\n"
           + " Exception: " + e.getMessage());
     } catch (ODataApplicationException e) {
-      fail("Exception occured while converting the filterTree into text" + "\n"
+      fail("Exception occurred while converting the filterTree into text" + "\n"
           + " Exception: " + e.getMessage());
     }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9048d725/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 ad8eeee..f20c7ea 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
@@ -491,13 +491,15 @@ public class FilterValidator implements TestValidator {
     return this;
   }
 
-  public FilterValidator isExSyntax(final long errorID) {
+  public FilterValidator isExSyntax(final UriParserSyntaxException.MessageKeys messageKey)
{
     assertEquals(UriParserSyntaxException.class, exception.getClass());
+    assertEquals(messageKey, exception.getMessageKey());
     return this;
   }
 
-  public FilterValidator isExSemantic(final long errorID) {
+  public FilterValidator isExSemantic(final UriParserSemanticException.MessageKeys messageKey)
{
     assertEquals(UriParserSemanticException.class, exception.getClass());
+    assertEquals(messageKey, exception.getMessageKey());
     return this;
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9048d725/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 0332c73..9095d39 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
@@ -76,7 +76,7 @@ public class ResourceValidator implements TestValidator {
     return this;
   }
 
-  public ResourceValidator setUriInfoImplPath(final UriInfoImpl uriInfoPath) {
+  public ResourceValidator setUriInfoImplPath(final UriInfo uriInfoPath) {
     uriInfo = uriInfoPath;
     last();
     return this;
@@ -87,10 +87,10 @@ public class ResourceValidator implements TestValidator {
   public ResourceValidator run(final String uri) {
     ParserWithLogging testParser = new ParserWithLogging();
 
-    UriInfoImpl uriInfoTmp = null;
+    UriInfo uriInfoTmp = null;
     uriPathInfo = null;
     try {
-      uriInfoTmp = (UriInfoImpl) testParser.parseUri(uri, edm);
+      uriInfoTmp = testParser.parseUri(uri, edm);
 
       UriValidator uriValidator = new UriValidator();
       uriValidator.validate(uriInfoTmp, HttpMethod.GET);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9048d725/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 300c8fc..f0407c1 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
@@ -18,11 +18,18 @@
  */
 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.commons.api.http.HttpMethod;
+import org.apache.olingo.server.api.ODataTranslatedException;
+import org.apache.olingo.server.api.uri.UriInfo;
 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;
@@ -38,16 +45,11 @@ import org.apache.olingo.server.core.uri.queryoption.SelectOptionImpl;
 import org.apache.olingo.server.core.uri.validator.UriValidationException;
 import org.apache.olingo.server.core.uri.validator.UriValidator;
 
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
 public class TestUriValidator implements TestValidator {
   private Edm edm;
 
-  private UriInfoImpl uriInfo;
-  private Exception exception;
+  private UriInfo uriInfo;
+  private ODataTranslatedException exception;
 
   // Setup
   public TestUriValidator setEdm(final Edm edm) {
@@ -60,8 +62,7 @@ public class TestUriValidator implements TestValidator {
     Parser parser = new Parser();
     UriValidator validator = new UriValidator();
 
-    uriInfo = null;
-    uriInfo = (UriInfoImpl) parser.parseUri(uri, edm);
+    uriInfo = parser.parseUri(uri, edm);
     validator.validate(uriInfo, HttpMethod.GET);
     return this;
   }
@@ -70,7 +71,7 @@ public class TestUriValidator implements TestValidator {
     Parser parser = new Parser();
     uriInfo = null;
     try {
-      uriInfo = (UriInfoImpl) parser.parseUri(uri, edm);
+      uriInfo = parser.parseUri(uri, edm);
       new UriValidator().validate(uriInfo, HttpMethod.GET);
       fail("Exception expected");
     } catch (UriParserException e) {
@@ -87,8 +88,7 @@ public class TestUriValidator implements TestValidator {
     parserTest.setLogLevel(1);
     uriInfo = null;
     try {
-      // uriInfoTmp = new UriParserImpl(edm).ParseUri(uri);
-      uriInfo = (UriInfoImpl) parserTest.parseUri(uri, edm);
+      uriInfo = parserTest.parseUri(uri, edm);
     } catch (UriParserException e) {
       fail("Exception occured while parsing the URI: " + uri + "\n"
           + " Exception: " + e.getMessage());
@@ -164,7 +164,7 @@ public class TestUriValidator implements TestValidator {
 
     List<CustomQueryOption> list = uriInfo.getCustomQueryOptions();
     if (list.size() <= index) {
-      fail("not enought queryParameters");
+      fail("not enough queryParameters");
     }
 
     CustomQueryOptionImpl option = (CustomQueryOptionImpl) list.get(index);
@@ -186,13 +186,21 @@ public class TestUriValidator implements TestValidator {
 
   }
 
-  public TestUriValidator isExSyntax(final long errorID) {
+  public TestUriValidator isExSyntax(final UriParserSyntaxException.MessageKeys messageKey)
{
     assertEquals(UriParserSyntaxException.class, exception.getClass());
+    assertEquals(messageKey, exception.getMessageKey());
     return this;
   }
 
-  public TestUriValidator isExSemantic(final long errorID) {
+  public TestUriValidator isExSemantic(final UriParserSemanticException.MessageKeys messageKey)
{
     assertEquals(UriParserSemanticException.class, exception.getClass());
+    assertEquals(messageKey, exception.getMessageKey());
+    return this;
+  }
+
+  public TestUriValidator isExValidation(final UriValidationException.MessageKeys messageKey)
{
+    assertEquals(UriValidationException.class, exception.getClass());
+    assertEquals(messageKey, exception.getMessageKey());
     return this;
   }
 
@@ -254,10 +262,4 @@ public class TestUriValidator implements TestValidator {
     assertEquals(fqn.toString(), item.getAllOperationsInSchemaNameSpace().toString());
     return this;
   }
-
-  public TestUriValidator isExValidation(String string) {
-    assertEquals(UriValidationException.class, exception.getClass());
-    return this;
-  }
-
 }


Mime
View raw message