Author: mkataria Date: Wed Aug 12 13:46:45 2020 New Revision: 1880807 URL: http://svn.apache.org/viewvc?rev=1880807&view=rev Log: OAK-9156: Port lucene tests
Added: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneFunctionIndexCommonTest.java (with props) jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregation2CommonTest.java (with props) jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregationCommonTest.java (with props) jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDescendantSpellcheckCommonTest.java (with props) jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDescendantSuggestionCommonTest.java (with props) jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexExclusionQueryCommonTest.java (with props) jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryCommonTest.java (with props) jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneSecureFacetCommonTest.java (with props) jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneStrictPathRestrictionEnableCommonTest.java (with props) jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneStrictPathRestrictionWarnCommonTest.java (with props) jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticFunctionIndexCommonTest.java (with props) jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticIndexDescendantSpellcheckCommonTest.java (with props) jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticIndexQueryCommonTest.java (with props) jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticStrictPathRestrictionWarnCommonTest.java (with props) jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDescendantSuggestionCommonTest.java (with props) jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticSecureFacetCommonTest.java (with props) jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticStrictPathRestrictionEnableCommonTest.java (with props) jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticDocumentMakerLargeStringPropertiesLogTest.java (with props) jackrabbit/oak/trunk/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/FunctionIndexCommonTest.java (with props) jackrabbit/oak/trunk/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexAggregation2CommonTest.java (with props) jackrabbit/oak/trunk/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexAggregationCommonTest.java (with props) jackrabbit/oak/trunk/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexDescendantSpellcheckCommonTest.java (with props) jackrabbit/oak/trunk/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexDescendantSuggestionCommonTest.java (with props) jackrabbit/oak/trunk/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexExclusionQueryCommonTest.java (with props) jackrabbit/oak/trunk/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexQueryCommonTest.java (with props) jackrabbit/oak/trunk/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/SecureFacetCommonTest.java (with props) jackrabbit/oak/trunk/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/StrictPathRestrictionEnableCommonTest.java (with props) jackrabbit/oak/trunk/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/StrictPathRestrictionWarnCommonTest.java (with props) jackrabbit/oak/trunk/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/TestUtil.java (with props) Removed: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneFacetCommonTest.java jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticFacetCommonTest.java jackrabbit/oak/trunk/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/FacetCommonTest.java Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/query/AbstractJcrTest.java jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexSuggestionCommonTest.java jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexCommonTest.java jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneSpellcheckCommonTest.java jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneTestRepositoryBuilder.java jackrabbit/oak/trunk/oak-search-elastic/pom.xml jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticTestRepositoryBuilder.java jackrabbit/oak/trunk/oak-search/pom.xml jackrabbit/oak/trunk/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/TestRepositoryBuilder.java Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/query/AbstractJcrTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/query/AbstractJcrTest.java?rev=1880807&r1=1880806&r2=1880807&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/query/AbstractJcrTest.java (original) +++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/query/AbstractJcrTest.java Wed Aug 12 13:46:45 2020 @@ -50,6 +50,7 @@ public abstract class AbstractJcrTest { anonymousSession.refresh(true); anonymousSession.save(); qm = anonymousSession.getWorkspace().getQueryManager(); + initialize(); } @After @@ -60,4 +61,8 @@ public abstract class AbstractJcrTest { } abstract protected Repository createJcrRepository() throws RepositoryException; + /* + Use this method to initialize variables/execute something after repository creation + */ + protected void initialize(){ } } Added: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneFunctionIndexCommonTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneFunctionIndexCommonTest.java?rev=1880807&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneFunctionIndexCommonTest.java (added) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneFunctionIndexCommonTest.java Wed Aug 12 13:46:45 2020 @@ -0,0 +1,89 @@ +/* + * 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.plugins.index.lucene; + +import org.apache.jackrabbit.JcrConstants; +import org.apache.jackrabbit.oak.InitialContentHelper; +import org.apache.jackrabbit.oak.api.ContentRepository; +import org.apache.jackrabbit.oak.api.Tree; +import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.plugins.index.FunctionIndexCommonTest; +import org.apache.jackrabbit.oak.plugins.index.LuceneIndexOptions; +import org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants; +import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore; +import org.apache.jackrabbit.oak.plugins.memory.PropertyStates; +import org.junit.After; +import org.junit.Rule; +import org.junit.rules.TemporaryFolder; + +import java.io.File; +import java.util.Set; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NAME; +import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NODE_TYPE; +import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.REINDEX_PROPERTY_NAME; +import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.TYPE_PROPERTY_NAME; + +public class LuceneFunctionIndexCommonTest extends FunctionIndexCommonTest { + + private ExecutorService executorService = Executors.newFixedThreadPool(2); + @Rule + public TemporaryFolder temporaryFolder = new TemporaryFolder(new File("target")); + + protected Tree createIndex(String name, Set<String> propNames) { + Tree index = root.getTree("/"); + return createIndex(index, name, propNames); + } + + protected Tree createIndex(Tree index, String name, Set<String> propNames) { + Tree def = index.addChild(INDEX_DEFINITIONS_NAME).addChild(name); + def.setProperty(JcrConstants.JCR_PRIMARYTYPE, + INDEX_DEFINITIONS_NODE_TYPE, Type.NAME); + def.setProperty(TYPE_PROPERTY_NAME, LuceneIndexConstants.TYPE_LUCENE); + def.setProperty(REINDEX_PROPERTY_NAME, true); + def.setProperty(FulltextIndexConstants.FULL_TEXT_ENABLED, false); + def.setProperty(PropertyStates.createProperty(FulltextIndexConstants.INCLUDE_PROPERTY_NAMES, propNames, Type.STRINGS)); + def.setProperty(LuceneIndexConstants.SAVE_DIR_LISTING, true); + return index.getChild(INDEX_DEFINITIONS_NAME).getChild(name); + } + + + @Override + protected ContentRepository createRepository() { + LuceneTestRepositoryBuilder luceneTestRepositoryBuilder = new LuceneTestRepositoryBuilder(executorService, temporaryFolder); + luceneTestRepositoryBuilder.setNodeStore(new MemoryNodeStore(InitialContentHelper.INITIAL_CONTENT)); + repositoryOptionsUtil = luceneTestRepositoryBuilder.build(); + indexOptions = new LuceneIndexOptions(); + return repositoryOptionsUtil.getOak() + .createContentRepository(); + } + + @Override + protected String getLoggerName() { + return LuceneIndexEditor.class.getName(); + } + + @After + public void shutdownExecutor() { + executorService.shutdown(); + } + +} Propchange: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneFunctionIndexCommonTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregation2CommonTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregation2CommonTest.java?rev=1880807&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregation2CommonTest.java (added) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregation2CommonTest.java Wed Aug 12 13:46:45 2020 @@ -0,0 +1,124 @@ +/* + * 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.plugins.index.lucene; + +import com.google.common.collect.Lists; +import org.apache.jackrabbit.oak.InitialContent; +import org.apache.jackrabbit.oak.Oak; +import org.apache.jackrabbit.oak.api.ContentRepository; +import org.apache.jackrabbit.oak.api.Root; +import org.apache.jackrabbit.oak.plugins.index.IndexAggregation2CommonTest; +import org.apache.jackrabbit.oak.plugins.index.LuceneIndexOptions; +import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore; +import org.apache.jackrabbit.oak.plugins.name.NamespaceEditorProvider; +import org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider; +import org.apache.jackrabbit.oak.plugins.nodetype.write.NodeTypeRegistry; +import org.apache.jackrabbit.oak.plugins.tree.factories.RootFactory; +import org.apache.jackrabbit.oak.spi.commit.CompositeEditorProvider; +import org.apache.jackrabbit.oak.spi.commit.EditorHook; +import org.apache.jackrabbit.oak.spi.commit.Observer; +import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider; +import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider; +import org.apache.jackrabbit.oak.spi.state.ApplyDiff; +import org.apache.jackrabbit.oak.spi.state.NodeBuilder; +import org.apache.jackrabbit.oak.spi.state.NodeState; +import org.apache.jackrabbit.oak.spi.state.NodeStore; +import org.jetbrains.annotations.NotNull; +import org.junit.After; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Collections; +import java.util.List; + +import static org.apache.jackrabbit.JcrConstants.JCR_SYSTEM; +import static org.apache.jackrabbit.oak.spi.nodetype.NodeTypeConstants.JCR_NODE_TYPES; +import static org.junit.Assert.fail; + +public class LuceneIndexAggregation2CommonTest extends IndexAggregation2CommonTest { + private static final Logger LOG = LoggerFactory.getLogger(LuceneIndexAggregation2CommonTest.class); + + @Override + protected ContentRepository createRepository() { + indexOptions = new LuceneIndexOptions(); + LuceneIndexProvider provider = new LuceneIndexProvider(); + + return new Oak() + .with(new InitialContent() { + + @Override + public void initialize(@NotNull NodeBuilder builder) { + super.initialize(builder); + + // registering additional node types for wider testing + InputStream stream = null; + try { + stream = LuceneIndexAggregation2CommonTest.class + .getResourceAsStream("test_nodetypes.cnd"); + NodeState base = builder.getNodeState(); + NodeStore store = new MemoryNodeStore(base); + + Root root = RootFactory.createSystemRoot(store, new EditorHook( + new CompositeEditorProvider(new NamespaceEditorProvider(), + new TypeEditorProvider())), null, null, null); + + NodeTypeRegistry.register(root, stream, "testing node types"); + + NodeState target = store.getRoot(); + target.compareAgainstBaseState(base, new ApplyDiff(builder)); + } catch (Exception e) { + LOG.error("Error while registering required node types. Failing here", e); + fail("Error while registering required node types"); + } finally { + printNodeTypes(builder); + if (stream != null) { + try { + stream.close(); + } catch (IOException e) { + LOG.debug("Ignoring exception on stream closing.", e); + } + } + } + + } + + }) + .with(new OpenSecurityProvider()) + .with(((QueryIndexProvider) provider.with(getNodeAggregator()))) + .with((Observer) provider).with(new LuceneIndexEditorProvider()) + .createContentRepository(); + } + + /** + * convenience method for printing on logs the currently registered node types. + * + * @param builder + */ + private static void printNodeTypes(NodeBuilder builder) { + if (LOG.isDebugEnabled()) { + NodeBuilder namespace = builder.child(JCR_SYSTEM).child(JCR_NODE_TYPES); + List<String> nodes = Lists.newArrayList(namespace.getChildNodeNames()); + Collections.sort(nodes); + for (String node : nodes) { + LOG.debug(node); + } + } + } + +} Propchange: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregation2CommonTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregationCommonTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregationCommonTest.java?rev=1880807&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregationCommonTest.java (added) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregationCommonTest.java Wed Aug 12 13:46:45 2020 @@ -0,0 +1,65 @@ +/* + * 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.plugins.index.lucene; + +import org.apache.jackrabbit.oak.InitialContentHelper; +import org.apache.jackrabbit.oak.Oak; +import org.apache.jackrabbit.oak.api.ContentRepository; +import org.apache.jackrabbit.oak.plugins.index.IndexAggregationCommonTest; +import org.apache.jackrabbit.oak.plugins.index.LuceneIndexOptions; +import org.apache.jackrabbit.oak.plugins.index.aggregate.SimpleNodeAggregator; +import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore; +import org.apache.jackrabbit.oak.spi.commit.Observer; +import org.apache.jackrabbit.oak.spi.query.QueryIndex; +import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider; +import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider; + +import static com.google.common.collect.Lists.newArrayList; +import static org.apache.jackrabbit.JcrConstants.JCR_CONTENT; +import static org.apache.jackrabbit.JcrConstants.NT_FILE; +import static org.apache.jackrabbit.JcrConstants.NT_FOLDER; + +public class LuceneIndexAggregationCommonTest extends IndexAggregationCommonTest { + + @Override + protected ContentRepository createRepository() { + indexOptions = new LuceneIndexOptions(); + LowCostLuceneIndexProvider provider = new LowCostLuceneIndexProvider(); + return new Oak(new MemoryNodeStore(InitialContentHelper.INITIAL_CONTENT)) + .with(new OpenSecurityProvider()) + .with((QueryIndexProvider) provider.with(getNodeAggregator())) + .with((Observer) provider) + .with(new LuceneIndexEditorProvider()) + .createContentRepository(); + } + + /** + * <code> + * <aggregate primaryType="nt:file"> + * <include>jcr:content</include> + * <include>jcr:content/*</include> + * <include-property>jcr:content/jcr:lastModified</include-property> + * </aggregate> + * <code> + */ + private static QueryIndex.NodeAggregator getNodeAggregator() { + return new SimpleNodeAggregator() + .newRuleWithName(NT_FILE, newArrayList(JCR_CONTENT, JCR_CONTENT + "/*")) + .newRuleWithName(NT_FOLDER, newArrayList("myFile", "subfolder/subsubfolder/file")); + } + +} Propchange: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregationCommonTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDescendantSpellcheckCommonTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDescendantSpellcheckCommonTest.java?rev=1880807&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDescendantSpellcheckCommonTest.java (added) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDescendantSpellcheckCommonTest.java Wed Aug 12 13:46:45 2020 @@ -0,0 +1,55 @@ +/* + * 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.plugins.index.lucene; + +import org.apache.jackrabbit.oak.Oak; +import org.apache.jackrabbit.oak.jcr.Jcr; +import org.apache.jackrabbit.oak.plugins.index.IndexDescendantSpellcheckCommonTest; +import org.apache.jackrabbit.oak.plugins.index.LuceneIndexOptions; +import org.junit.After; +import org.junit.Rule; +import org.junit.rules.TemporaryFolder; + +import javax.jcr.Repository; +import javax.jcr.RepositoryException; +import java.io.File; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class LuceneIndexDescendantSpellcheckCommonTest extends IndexDescendantSpellcheckCommonTest { + + private ExecutorService executorService = Executors.newFixedThreadPool(2); + @Rule + public TemporaryFolder temporaryFolder = new TemporaryFolder(new File("target")); + + @Override + protected Repository createJcrRepository() throws RepositoryException { + indexOptions = new LuceneIndexOptions(); + repositoryOptionsUtil = new LuceneTestRepositoryBuilder(executorService, temporaryFolder).build(); + Oak oak = repositoryOptionsUtil.getOak(); + Jcr jcr = new Jcr(oak); + Repository repository = jcr.createRepository(); + return repository; + } + + @After + public void shutdownExecutor() { + executorService.shutdown(); + } + + +} Propchange: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDescendantSpellcheckCommonTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDescendantSuggestionCommonTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDescendantSuggestionCommonTest.java?rev=1880807&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDescendantSuggestionCommonTest.java (added) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDescendantSuggestionCommonTest.java Wed Aug 12 13:46:45 2020 @@ -0,0 +1,53 @@ +/* + * 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.plugins.index.lucene; + +import org.apache.jackrabbit.oak.Oak; +import org.apache.jackrabbit.oak.jcr.Jcr; +import org.apache.jackrabbit.oak.plugins.index.IndexDescendantSuggestionCommonTest; +import org.apache.jackrabbit.oak.plugins.index.LuceneIndexOptions; +import org.junit.After; +import org.junit.Rule; +import org.junit.rules.TemporaryFolder; + +import javax.jcr.Repository; +import javax.jcr.RepositoryException; +import java.io.File; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class LuceneIndexDescendantSuggestionCommonTest extends IndexDescendantSuggestionCommonTest { + private ExecutorService executorService = Executors.newFixedThreadPool(2); + @Rule + public TemporaryFolder temporaryFolder = new TemporaryFolder(new File("target")); + + @Override + protected Repository createJcrRepository() throws RepositoryException { + indexOptions = new LuceneIndexOptions(); + repositoryOptionsUtil = new LuceneTestRepositoryBuilder(executorService, temporaryFolder).build(); + Oak oak = repositoryOptionsUtil.getOak(); + Jcr jcr = new Jcr(oak); + Repository repository = jcr.createRepository(); + return repository; + } + + @After + public void shutdownExecutor() { + executorService.shutdown(); + } + +} Propchange: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDescendantSuggestionCommonTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexExclusionQueryCommonTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexExclusionQueryCommonTest.java?rev=1880807&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexExclusionQueryCommonTest.java (added) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexExclusionQueryCommonTest.java Wed Aug 12 13:46:45 2020 @@ -0,0 +1,68 @@ +/* + * 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.plugins.index.lucene; + +import org.apache.jackrabbit.oak.InitialContentHelper; +import org.apache.jackrabbit.oak.Oak; +import org.apache.jackrabbit.oak.api.ContentRepository; +import org.apache.jackrabbit.oak.api.Tree; +import org.apache.jackrabbit.oak.plugins.index.IndexExclusionQueryCommonTest; +import org.apache.jackrabbit.oak.plugins.index.LuceneIndexOptions; +import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore; +import org.apache.jackrabbit.oak.spi.commit.Observer; +import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider; +import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider; + +import static com.google.common.collect.ImmutableList.of; +import static javax.jcr.PropertyType.TYPENAME_BINARY; +import static javax.jcr.PropertyType.TYPENAME_STRING; +import static org.apache.jackrabbit.oak.api.Type.STRINGS; +import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.TYPE_LUCENE; +import static org.apache.jackrabbit.oak.plugins.index.lucene.TestUtil.useV2; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.EXCLUDE_PROPERTY_NAMES; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.INCLUDE_PROPERTY_TYPES; + +/** + * Tests the {@link LuceneIndexProvider} exclusion settings + */ +public class LuceneIndexExclusionQueryCommonTest extends IndexExclusionQueryCommonTest { + + private static final String NOT_IN = "notincluded"; + + @Override + protected void createTestIndexNode() throws Exception { + indexOptions = new LuceneIndexOptions(); + Tree lucene = createTestIndexNode(root.getTree("/"), TYPE_LUCENE); + lucene.setProperty(INCLUDE_PROPERTY_TYPES, + of(TYPENAME_BINARY, TYPENAME_STRING), STRINGS); + lucene.setProperty(EXCLUDE_PROPERTY_NAMES, of(NOT_IN), STRINGS); + useV2(lucene); + root.commit(); + } + + @Override + protected ContentRepository createRepository() { + LowCostLuceneIndexProvider provider = new LowCostLuceneIndexProvider(); + return new Oak(new MemoryNodeStore(InitialContentHelper.INITIAL_CONTENT)) + .with(new OpenSecurityProvider()) + .with((QueryIndexProvider) provider) + .with((Observer) provider) + .with(new LuceneIndexEditorProvider()) + .createContentRepository(); + } + +} Propchange: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexExclusionQueryCommonTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryCommonTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryCommonTest.java?rev=1880807&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryCommonTest.java (added) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryCommonTest.java Wed Aug 12 13:46:45 2020 @@ -0,0 +1,56 @@ +/* + * 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.plugins.index.lucene; + +import org.apache.jackrabbit.oak.InitialContentHelper; +import org.apache.jackrabbit.oak.api.ContentRepository; +import org.apache.jackrabbit.oak.plugins.index.IndexQueryCommonTest; +import org.apache.jackrabbit.oak.plugins.index.LuceneIndexOptions; +import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore; +import org.junit.After; +import org.junit.Rule; +import org.junit.rules.TemporaryFolder; + +import java.io.File; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +/** + * Tests the query engine using the default index implementation: the + * {@link LuceneIndexProvider} + */ +public class LuceneIndexQueryCommonTest extends IndexQueryCommonTest { + + private ExecutorService executorService = Executors.newFixedThreadPool(2); + @Rule + public TemporaryFolder temporaryFolder = new TemporaryFolder(new File("target")); + + @Override + protected ContentRepository createRepository() { + LuceneTestRepositoryBuilder luceneTestRepositoryBuilder = new LuceneTestRepositoryBuilder(executorService, temporaryFolder); + luceneTestRepositoryBuilder.setNodeStore(new MemoryNodeStore(InitialContentHelper.INITIAL_CONTENT)); + repositoryOptionsUtil = luceneTestRepositoryBuilder.build(); + indexOptions = new LuceneIndexOptions(); + return repositoryOptionsUtil.getOak().createContentRepository(); + } + + @After + public void shutdownExecutor() { + executorService.shutdown(); + } + +} Propchange: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryCommonTest.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java?rev=1880807&r1=1880806&r2=1880807&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java Wed Aug 12 13:46:45 2020 @@ -322,7 +322,6 @@ public class LuceneIndexQueryTest extend @Test public void containsPathNum() throws Exception { - Tree test = root.getTree("/").addChild("test"); Tree a = test.addChild("a"); a.setProperty("name", "/segment1/segment2/segment3"); Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexSuggestionCommonTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexSuggestionCommonTest.java?rev=1880807&r1=1880806&r2=1880807&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexSuggestionCommonTest.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexSuggestionCommonTest.java Wed Aug 12 13:46:45 2020 @@ -20,6 +20,7 @@ import org.apache.jackrabbit.oak.Oak; import org.apache.jackrabbit.oak.jcr.Jcr; import org.apache.jackrabbit.oak.plugins.index.IndexSuggestionCommonTest; import org.apache.jackrabbit.oak.plugins.index.LuceneIndexOptions; +import org.junit.After; import org.junit.Rule; import org.junit.rules.TemporaryFolder; @@ -43,4 +44,10 @@ public class LuceneIndexSuggestionCommon Repository repository = jcr.createRepository(); return repository; } + + @After + public void shutdownExecutor() { + executorService.shutdown(); + } + } Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexCommonTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexCommonTest.java?rev=1880807&r1=1880806&r2=1880807&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexCommonTest.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexCommonTest.java Wed Aug 12 13:46:45 2020 @@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.plugin import org.apache.jackrabbit.oak.api.ContentRepository; import org.apache.jackrabbit.oak.plugins.index.LuceneIndexOptions; import org.apache.jackrabbit.oak.plugins.index.PropertyIndexCommonTest; +import org.junit.After; import org.junit.Rule; import org.junit.rules.TemporaryFolder; @@ -44,4 +45,9 @@ public class LucenePropertyIndexCommonTe setTraversalEnabled(false); } + @After + public void shutdownExecutor() { + executorService.shutdown(); + } + } Added: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneSecureFacetCommonTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneSecureFacetCommonTest.java?rev=1880807&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneSecureFacetCommonTest.java (added) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneSecureFacetCommonTest.java Wed Aug 12 13:46:45 2020 @@ -0,0 +1,57 @@ +/* + * 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.plugins.index.lucene; + +import org.apache.jackrabbit.oak.Oak; +import org.apache.jackrabbit.oak.jcr.Jcr; +import org.apache.jackrabbit.oak.plugins.index.LuceneIndexOptions; +import org.apache.jackrabbit.oak.plugins.index.SecureFacetCommonTest; +import org.apache.jackrabbit.oak.plugins.index.TestUtils; +import org.junit.After; +import org.junit.Rule; +import org.junit.rules.TemporaryFolder; + +import javax.jcr.Repository; +import java.io.File; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class LuceneSecureFacetCommonTest extends SecureFacetCommonTest { + + private ExecutorService executorService = Executors.newFixedThreadPool(2); + @Rule + public TemporaryFolder temporaryFolder = new TemporaryFolder(new File("target")); + + protected Repository createJcrRepository() { + indexOptions = new LuceneIndexOptions(); + repositoryOptionsUtil = new LuceneTestRepositoryBuilder(executorService, temporaryFolder).build(); + Oak oak = repositoryOptionsUtil.getOak(); + Jcr jcr = new Jcr(oak); + Repository repository = jcr.createRepository(); + return repository; + } + + protected void assertEventually(Runnable r) { + TestUtils.assertEventually(r, (repositoryOptionsUtil.isAsync() ? repositoryOptionsUtil.defaultAsyncIndexingTimeInSeconds : 0) * 5); + } + + @After + public void shutdownExecutor() { + executorService.shutdown(); + } + +} Propchange: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneSecureFacetCommonTest.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneSpellcheckCommonTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneSpellcheckCommonTest.java?rev=1880807&r1=1880806&r2=1880807&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneSpellcheckCommonTest.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneSpellcheckCommonTest.java Wed Aug 12 13:46:45 2020 @@ -20,6 +20,7 @@ import org.apache.jackrabbit.oak.Oak; import org.apache.jackrabbit.oak.jcr.Jcr; import org.apache.jackrabbit.oak.plugins.index.LuceneIndexOptions; import org.apache.jackrabbit.oak.plugins.index.SpellcheckCommonTest; +import org.junit.After; import org.junit.Ignore; import org.junit.Rule; import org.junit.rules.TemporaryFolder; @@ -45,4 +46,10 @@ public class LuceneSpellcheckCommonTest Repository repository = jcr.createRepository(); return repository; } + + @After + public void shutdownExecutor() { + executorService.shutdown(); + } + } Added: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneStrictPathRestrictionEnableCommonTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneStrictPathRestrictionEnableCommonTest.java?rev=1880807&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneStrictPathRestrictionEnableCommonTest.java (added) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneStrictPathRestrictionEnableCommonTest.java Wed Aug 12 13:46:45 2020 @@ -0,0 +1,66 @@ +/* + * 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.plugins.index.lucene; + +import org.apache.jackrabbit.oak.api.ContentRepository; +import org.apache.jackrabbit.oak.api.StrictPathRestriction; +import org.apache.jackrabbit.oak.commons.concurrent.ExecutorCloser; +import org.apache.jackrabbit.oak.plugins.index.LuceneIndexOptions; +import org.apache.jackrabbit.oak.plugins.index.StrictPathRestrictionEnableCommonTest; +import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition; +import org.apache.jackrabbit.oak.query.QueryEngineSettings; +import org.junit.After; +import org.junit.Rule; +import org.junit.rules.TemporaryFolder; + +import java.io.File; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +@SuppressWarnings("ArraysAsListWithZeroOrOneArgument") +public class LuceneStrictPathRestrictionEnableCommonTest extends StrictPathRestrictionEnableCommonTest { + + private ExecutorService executorService = Executors.newFixedThreadPool(2); + @Rule + public TemporaryFolder temporaryFolder = new TemporaryFolder(new File("target")); + + @After + public void after() { + new ExecutorCloser(executorService).close(); + IndexDefinition.setDisableStoredIndexDefinition(false); + } + + @Override + protected ContentRepository createRepository() { + LuceneTestRepositoryBuilder luceneTestRepositoryBuilder = new LuceneTestRepositoryBuilder(executorService, temporaryFolder); + QueryEngineSettings queryEngineSettings = new QueryEngineSettings(); + queryEngineSettings.setStrictPathRestriction(StrictPathRestriction.ENABLE.name()); + luceneTestRepositoryBuilder.setQueryEngineSettings(queryEngineSettings); + repositoryOptionsUtil = luceneTestRepositoryBuilder.build(); + indexOptions = new LuceneIndexOptions(); + return repositoryOptionsUtil.getOak().createContentRepository(); + } + + @After + public void shutdownExecutor() { + executorService.shutdown(); + } + +} Propchange: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneStrictPathRestrictionEnableCommonTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneStrictPathRestrictionWarnCommonTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneStrictPathRestrictionWarnCommonTest.java?rev=1880807&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneStrictPathRestrictionWarnCommonTest.java (added) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneStrictPathRestrictionWarnCommonTest.java Wed Aug 12 13:46:45 2020 @@ -0,0 +1,93 @@ +/* + * 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.plugins.index.lucene; + +import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.core.read.ListAppender; +import org.apache.jackrabbit.oak.api.ContentRepository; +import org.apache.jackrabbit.oak.api.StrictPathRestriction; +import org.apache.jackrabbit.oak.commons.concurrent.ExecutorCloser; +import org.apache.jackrabbit.oak.plugins.index.LuceneIndexOptions; +import org.apache.jackrabbit.oak.plugins.index.StrictPathRestrictionWarnCommonTest; +import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition; +import org.apache.jackrabbit.oak.query.QueryEngineSettings; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.rules.TemporaryFolder; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +@SuppressWarnings("ArraysAsListWithZeroOrOneArgument") +public class LuceneStrictPathRestrictionWarnCommonTest extends StrictPathRestrictionWarnCommonTest { + + private ExecutorService executorService = Executors.newFixedThreadPool(2); + @Rule + public TemporaryFolder temporaryFolder = new TemporaryFolder(new File("target")); + + private final String warnMessage = "Index definition of index used have path restrictions and query won't return nodes from " + + "those restricted paths"; + + private final String queryImplLogger = "org.apache.jackrabbit.oak.query.QueryImpl"; + + @Before + public void loggingAppenderStart() { + LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); + listAppender = new ListAppender<>(); + listAppender.start(); + context.getLogger(queryImplLogger).addAppender(listAppender); + } + + @After + public void loggingAppenderStop() { + listAppender.stop(); + } + + @After + public void after() { + new ExecutorCloser(executorService).close(); + IndexDefinition.setDisableStoredIndexDefinition(false); + } + + @Override + protected void createTestIndexNode() throws Exception { + setTraversalEnabled(false); + } + + @Override + protected ContentRepository createRepository() { + LuceneTestRepositoryBuilder luceneTestRepositoryBuilder = new LuceneTestRepositoryBuilder(executorService, temporaryFolder); + QueryEngineSettings queryEngineSettings = new QueryEngineSettings(); + queryEngineSettings.setStrictPathRestriction(StrictPathRestriction.WARN.name()); + luceneTestRepositoryBuilder.setQueryEngineSettings(queryEngineSettings); + repositoryOptionsUtil = luceneTestRepositoryBuilder.build(); + indexOptions = new LuceneIndexOptions(); + return repositoryOptionsUtil.getOak().createContentRepository(); + } + + @After + public void shutdownExecutor() { + executorService.shutdown(); + } + +} Propchange: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneStrictPathRestrictionWarnCommonTest.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneTestRepositoryBuilder.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneTestRepositoryBuilder.java?rev=1880807&r1=1880806&r2=1880807&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneTestRepositoryBuilder.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneTestRepositoryBuilder.java Wed Aug 12 13:46:45 2020 @@ -20,7 +20,6 @@ package org.apache.jackrabbit.oak.plugin import org.apache.commons.io.FileUtils; import org.apache.jackrabbit.oak.Oak; -import org.apache.jackrabbit.oak.api.StrictPathRestriction; import org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdate; import org.apache.jackrabbit.oak.plugins.index.TestRepository; import org.apache.jackrabbit.oak.plugins.index.TestRepositoryBuilder; @@ -57,9 +56,7 @@ public class LuceneTestRepositoryBuilder resultCountingIndexProvider = new ResultCountingIndexProvider(indexProvider); queryEngineSettings = new QueryEngineSettings(); - queryEngineSettings.setStrictPathRestriction(StrictPathRestriction.ENABLE.name()); optionalEditorProvider = new TestUtil.OptionalEditorProvider(); - asyncIndexUpdate.setCorruptIndexHandler(trackingCorruptIndexHandler); } Modified: jackrabbit/oak/trunk/oak-search-elastic/pom.xml URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/pom.xml?rev=1880807&r1=1880806&r2=1880807&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-search-elastic/pom.xml (original) +++ jackrabbit/oak/trunk/oak-search-elastic/pom.xml Wed Aug 12 13:46:45 2020 @@ -267,6 +267,13 @@ <type>test-jar</type> <scope>test</scope> </dependency> + <dependency> + <groupId>org.apache.jackrabbit</groupId> + <artifactId>oak-commons</artifactId> + <version>${project.version}</version> + <type>test-jar</type> + <scope>test</scope> + </dependency> </dependencies> </project> Added: jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticFunctionIndexCommonTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticFunctionIndexCommonTest.java?rev=1880807&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticFunctionIndexCommonTest.java (added) +++ jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticFunctionIndexCommonTest.java Wed Aug 12 13:46:45 2020 @@ -0,0 +1,84 @@ +/* + * 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.plugins.index; + +import org.apache.jackrabbit.JcrConstants; +import org.apache.jackrabbit.oak.api.ContentRepository; +import org.apache.jackrabbit.oak.api.Tree; +import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticConnectionRule; +import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexOptions; +import org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants; +import org.apache.jackrabbit.oak.plugins.memory.PropertyStates; +import org.junit.ClassRule; +import org.junit.Ignore; + +import java.util.Set; + +import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NAME; +import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NODE_TYPE; +import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.REINDEX_PROPERTY_NAME; +import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.TYPE_PROPERTY_NAME; + +@Ignore +public class ElasticFunctionIndexCommonTest extends FunctionIndexCommonTest { + // Set this connection string as + // <scheme>://<hostname>:<port>?key_id=<>,key_secret=<> + // key_id and key_secret are optional in case the ES server + // needs authentication + // Do not set this if docker is running and you want to run the tests on docker instead. + private static String elasticConnectionString = System.getProperty("elasticConnectionString"); + @ClassRule + public static ElasticConnectionRule elasticRule = new ElasticConnectionRule(elasticConnectionString); + + public ElasticFunctionIndexCommonTest() { + indexOptions = new ElasticIndexOptions(); + } + + @Override + protected ContentRepository createRepository() { + repositoryOptionsUtil = new ElasticTestRepositoryBuilder(elasticRule).build(); + return repositoryOptionsUtil.getOak().createContentRepository(); + } + + @Override + protected void createTestIndexNode() { + setTraversalEnabled(false); + } + + protected Tree createIndex(String name, Set<String> propNames) { + Tree index = root.getTree("/"); + return createIndex(index, name, propNames); + } + + protected Tree createIndex(Tree index, String name, Set<String> propNames) { + Tree def = index.addChild(INDEX_DEFINITIONS_NAME).addChild(name); + def.setProperty(JcrConstants.JCR_PRIMARYTYPE, + INDEX_DEFINITIONS_NODE_TYPE, Type.NAME); + def.setProperty(TYPE_PROPERTY_NAME, indexOptions.getIndexType()); + def.setProperty(REINDEX_PROPERTY_NAME, true); + def.setProperty(FulltextIndexConstants.FULL_TEXT_ENABLED, false); + def.setProperty(PropertyStates.createProperty(FulltextIndexConstants.INCLUDE_PROPERTY_NAMES, propNames, Type.STRINGS)); + //def.setProperty(LuceneIndexConstants.SAVE_DIR_LISTING, true); + return index.getChild(INDEX_DEFINITIONS_NAME).getChild(name); + } + + @Override + protected String getLoggerName() { + return null; + } +} Propchange: jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticFunctionIndexCommonTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticIndexDescendantSpellcheckCommonTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticIndexDescendantSpellcheckCommonTest.java?rev=1880807&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticIndexDescendantSpellcheckCommonTest.java (added) +++ jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticIndexDescendantSpellcheckCommonTest.java Wed Aug 12 13:46:45 2020 @@ -0,0 +1,48 @@ +/* + * 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.plugins.index; + +import org.apache.jackrabbit.oak.Oak; +import org.apache.jackrabbit.oak.jcr.Jcr; +import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticConnectionRule; +import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexOptions; +import org.junit.ClassRule; + +import javax.jcr.Repository; +import javax.jcr.RepositoryException; + +public class ElasticIndexDescendantSpellcheckCommonTest extends IndexDescendantSpellcheckCommonTest { + + // Set this connection string as + // <scheme>://<hostname>:<port>?key_id=<>,key_secret=<> + // key_id and key_secret are optional in case the ES server + // needs authentication + // Do not set this if docker is running and you want to run the tests on docker instead. + private static String elasticConnectionString = System.getProperty("elasticConnectionString"); + @ClassRule + public static ElasticConnectionRule elasticRule = new ElasticConnectionRule(elasticConnectionString); + + @Override + protected Repository createJcrRepository() throws RepositoryException { + indexOptions = new ElasticIndexOptions(); + repositoryOptionsUtil = new ElasticTestRepositoryBuilder(elasticRule).build(); + Oak oak = repositoryOptionsUtil.getOak(); + Jcr jcr = new Jcr(oak); + Repository repository = jcr.createRepository(); + return repository; + } +} Propchange: jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticIndexDescendantSpellcheckCommonTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticIndexQueryCommonTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticIndexQueryCommonTest.java?rev=1880807&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticIndexQueryCommonTest.java (added) +++ jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticIndexQueryCommonTest.java Wed Aug 12 13:46:45 2020 @@ -0,0 +1,48 @@ +/* + * 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.plugins.index; + +import org.apache.jackrabbit.oak.InitialContentHelper; +import org.apache.jackrabbit.oak.api.ContentRepository; +import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticConnectionRule; +import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexOptions; +import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore; +import org.junit.ClassRule; + +public class ElasticIndexQueryCommonTest extends IndexQueryCommonTest { + + // Set this connection string as + // <scheme>://<hostname>:<port>?key_id=<>,key_secret=<> + // key_id and key_secret are optional in case the ES server + // needs authentication + // Do not set this if docker is running and you want to run the tests on docker instead. + private static String elasticConnectionString = System.getProperty("elasticConnectionString"); + @ClassRule + public static ElasticConnectionRule elasticRule = new ElasticConnectionRule(elasticConnectionString); + + public ElasticIndexQueryCommonTest() { + indexOptions = new ElasticIndexOptions(); + } + + @Override + protected ContentRepository createRepository() { + ElasticTestRepositoryBuilder elasticTestRepositoryBuilder = new ElasticTestRepositoryBuilder(elasticRule); + elasticTestRepositoryBuilder.setNodeStore(new MemoryNodeStore(InitialContentHelper.INITIAL_CONTENT)); + repositoryOptionsUtil = elasticTestRepositoryBuilder.build(); + return repositoryOptionsUtil.getOak().createContentRepository(); + } +} Propchange: jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticIndexQueryCommonTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticStrictPathRestrictionWarnCommonTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticStrictPathRestrictionWarnCommonTest.java?rev=1880807&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticStrictPathRestrictionWarnCommonTest.java (added) +++ jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticStrictPathRestrictionWarnCommonTest.java Wed Aug 12 13:46:45 2020 @@ -0,0 +1,47 @@ +/* + * 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.plugins.index; + +import org.apache.jackrabbit.oak.api.ContentRepository; +import org.apache.jackrabbit.oak.api.StrictPathRestriction; +import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticConnectionRule; +import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexOptions; +import org.apache.jackrabbit.oak.query.QueryEngineSettings; +import org.junit.ClassRule; + +public class ElasticStrictPathRestrictionWarnCommonTest extends StrictPathRestrictionWarnCommonTest { + + // Set this connection string as + // <scheme>://<hostname>:<port>?key_id=<>,key_secret=<> + // key_id and key_secret are optional in case the ES server + // needs authentication + // Do not set this if docker is running and you want to run the tests on docker instead. + private static String elasticConnectionString = System.getProperty("elasticConnectionString"); + @ClassRule + public static ElasticConnectionRule elasticRule = new ElasticConnectionRule(elasticConnectionString); + + @Override + protected ContentRepository createRepository() { + indexOptions = new ElasticIndexOptions(); + ElasticTestRepositoryBuilder elasticTestRepositoryBuilder = new ElasticTestRepositoryBuilder(elasticRule); + QueryEngineSettings queryEngineSettings = new QueryEngineSettings(); + queryEngineSettings.setStrictPathRestriction(StrictPathRestriction.WARN.name()); + elasticTestRepositoryBuilder.setQueryEngineSettings(queryEngineSettings); + repositoryOptionsUtil = elasticTestRepositoryBuilder.build(); + return repositoryOptionsUtil.getOak().createContentRepository(); + } +} Propchange: jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticStrictPathRestrictionWarnCommonTest.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticTestRepositoryBuilder.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticTestRepositoryBuilder.java?rev=1880807&r1=1880806&r2=1880807&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticTestRepositoryBuilder.java (original) +++ jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/ElasticTestRepositoryBuilder.java Wed Aug 12 13:46:45 2020 @@ -26,6 +26,7 @@ import org.apache.jackrabbit.oak.plugins import org.apache.jackrabbit.oak.plugins.index.elastic.index.ElasticIndexEditorProvider; import org.apache.jackrabbit.oak.plugins.index.elastic.query.ElasticIndexProvider; import org.apache.jackrabbit.oak.plugins.index.search.ExtractedTextCache; +import org.apache.jackrabbit.oak.query.QueryEngineSettings; import org.apache.jackrabbit.oak.spi.commit.Observer; import static com.google.common.collect.Lists.newArrayList; @@ -45,6 +46,7 @@ public class ElasticTestRepositoryBuilde editorProvider, new NodeCounterEditorProvider() ))); + queryEngineSettings = new QueryEngineSettings(); asyncIndexUpdate.setCorruptIndexHandler(trackingCorruptIndexHandler); } @@ -55,7 +57,9 @@ public class ElasticTestRepositoryBuilde .with(editorProvider) .with((Observer) indexProvider) .with(indexProvider) - .with(queryIndexProvider); + .with(indexEditorProvider) + .with(queryIndexProvider) + .with(queryEngineSettings); if (isAsync) { oak.withAsyncIndexing("async", asyncIndexingTimeInSeconds); } Added: jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDescendantSuggestionCommonTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDescendantSuggestionCommonTest.java?rev=1880807&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDescendantSuggestionCommonTest.java (added) +++ jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDescendantSuggestionCommonTest.java Wed Aug 12 13:46:45 2020 @@ -0,0 +1,48 @@ +/* + * 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.plugins.index.elastic; + +import org.apache.jackrabbit.oak.Oak; +import org.apache.jackrabbit.oak.jcr.Jcr; +import org.apache.jackrabbit.oak.plugins.index.ElasticTestRepositoryBuilder; +import org.apache.jackrabbit.oak.plugins.index.IndexDescendantSuggestionCommonTest; +import org.junit.ClassRule; + +import javax.jcr.Repository; +import javax.jcr.RepositoryException; + +public class ElasticIndexDescendantSuggestionCommonTest extends IndexDescendantSuggestionCommonTest { + + // Set this connection string as + // <scheme>://<hostname>:<port>?key_id=<>,key_secret=<> + // key_id and key_secret are optional in case the ES server + // needs authentication + // Do not set this if docker is running and you want to run the tests on docker instead. + private static String elasticConnectionString = System.getProperty("elasticConnectionString"); + @ClassRule + public static ElasticConnectionRule elasticRule = new ElasticConnectionRule(elasticConnectionString); + + @Override + protected Repository createJcrRepository() throws RepositoryException { + indexOptions = new ElasticIndexOptions(); + repositoryOptionsUtil = new ElasticTestRepositoryBuilder(elasticRule).build(); + Oak oak = repositoryOptionsUtil.getOak(); + Jcr jcr = new Jcr(oak); + Repository repository = jcr.createRepository(); + return repository; + } +} Propchange: jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDescendantSuggestionCommonTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticSecureFacetCommonTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticSecureFacetCommonTest.java?rev=1880807&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticSecureFacetCommonTest.java (added) +++ jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticSecureFacetCommonTest.java Wed Aug 12 13:46:45 2020 @@ -0,0 +1,62 @@ +/* + * 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.plugins.index.elastic; + +import org.apache.jackrabbit.oak.Oak; +import org.apache.jackrabbit.oak.jcr.Jcr; +import org.apache.jackrabbit.oak.plugins.index.ElasticTestRepositoryBuilder; +import org.apache.jackrabbit.oak.plugins.index.SecureFacetCommonTest; +import org.apache.jackrabbit.oak.plugins.index.TestUtils; +import org.junit.After; +import org.junit.ClassRule; + +import javax.jcr.Repository; +import java.io.IOException; + +public class ElasticSecureFacetCommonTest extends SecureFacetCommonTest { + + // Set this connection string as + // <scheme>://<hostname>:<port>?key_id=<>,key_secret=<> + // key_id and key_secret are optional in case the ES server + // needs authentication + // Do not set this if docker is running and you want to run the tests on docker instead. + private static String elasticConnectionString = System.getProperty("elasticConnectionString"); + @ClassRule + public static ElasticConnectionRule elasticRule = new ElasticConnectionRule(elasticConnectionString); + + /* + Close the ES connection after every test method execution + */ + @After + public void cleanup() throws IOException { + elasticRule.closeElasticConnection(); + } + + protected Repository createJcrRepository() { + indexOptions = new ElasticIndexOptions(); + repositoryOptionsUtil = new ElasticTestRepositoryBuilder(elasticRule).build(); + Oak oak = repositoryOptionsUtil.getOak(); + Jcr jcr = new Jcr(oak); + Repository repository = jcr.createRepository(); + return repository; + } + + protected void assertEventually(Runnable r) { + TestUtils.assertEventually(r, + ((repositoryOptionsUtil.isAsync() ? repositoryOptionsUtil.defaultAsyncIndexingTimeInSeconds : 0) + ElasticIndexDefinition.BULK_FLUSH_INTERVAL_MS_DEFAULT) * 5); + } +} Propchange: jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticSecureFacetCommonTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticStrictPathRestrictionEnableCommonTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticStrictPathRestrictionEnableCommonTest.java?rev=1880807&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticStrictPathRestrictionEnableCommonTest.java (added) +++ jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticStrictPathRestrictionEnableCommonTest.java Wed Aug 12 13:46:45 2020 @@ -0,0 +1,47 @@ +/* + * 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.plugins.index.elastic; + +import org.apache.jackrabbit.oak.api.ContentRepository; +import org.apache.jackrabbit.oak.api.StrictPathRestriction; +import org.apache.jackrabbit.oak.plugins.index.ElasticTestRepositoryBuilder; +import org.apache.jackrabbit.oak.plugins.index.StrictPathRestrictionEnableCommonTest; +import org.apache.jackrabbit.oak.query.QueryEngineSettings; +import org.junit.ClassRule; + +public class ElasticStrictPathRestrictionEnableCommonTest extends StrictPathRestrictionEnableCommonTest { + + // Set this connection string as + // <scheme>://<hostname>:<port>?key_id=<>,key_secret=<> + // key_id and key_secret are optional in case the ES server + // needs authentication + // Do not set this if docker is running and you want to run the tests on docker instead. + private static String elasticConnectionString = System.getProperty("elasticConnectionString"); + @ClassRule + public static ElasticConnectionRule elasticRule = new ElasticConnectionRule(elasticConnectionString); + + @Override + protected ContentRepository createRepository() { + indexOptions = new ElasticIndexOptions(); + ElasticTestRepositoryBuilder elasticTestRepositoryBuilder = new ElasticTestRepositoryBuilder(elasticRule); + QueryEngineSettings queryEngineSettings = new QueryEngineSettings(); + queryEngineSettings.setStrictPathRestriction(StrictPathRestriction.ENABLE.name()); + elasticTestRepositoryBuilder.setQueryEngineSettings(queryEngineSettings); + repositoryOptionsUtil = elasticTestRepositoryBuilder.build(); + return repositoryOptionsUtil.getOak().createContentRepository(); + } +} Propchange: jackrabbit/oak/trunk/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticStrictPathRestrictionEnableCommonTest.java ------------------------------------------------------------------------------ svn:eol-style = native