jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1441474 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ oak-core/src/test/java/org/apache/jackrabbit/oak/api/ oak-core/src/test/java/org/apache/jackrabbit/oak/query/ oak-jcr/
Date Fri, 01 Feb 2013 14:59:36 GMT
Author: alexparvulescu
Date: Fri Feb  1 14:59:35 2013
New Revision: 1441474

URL: http://svn.apache.org/viewvc?rev=1441474&view=rev
Log:
OAK-476 QueryEngine ignores unknown node types

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/api/QueryTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
    jackrabbit/oak/trunk/oak-jcr/pom.xml

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java?rev=1441474&r1=1441473&r2=1441474&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
Fri Feb  1 14:59:35 2013
@@ -138,7 +138,7 @@ public class SelectorImpl extends Source
     private Filter createFilter(boolean preparing) {
         FilterImpl f = new FilterImpl(this, query.getStatement());
         f.setPreparing(preparing);
-        validateNodeType(nodeTypeName);
+        validateNodeType();
         f.setNodeType(nodeTypeName);
         if (joinCondition != null) {
             joinCondition.restrict(f);
@@ -160,11 +160,20 @@ public class SelectorImpl extends Source
         return f;
     }
     
-    private void validateNodeType(String nodeType) {
+    private void validateNodeType() {
         // this looks a bit weird, but it should be correct - the code
         // assumes that paths and node type names have the same format
         // restrictions (characters such as "[" are not allowed and so on)
-        query.validatePath(nodeType);
+        query.validatePath(nodeTypeName);
+
+        try {
+            // force init of node types, which will also check for the node
+            // type's existence
+            getNodeTypes();
+        } catch (RepositoryException e) {
+            throw new IllegalArgumentException("Unable to determine node type "
+                    + nodeTypeName, e);
+        }
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/api/QueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/api/QueryTest.java?rev=1441474&r1=1441473&r2=1441474&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/api/QueryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/api/QueryTest.java
Fri Feb  1 14:59:35 2013
@@ -27,6 +27,7 @@ import javax.jcr.query.Query;
 
 import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
+import org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -42,7 +43,7 @@ public class QueryTest {
 
     @Before
     public void setUp() {
-        repository = new Oak().createContentRepository();
+        repository = new Oak().with(new InitialContent()).createContentRepository();
     }
 
     @After
@@ -54,7 +55,7 @@ public class QueryTest {
     public void queryOnStableRevision() throws Exception {
         ContentSession s = repository.login(null, null);
         Root r = s.getLatestRoot();
-        Tree t = r.getTree("/");
+        Tree t = r.getTree("/").addChild("test");
         t.addChild("node1").setProperty("jcr:primaryType", "nt:base");
         t.addChild("node2").setProperty("jcr:primaryType", "nt:base");
         t.addChild("node3").setProperty("jcr:primaryType", "nt:base");
@@ -63,11 +64,11 @@ public class QueryTest {
         ContentSession s2 = repository.login(null, null);
         Root r2 = s2.getLatestRoot();
 
-        r.getTree("/").getChild("node2").remove();
+        r.getTree("/test").getChild("node2").remove();
         r.commit();
 
         Result result = r2.getQueryEngine().executeQuery(
-                "//element(*, nt:base)",
+                "test//element(*, nt:base)",
                 Query.XPATH, Long.MAX_VALUE, 0,
                 Collections.<String, PropertyValue>emptyMap(),
                 NamePathMapper.DEFAULT);
@@ -75,7 +76,7 @@ public class QueryTest {
         for (ResultRow rr : result.getRows()) {
             paths.add(rr.getPath());
         }
-        assertEquals(new HashSet<String>(Arrays.asList("/", "/node1", "/node2", "/node3")),
paths);
+        assertEquals(new HashSet<String>(Arrays.asList("/test/node1", "/test/node2",
"/test/node3")), paths);
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java?rev=1441474&r1=1441473&r2=1441474&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
Fri Feb  1 14:59:35 2013
@@ -167,7 +167,6 @@ public abstract class AbstractQueryTest 
                     String got;
                     try {
                         got = c.convert(line);
-                        executeQuery(got, QueryEngineImpl.SQL2, null);
                     } catch (ParseException e) {
                         got = "invalid: " + e.getMessage().replace('\n', ' ');
                     } catch (Exception e) {
@@ -296,4 +295,4 @@ public abstract class AbstractQueryTest 
                 .getInputArguments().toString().indexOf("-agentlib:jdwp") > 0;
     }
 
-}
\ No newline at end of file
+}

Modified: jackrabbit/oak/trunk/oak-jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/pom.xml?rev=1441474&r1=1441473&r2=1441474&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-jcr/pom.xml Fri Feb  1 14:59:35 2013
@@ -202,7 +202,6 @@
       org.apache.jackrabbit.test.api.query.SimpleSelectionTest#testSingleProperty       
            <!-- OAK-323 -->
       org.apache.jackrabbit.test.api.query.qom.ColumnTest#testExpandColumnsForNodeType  
            <!-- OAK-323 -->
       org.apache.jackrabbit.test.api.query.GetPropertyNamesTest#testGetPropertyNames    
            <!-- OAK-323 -->
-      org.apache.jackrabbit.test.api.query.qom.SelectorTest#testUnknownNodeType         
            <!-- OAK-476 -->
       org.apache.jackrabbit.test.api.query.qom.EquiJoinConditionTest#testRightOuterJoin1
<!-- bug in test case, see OAK-559 -->
       org.apache.jackrabbit.test.api.query.qom.EquiJoinConditionTest#testLeftOuterJoin2 <!--
bug in test case, see OAK-559 -->
       org.apache.jackrabbit.test.api.observation.EventTest#testGetUserId



Mime
View raw message