Index: oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreLuceneIndexTest.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreLuceneIndexTest.java (revision 1868136) +++ oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreLuceneIndexTest.java (date 1570541288125) @@ -26,6 +26,7 @@ import org.apache.jackrabbit.oak.spi.mount.MountInfoProvider; import org.apache.jackrabbit.oak.spi.mount.Mounts; import org.apache.jackrabbit.oak.spi.state.NodeStore; +import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -73,9 +74,12 @@ repoV1.initCompositeRepo(); } - @Override - public void closeRepositories() throws Exception { + @After + public void tearDown() throws Exception { repoV1.cleanup(); + if (repoV2 != null) { + repoV2.cleanup(); + } } /** @@ -293,9 +297,6 @@ result = repoV1.executeQuery("/jcr:root//*[@foo3 = 'bar'] order by @jcr:path", "xpath"); assertEquals("/content-foo3/node-0, " + "/content-foo3/node-1", getResult(result, "jcr:path")); - - repoV1.cleanup(); - repoV2.cleanup(); } private static String getResult(QueryResult result, String propertyName) throws RepositoryException { Index: oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreQueryTest.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreQueryTest.java (revision 1868136) +++ oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreQueryTest.java (date 1570533838960) @@ -179,7 +179,7 @@ } - public void createLuceneIndex(NodeBuilder b) { + private void createLuceneIndex(NodeBuilder b) { b = b.child(INDEX_DEFINITIONS_NAME).child("lucene"); b.setProperty(JCR_PRIMARYTYPE, INDEX_DEFINITIONS_NODE_TYPE, NAME); b.setProperty(TYPE_PROPERTY_NAME, LuceneIndexConstants.TYPE_LUCENE); @@ -225,26 +225,25 @@ NodeBuilder builder; builder = store.getRoot().builder(); - builder.child(INDEX_DEFINITIONS_NAME).child("lucene").setProperty(REINDEX_PROPERTY_NAME,true); store.merge(builder, hook, CommitInfo.EMPTY); root.commit(); assertEquals(builder.child(INDEX_DEFINITIONS_NAME).child("lucene").getProperty(REINDEX_COUNT).getValue(Type.STRING),"2"); - - } @Test public void luceneIndex() throws Exception { // create an index in both the read-only and the read-write store NodeBuilder readOnlyBuilder = readOnlyStore.getRoot().builder(); + // add nodes in the read-only area for (int i = 0; i < 3; i++) { NodeBuilder b = readOnlyBuilder.child("readOnly").child("node-" + i); b.setProperty("asyncFoo", "bar"); b.setProperty("jcr:primaryType", "nt:base", Type.NAME); } + createLuceneIndex(readOnlyBuilder); NodeBuilder globalBuilder = globalStore.getRoot().builder(); @@ -253,9 +252,6 @@ LuceneIndexEditorProvider iep = new LuceneIndexEditorProvider(indexCopier, indexTracker, null, null, mip); EditorHook hook = new EditorHook( new IndexUpdateProvider(iep, "async", false)); - readOnlyStore.merge(readOnlyBuilder, hook, CommitInfo.EMPTY); - globalStore.merge(globalBuilder, hook, CommitInfo.EMPTY); - root.commit(); readOnlyStore.merge(readOnlyBuilder, hook, CommitInfo.EMPTY); globalStore.merge(globalBuilder, hook, CommitInfo.EMPTY); @@ -263,8 +259,6 @@ indexTracker.update(readOnlyStore.getRoot()); indexTracker.update(globalStore.getRoot()); - // add nodes in the read-only area - // run a query // need to login again to see changes in the read-only area session = createRepository(store).login(null, null); @@ -280,8 +274,7 @@ executeQuery("/jcr:root//*[@asyncFoo = 'bar']", "xpath").toString()); // add nodes in the read-write area - NodeBuilder builder; - builder = store.getRoot().builder(); + NodeBuilder builder = store.getRoot().builder(); for (int i = 0; i < 3; i++) { builder.child("content").child("node-" + i).setProperty("asyncFoo", "bar"); } Index: oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreQueryTestBase.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreQueryTestBase.java (revision 1868136) +++ oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreQueryTestBase.java (date 1570548269486) @@ -55,6 +55,7 @@ import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.jcr.Jcr; import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore; +import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreBuilder; import org.apache.jackrabbit.oak.plugins.document.rdb.RDBDataSourceFactory; import org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentNodeStoreBuilder; import org.apache.jackrabbit.oak.plugins.document.rdb.RDBOptions; @@ -137,13 +138,14 @@ @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(new File("target")); - @Parameters(name="Root: {0}, Mounts: {1}") + @Parameters(name = "Root: {0}, Mounts: {1}") public static Collection data() { - return Arrays.asList(new Object[][] { - { NodeStoreKind.MEMORY, NodeStoreKind.MEMORY }, - { NodeStoreKind.SEGMENT, NodeStoreKind.SEGMENT} -// { NodeStoreKind.DOCUMENT_H2, NodeStoreKind.DOCUMENT_H2}, -// { NodeStoreKind.DOCUMENT_H2, NodeStoreKind.SEGMENT} + return Arrays.asList(new Object[][]{ + {NodeStoreKind.MEMORY, NodeStoreKind.MEMORY}, + {NodeStoreKind.SEGMENT, NodeStoreKind.SEGMENT}, + {NodeStoreKind.DOCUMENT_H2, NodeStoreKind.DOCUMENT_H2}, + {NodeStoreKind.DOCUMENT_H2, NodeStoreKind.SEGMENT}, + {NodeStoreKind.DOCUMENT_MEMORY, NodeStoreKind.DOCUMENT_MEMORY} }); } @@ -406,7 +408,7 @@ } @After - public void closeRepositories() throws Exception { + public final void baseTearDown() throws Exception { for ( NodeStoreRegistration reg : registrations ) { reg.close(); } @@ -486,25 +488,26 @@ } }, DOCUMENT_H2 { - // TODO - copied from DocumentRdbFixture - - private DataSource ds; - @Override public NodeStoreRegistration create(final String name) { return new NodeStoreRegistration() { private DocumentNodeStore instance; + private String dbPath; + + // TODO - copied from DocumentRdbFixture + + private DataSource ds; @Override public NodeStore get(TemporaryFolder temporaryFolder) throws Exception { RDBOptions options = new RDBOptions().dropTablesOnClose(true); - String jdbcUrl = "jdbc:h2:file:" + temporaryFolder.getRoot().getAbsolutePath() + "/document"; + dbPath = temporaryFolder.getRoot().getAbsolutePath() + "/document"; if ( name != null ) { - jdbcUrl += "-" + name; + dbPath += "-" + name; } - ds = RDBDataSourceFactory.forJdbcUrl(jdbcUrl, "sa", ""); + ds = RDBDataSourceFactory.forJdbcUrl("jdbc:h2:file:" + dbPath, "sa", ""); instance = new RDBDocumentNodeStoreBuilder() .setRDBConnection(ds, options).build(); @@ -520,8 +523,33 @@ if ( ds instanceof Closeable ) { ((Closeable) ds).close(); } + FileUtils.deleteQuietly(new File(dbPath)); + } + + }; + + } + }, DOCUMENT_MEMORY { + @Override + public NodeStoreRegistration create(final String name) { + + return new NodeStoreRegistration() { + + private DocumentNodeStore instance; + + @Override + public NodeStore get(TemporaryFolder temporaryFolder) throws Exception { + DocumentNodeStoreBuilder documentNodeStoreBuilder = DocumentNodeStoreBuilder.newDocumentNodeStoreBuilder(); + + instance = documentNodeStoreBuilder.build(); + + return instance; } + @Override + public void close() { + instance.dispose(); + } }; } Index: oak-lucene/pom.xml IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-lucene/pom.xml (revision 1868136) +++ oak-lucene/pom.xml (date 1569332600011) @@ -421,6 +421,17 @@ docker-junit-rule test + + com.h2database + h2 + ${h2.version} + test + + + org.apache.tomcat + tomcat-jdbc + test +