This is an automated email from the ASF dual-hosted git repository.

daim pushed a commit to branch DetailedGC/OAK-10199
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git

commit 315f5935f2595b46f05cccb48985d3c72ae947bf
Author: Manfred Baedke <[email protected]>
AuthorDate: Fri Jan 19 13:35:49 2024 +0100

    OAK-10596: Improve the test coverage of o.a.j.o.namepath.JcrPathParser
    
    Improved test cases
---
 .../jackrabbit/oak/namepath/PathParserTest.java    | 73 ++++------------------
 1 file changed, 11 insertions(+), 62 deletions(-)

diff --git 
a/oak-core-spi/src/test/java/org/apache/jackrabbit/oak/namepath/PathParserTest.java
 
b/oak-core-spi/src/test/java/org/apache/jackrabbit/oak/namepath/PathParserTest.java
index 679b1dfa34..ddafaaf1d5 100755
--- 
a/oak-core-spi/src/test/java/org/apache/jackrabbit/oak/namepath/PathParserTest.java
+++ 
b/oak-core-spi/src/test/java/org/apache/jackrabbit/oak/namepath/PathParserTest.java
@@ -188,10 +188,9 @@ public class PathParserTest {
     @Test
     @Ignore  //OAK-10611
     public void testUnexpectedOpeningSquareBracket() throws 
RepositoryException {
-        //TODO check for specific error messages
         String path = "[";
         TestListener listener = new TestListener(
-                CALLBACKRESULT_ERROR_ANY
+                CALLBACKRESULT_ERROR("'[' not allowed in name")
         );
         assertFalse(JcrPathParser.validate(path));
         assertFalse(JcrPathParser.parse(path, listener));
@@ -200,7 +199,7 @@ public class PathParserTest {
         path = "/[";
         listener = new TestListener(
                 CALLBACKRESULT_ROOT,
-                CALLBACKRESULT_ERROR_ANY
+                CALLBACKRESULT_ERROR("'[' not allowed in name")
         );
         assertFalse(JcrPathParser.validate(path));
         assertFalse(JcrPathParser.parse(path, listener));
@@ -209,7 +208,7 @@ public class PathParserTest {
         path = "./[";
         listener = new TestListener(
                 CALLBACKRESULT_CURRENT,
-                CALLBACKRESULT_ERROR_ANY
+                CALLBACKRESULT_ERROR("'[' not allowed in name")
         );
         assertFalse(JcrPathParser.validate(path));
         assertFalse(JcrPathParser.parse(path, listener));
@@ -218,7 +217,7 @@ public class PathParserTest {
         path = "../[";
         listener = new TestListener(
                 CALLBACKRESULT_PARENT,
-                CALLBACKRESULT_ERROR_ANY
+                CALLBACKRESULT_ERROR("'[' not allowed in name")
         );
         assertFalse(JcrPathParser.validate(path));
         assertFalse(JcrPathParser.parse(path, listener));
@@ -226,7 +225,7 @@ public class PathParserTest {
 
         path = ".[";
         listener = new TestListener(
-                CALLBACKRESULT_ERROR_ANY
+                CALLBACKRESULT_ERROR("'[' not allowed in name")
         );
         assertFalse(JcrPathParser.validate(path));
         assertFalse(JcrPathParser.parse(path, listener));
@@ -234,7 +233,7 @@ public class PathParserTest {
 
         path = "..[";
         listener = new TestListener(
-                CALLBACKRESULT_ERROR_ANY
+                CALLBACKRESULT_ERROR("'[' not allowed in name")
         );
         assertFalse(JcrPathParser.validate(path));
         assertFalse(JcrPathParser.parse(path, listener));
@@ -242,7 +241,7 @@ public class PathParserTest {
 
         path = "{[";
         listener = new TestListener(
-                CALLBACKRESULT_ERROR_ANY
+                CALLBACKRESULT_ERROR("'{[' is not a valid path. Missing '}'.")
         );
         assertFalse(JcrPathParser.validate(path));
         assertFalse(JcrPathParser.parse(path, listener));
@@ -250,7 +249,7 @@ public class PathParserTest {
 
         path = "a[[";
         listener = new TestListener(
-                CALLBACKRESULT_ERROR_ANY
+                CALLBACKRESULT_ERROR("'[' not allowed in name")
         );
         assertFalse(JcrPathParser.validate(path));
         assertFalse(JcrPathParser.parse(path, listener));
@@ -260,61 +259,11 @@ public class PathParserTest {
     @Test
     @Ignore  //OAK-10611
     public void testMissingClosingSquareBracket() throws RepositoryException {
-        //TODO check for specific error messages
-        String path = "[";
+        String path = "/a[";
         TestListener listener = new TestListener(
-                CALLBACKRESULT_ERROR_ANY
-        );
-        assertFalse(JcrPathParser.validate(path));
-        assertFalse(JcrPathParser.parse(path, listener));
-        listener.evaluate();
-
-        path = "/[";
-        listener = new TestListener(
                 CALLBACKRESULT_ROOT,
-                CALLBACKRESULT_ERROR_ANY
-        );
-        assertFalse(JcrPathParser.validate(path));
-        assertFalse(JcrPathParser.parse(path, listener));
-        listener.evaluate();
-
-        path = "./[";
-        listener = new TestListener(
-                CALLBACKRESULT_CURRENT,
-                CALLBACKRESULT_ERROR_ANY
-        );
-        assertFalse(JcrPathParser.validate(path));
-        assertFalse(JcrPathParser.parse(path, listener));
-        listener.evaluate();
-
-        path = "../[";
-        listener = new TestListener(
-                CALLBACKRESULT_PARENT,
-                CALLBACKRESULT_ERROR_ANY
-        );
-        assertFalse(JcrPathParser.validate(path));
-        assertFalse(JcrPathParser.parse(path, listener));
-        listener.evaluate();
-
-        path = ".[";
-        listener = new TestListener(
-                CALLBACKRESULT_ERROR_ANY
-        );
-        assertFalse(JcrPathParser.validate(path));
-        assertFalse(JcrPathParser.parse(path, listener));
-        listener.evaluate();
-
-        path = "..[";
-        listener = new TestListener(
-                CALLBACKRESULT_ERROR_ANY
-        );
-        assertFalse(JcrPathParser.validate(path));
-        assertFalse(JcrPathParser.parse(path, listener));
-        listener.evaluate();
-
-        path = "{[";
-        listener = new TestListener(
-                CALLBACKRESULT_ERROR_ANY
+                //the parser actually produces an error, but we should change 
the error message to something like this
+                CALLBACKRESULT_ERROR("'/a[' is not a valid path. ']' expected 
after index.")
         );
         assertFalse(JcrPathParser.validate(path));
         assertFalse(JcrPathParser.parse(path, listener));

Reply via email to