You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2015/11/03 14:24:10 UTC

olingo-odata4 git commit: [OLINGO-801] Added tests for complex function parameters

Repository: olingo-odata4
Updated Branches:
  refs/heads/master 1831364aa -> 734ea9198


[OLINGO-801] Added tests for complex function parameters


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

Branch: refs/heads/master
Commit: 734ea919886a8c5b03d57afd4ab031f9d3c849a9
Parents: 1831364
Author: Christian Holzer <c....@sap.com>
Authored: Tue Nov 3 11:29:37 2015 +0100
Committer: Christian Holzer <c....@sap.com>
Committed: Tue Nov 3 14:18:08 2015 +0100

----------------------------------------------------------------------
 .../olingo/server/core/uri/antlr/UriParser.g4   |  8 ++--
 .../core/uri/antlr/TestFullResourcePath.java    | 48 ++++++++++++++++++--
 2 files changed, 47 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/734ea919/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriParser.g4
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriParser.g4 b/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriParser.g4
index dc1af2b..ff8994f 100644
--- a/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriParser.g4
+++ b/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriParser.g4
@@ -304,7 +304,7 @@ arrayOrObject       : json_array
 
 json_array          : BEGIN_ARRAY json_value ( WSP? COMMA WSP? json_value)* END_ARRAY;
 
-json_value          : jsonPrimitiv
+json_value          : jsonPrimitive
                     | rootExpr
                     | json_object
                     | json_array;
@@ -321,14 +321,14 @@ json_key_value_pair : STRING_IN_JSON
                       json_value;
                                         
 //; JSON syntax: adapted to URI restrictions from [RFC4627]                 
-jsonPrimitiv        : STRING_IN_JSON
+jsonPrimitive 		: STRING_IN_JSON
                     | number_in_json
                     | TRUE
                     | FALSE
-                    | 'null'
+                    | NULLVALUE
                     ;
 
