From 1aa5ec405223c3616a334bc210c34155a1f5b527 Mon Sep 17 00:00:00 2001 From: Jukka Zitting Date: Tue, 2 Oct 2012 15:49:34 +0200 Subject: [PATCH] OAK-237: Run Jackrabbit query tests Based on Alex Parvulescu's earlier patch --- .../oak/plugins/type/InitialContent.java | 1 + oak-jcr/pom.xml | 7 ++ .../apache/jackrabbit/oak/jcr/RepositoryImpl.java | 7 ++ .../jackrabbit/oak/jcr/query/QueryJcrTest.java | 86 ++++++++++++++++++++++ oak-parent/pom.xml | 2 +- 5 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryJcrTest.java diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/InitialContent.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/InitialContent.java index 94ce2af..a83cabc 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/InitialContent.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/InitialContent.java @@ -52,6 +52,7 @@ public class InitialContent extends DefaultMicroKernelTracker { "\"jcr:activities\" :{\"jcr:primaryType\":\"nam:rep:Activities\"}," + "\"rep:privileges\" :{\"jcr:primaryType\":\"nam:rep:Privileges\"}}", null, null); } + mk.commit("/", "+\"oak-index\": { \"indexes\": { \"type\": \"lucene\" }}", null, null); BuiltInNodeTypes.register(new Oak(mk).createRoot()); } diff --git a/oak-jcr/pom.xml b/oak-jcr/pom.xml index a9b5a3b..45b12cd 100644 --- a/oak-jcr/pom.xml +++ b/oak-jcr/pom.xml @@ -369,6 +369,13 @@ org.apache.jackrabbit.test.api.observation.LockingTest#testRemoveLockFromNode ${jackrabbit.version} test + + org.apache.jackrabbit + jackrabbit-core + ${jackrabbit.version} + tests + test + diff --git a/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java b/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java index 51e22a9..c281330 100644 --- a/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java +++ b/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java @@ -33,6 +33,9 @@ import org.apache.jackrabbit.oak.Oak; import org.apache.jackrabbit.oak.api.ContentRepository; import org.apache.jackrabbit.oak.api.ContentSession; import org.apache.jackrabbit.oak.core.ContentRepositoryImpl; +import org.apache.jackrabbit.oak.plugins.lucene.LuceneHook; +import org.apache.jackrabbit.oak.plugins.lucene.LuceneIndexProvider; +import org.apache.jackrabbit.oak.plugins.lucene.LuceneReindexHook; import org.apache.jackrabbit.oak.plugins.name.NameValidatorProvider; import org.apache.jackrabbit.oak.plugins.name.NamespaceValidatorProvider; import org.apache.jackrabbit.oak.plugins.type.InitialContent; @@ -47,6 +50,7 @@ import org.apache.jackrabbit.oak.spi.commit.CompositeHook; import org.apache.jackrabbit.oak.spi.commit.CompositeValidatorProvider; import org.apache.jackrabbit.oak.spi.commit.ValidatingHook; import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider; +import org.apache.jackrabbit.oak.spi.query.IndexUtils; import org.apache.jackrabbit.oak.spi.security.user.UserConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -76,6 +80,8 @@ public class RepositoryImpl implements Repository { private static final CompositeHook DEFAULT_COMMIT_HOOK = new CompositeHook( new ValidatingHook(DEFAULT_VALIDATOR), + new LuceneReindexHook(IndexUtils.DEFAULT_INDEX_HOME), + new LuceneHook(IndexUtils.DEFAULT_INDEX_HOME), new UniqueIndexHook()); private final Descriptors descriptors = new Descriptors(new SimpleValueFactory()); @@ -93,6 +99,7 @@ public class RepositoryImpl implements Repository { public RepositoryImpl( MicroKernel kernel, ScheduledExecutorService executor) { this(new Oak(setupInitialContent(kernel)) + .with(new LuceneIndexProvider(IndexUtils.DEFAULT_INDEX_HOME)) .with(DEFAULT_COMMIT_HOOK) .createContentRepository(), executor); diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryJcrTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryJcrTest.java new file mode 100644 index 0000000..22f4024 --- /dev/null +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryJcrTest.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.jcr.query; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.apache.jackrabbit.core.query.FulltextQueryTest; +import org.apache.jackrabbit.core.query.FulltextSQL2QueryTest; +import org.apache.jackrabbit.core.query.JoinTest; +import org.apache.jackrabbit.core.query.MixinTest; +import org.apache.jackrabbit.core.query.OrderByTest; +import org.apache.jackrabbit.core.query.PathQueryNodeTest; +import org.apache.jackrabbit.core.query.SQL2NodeLocalNameTest; +import org.apache.jackrabbit.core.query.SQL2OffsetLimitTest; +import org.apache.jackrabbit.core.query.SQL2OrderByTest; +import org.apache.jackrabbit.core.query.SQLTest; +import org.apache.jackrabbit.core.query.SkipDeletedNodesTest; +import org.apache.jackrabbit.test.ConcurrentTestSuite; + +public class QueryJcrTest extends TestCase { + + public static Test suite() { + TestSuite suite = new ConcurrentTestSuite("Jackrabbit query tests"); + suite.addTestSuite(FulltextQueryTest.class); + suite.addTestSuite(SQLTest.class); + suite.addTestSuite(JoinTest.class); + suite.addTestSuite(OrderByTest.class); + suite.addTestSuite(SkipDeletedNodesTest.class); + suite.addTestSuite(PathQueryNodeTest.class); + suite.addTestSuite(FulltextSQL2QueryTest.class); + suite.addTestSuite(SQL2NodeLocalNameTest.class); + suite.addTestSuite(SQL2OffsetLimitTest.class); + suite.addTestSuite(SQL2OrderByTest.class); + suite.addTestSuite(MixinTest.class); + + // + // NOT OK + // + // suite.addTestSuite(SQL2PathEscapingTest.class); // OAK-295 + // suite.addTestSuite(QueryResultTest.class);// OAK-308 + // suite.addTestSuite(LimitAndOffsetTest.class); // OAK-308 + // suite.addTestSuite(ParentNodeTest.class); // OAK-309 + // suite.addTestSuite(ExcerptTest.class); // OAK-318 + // suite.addTestSuite(SimilarQueryTest.class); // OAK-319 + // suite.addTestSuite(DerefTest.class); // OAK-321 + // suite.addTestSuite(XPathAxisTest.class); // OAK-322 + // suite.addTestSuite(SQL2QueryResultTest.class); // OAK-323 + // suite.addTestSuite(SQL2OuterJoinTest.class); // OAK-326 + // suite.addTestSuite(SimpleQueryTest.class); // OAK-327 + // suite.addTestSuite(FnNameQueryTest.class); // OAK-328 + // suite.addTestSuite(UpperLowerCaseQueryTest.class); // OAK-329 + + // + // NOT IMPLEMENTED + // + // suite.addTestSuite(ChildAxisQueryTest.class); // sns + // suite.addTestSuite(SelectClauseTest.class); // sns + // suite.addTestSuite(ShareableNodeTest.class); // ws#clone + // suite.addTestSuite(VersionStoreQueryTest.class); // versioning + + // + // TOO JR SPECIFIC + // + // suite.addTestSuite(LimitedAccessQueryTest.class); // acls + // suite.addTestSuite(SkipDeniedNodesTest.class); // acls + + return suite; + } + +} \ No newline at end of file diff --git a/oak-parent/pom.xml b/oak-parent/pom.xml index 00613b7..f3c8425 100644 --- a/oak-parent/pom.xml +++ b/oak-parent/pom.xml @@ -40,7 +40,7 @@ ${project.build.sourceEncoding} - 2.5.2 + 2.6-SNAPSHOT 13.0.1 -- 1.7.11.3