diff --git a/extensions/indexes/indexes-integration-tests/src/test/java/org/exist/indexing/EnforceIndexUseTest.java b/extensions/indexes/indexes-integration-tests/src/test/java/org/exist/indexing/EnforceIndexUseTest.java index d26ea5cdf72..1a0c2db5939 100644 --- a/extensions/indexes/indexes-integration-tests/src/test/java/org/exist/indexing/EnforceIndexUseTest.java +++ b/extensions/indexes/indexes-integration-tests/src/test/java/org/exist/indexing/EnforceIndexUseTest.java @@ -48,19 +48,13 @@ public static java.util.Collection data() { @Parameterized.Parameter public String enforceIndexUseValue; + // always means the database will only get results from the collections indexed by range index it will ignore un-indexed collections + // strict means it will get results from all the collections and will not ignore un-indexed @Parameterized.Parameter(value = 1) public int expectedSearchCount; - @ClassRule - public static final ExistEmbeddedServer existEmbeddedServer = new ExistEmbeddedServer( - propertiesBuilder() - .put(XQueryContext.PROPERTY_ENFORCE_INDEX_USE, "always") // always means the database will only get results from the collections indexed by range index it will ignore un-indexed collections - // strict means it will get results from all the collections and will not ignore un-indexed - // this value is changed in LINE 125 in this file - .build(), - true, - true); + private ExistEmbeddedServer existEmbeddedServer; private static final String OLD_RANGE_COLLECTION_CONFIG = "\n" + " \n" + @@ -78,8 +72,8 @@ public static java.util.Collection data() { private static final String XML = "\n" + - "\n" + - ""; + "\n" + + ""; @Test public void matchesWithDiffrentIndexStyles() throws PermissionDeniedException, EXistException, XPathException { @@ -117,11 +111,18 @@ private DocumentSet configureAndStore(final String configuration, final String d return docs; } + @Before - public void setup() throws PermissionDeniedException, IOException, SAXException, URISyntaxException, LockException, CollectionConfigurationException, EXistException{ - final BrokerPool pool = existEmbeddedServer.getBrokerPool(); + public void setup() throws Throwable { + existEmbeddedServer = new ExistEmbeddedServer( + propertiesBuilder() + .put(XQueryContext.PROPERTY_ENFORCE_INDEX_USE, enforceIndexUseValue).build() + ,true + ,true); - pool.getConfiguration().setProperty(XQueryContext.PROPERTY_ENFORCE_INDEX_USE, enforceIndexUseValue); + existEmbeddedServer.startDb(); + + final BrokerPool pool = existEmbeddedServer.getBrokerPool(); final TransactionManager transact = pool.getTransactionManager(); try(final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject())); @@ -132,10 +133,10 @@ public void setup() throws PermissionDeniedException, IOException, SAXException, final Collection oldRange = broker.getOrCreateCollection(transaction, XmldbURI.xmldbUriFor(TestConstants.TEST_COLLECTION_URI + "old-range-index")); final Collection noRange = broker.getOrCreateCollection(transaction, XmldbURI.xmldbUriFor(TestConstants.TEST_COLLECTION_URI + "no-range-index"))){ - broker.saveCollection(transaction, newRange); - broker.saveCollection(transaction, test); - broker.saveCollection(transaction, oldRange); - broker.saveCollection(transaction, noRange); + broker.saveCollection(transaction, newRange); + broker.saveCollection(transaction, test); + broker.saveCollection(transaction, oldRange); + broker.saveCollection(transaction, noRange); } transaction.commit(); @@ -165,5 +166,8 @@ public void cleanup() throws EXistException, PermissionDeniedException, IOExcept transaction.commit(); } + + existEmbeddedServer.stopDb(true); + existEmbeddedServer = null; } } \ No newline at end of file