-number_in_json          : INT | DECIMAL;
+number_in_json		: INT | DECIMAL;
 
 //;------------------------------------------------------------------------------
 //; 6. Names and identifiers

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/734ea919/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 d5d4257..6f1c4ad 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
@@ -5697,9 +5697,11 @@ public class TestFullResourcePath {
       .at(1).isFunction("BFCESTwoKeyNavRTStringParam").isParameterAlias(0, "ParameterComp", "@p1")
       .isInAliasToValueMap("@p1", "{\"PropertyInt16\":1,\"ProperyString\":\"1\"}");
     
-    // Test JSON String lexer rule =\"3,Int16=abc},\\\nabc&test%test\b\f\r\t\u0022}
-    final String stringValueEncoded = "=\\\"3,Int16=abc},\\\\\\nabc%26test%25test\\b\\f\\r\\t\\u0022}";
-    final String stringValueDecoded = "=\\\"3,Int16=abc},\\\\\\nabc&test%test\\b\\f\\r\\t\\u0022}";
+    // Test JSON String lexer rule =\"3,Int16=abc},\\\nabc&test%test\b\f\r\t\u0022\\}\\{\\)\\(\\]\\[}
+    final String stringValueEncoded = "=\\\"3,Int16=abc},\\\\\\nabc%26test%25test\\b\\f\\r\\t\\u0022\\\\}\\\\{\\\\)" 
+        + "\\\\(\\\\]\\\\[}";
+    final String stringValueDecoded = "=\\\"3,Int16=abc},\\\\\\nabc&test%test\\b\\f\\r\\t\\u0022\\\\}\\\\{\\\\)" 
+        + "\\\\(\\\\]\\\\[}";
 
     testUri.run("ESTwoKeyNav/olingo.odata.test1.BFCESTwoKeyNavRTStringParam" 
         + "(ParameterComp=@p1)", "@p1={\"PropertyInt16\":1,\"ProperyString\":\"" + stringValueEncoded + "\"}")
@@ -5716,12 +5718,28 @@ public class TestFullResourcePath {
     testUri.run("ESTwoKeyNav", "$filter=olingo.odata.test1.BFCESTwoKeyNavRTStringParam" 
         + "(ParameterComp={\"PropertyString\":\"" + stringValueEncoded + "\",\"PropertyInt16\":1}) eq 'Test'")
     .goFilter().left().is("<<BFCESTwoKeyNavRTStringParam> eq <'Test'>>")
-    .isParameterText(0, "{\"PropertyString\":\"=\\\"3,Int16=abc},\\\\\\nabc&test%test\\b\\f\\r\\t\\u0022}\"," 
-        + "\"PropertyInt16\":1}");
+    .isParameterText(0, "{\"PropertyString\":\"" + stringValueDecoded + "\",\"PropertyInt16\":1}");
     
     testUri.run("ESTwoKeyNav", "$filter=olingo.odata.test1.BFCESTwoKeyNavRTStringParam"
         + "(ParameterComp=@p1) eq 0&@p1={\"PropertyInt16\":1,\"ProperyString\":\"1\"}");
     
+    testUri.run("ESTwoKeyNav", "$filter=olingo.odata.test1.BFCESTwoKeyNavRTStringParam"
+        + "(ParameterComp=@p1) eq 0&@p1={\"PropertyInt16\":1,\"ProperyString\":null}")
+      .goFilter().left().isParameterText(0, null);
+    
+    testUri.run("ESTwoKeyNav", "$filter=olingo.odata.test1.BFCESTwoKeyNavRTStringParam"
+        + "(ParameterComp=@p1) eq 0&@p1={}");
+    
+    testUri.run("ESTwoKeyNav", "$filter=olingo.odata.test1.BFCESTwoKeyNavRTStringParam"
+        + "(ParameterComp=@p1) eq 0&@p1={\"PropertyInt16\":[1,2,3],\"ProperyString\":\"1\"}");
+    
+    testUri.run("ESTwoKeyNav", "$filter=olingo.odata.test1.BFCESTwoKeyNavRTStringParam"
+        + "(ParameterComp=@p1) eq 0&@p1={\"PropertyInt16\":[\"1\",\"2\",\"3\"],\"ProperyString\":\"1\"}");
+    
+    testUri.run("ESTwoKeyNav", "$filter=olingo.odata.test1.BFCESTwoKeyNavRTStringParam"
+        + "(ParameterComp=@p1) eq 0&@p1={\"PropertyInt16\":[{\"Prop1\":123,\"Prop2\":\"Test\",\"Prop3\":[1,2,3]}," 
+        + "{\"Prop1\":{\"Prop1\":[\"Prop\\\":{]\"]}}],\"ProperyString\":\"1\"}");
+    
     testUri.runEx("ESTwoKeyNav/olingo.odata.test1.BFCESTwoKeyNavRTStringParam" 
         + "(ParameterComp=@p1)", "@p1={\"PropertyInt16\":1,\"ProperyString\":'1'}")
       .isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
@@ -5754,6 +5772,26 @@ public class TestFullResourcePath {
   
     testUri.runEx("ESAllPrim", "$filter=FINRTInt16() eq 0")
       .isExSemantic(UriParserSemanticException.MessageKeys.FUNCTION_IMPORT_NOT_ALLOWED);
+    
+    testUri.runEx("ESTwoKeyNav", "$filter=olingo.odata.test1.BFCESTwoKeyNavRTStringParam"
+        + "(ParameterComp=@p1) eq 0&@p1={\"PropertyInt16\":1,\"ProperyString\":\"1\"")  
+      .isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
+    
+    testUri.runEx("ESTwoKeyNav", "$filter=olingo.odata.test1.BFCESTwoKeyNavRTStringParam"
+        + "(ParameterComp=@p1) eq 0&@p1={\"PropertyInt16\":1,\"ProperyString\":\"1\"}}")  
+      .isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
+    
+    testUri.runEx("ESTwoKeyNav", "$filter=olingo.odata.test1.BFCESTwoKeyNavRTStringParam"
+        + "(ParameterComp=@p1) eq 0&@p1={\"PropertyInt16\":[1,2,3]],\"ProperyString\":\"1\"}")  
+      .isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
+    
+    testUri.runEx("ESTwoKeyNav", "$filter=olingo.odata.test1.BFCESTwoKeyNavRTStringParam"
+        + "(ParameterComp=@p1) eq 0&@p1={\"PropertyInt16\":[1,2,3,\"ProperyString\":\"1\"}")  
+      .isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
+    
+    testUri.runEx("ESTwoKeyNav", "$filter=olingo.odata.test1.BFCESTwoKeyNavRTStringParam"
+        + "(ParameterComp=@p1) eq 0&@p1={\"PropertyInt16\":[1,2,3},\"ProperyString\":\"1\"}")  
+      .isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
   }
   
   @Test