Skip to content

Commit

Permalink
use Parameterized value for enforceIndexUseValue
Browse files Browse the repository at this point in the history
  • Loading branch information
marmoure committed May 11, 2023
1 parent 37a2446 commit e8c9b5f
Showing 1 changed file with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,13 @@ public static java.util.Collection<Object[]> data() {

@Parameterized.Parameter
public String enforceIndexUseValue;

Check notice on line 50 in extensions/indexes/indexes-integration-tests/src/test/java/org/exist/indexing/EnforceIndexUseTest.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

extensions/indexes/indexes-integration-tests/src/test/java/org/exist/indexing/EnforceIndexUseTest.java#L50

Fields should be declared at the top of the class, before any method declarations, constructors, initializers or inner classes.
// 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;

Check notice on line 55 in extensions/indexes/indexes-integration-tests/src/test/java/org/exist/indexing/EnforceIndexUseTest.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

extensions/indexes/indexes-integration-tests/src/test/java/org/exist/indexing/EnforceIndexUseTest.java#L55

Fields should be declared at the top of the class, before any method declarations, constructors, initializers or inner classes.

@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;

Check notice on line 57 in extensions/indexes/indexes-integration-tests/src/test/java/org/exist/indexing/EnforceIndexUseTest.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

extensions/indexes/indexes-integration-tests/src/test/java/org/exist/indexing/EnforceIndexUseTest.java#L57

Fields should be declared at the top of the class, before any method declarations, constructors, initializers or inner classes.
private static final String OLD_RANGE_COLLECTION_CONFIG =

Check notice on line 58 in extensions/indexes/indexes-integration-tests/src/test/java/org/exist/indexing/EnforceIndexUseTest.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

extensions/indexes/indexes-integration-tests/src/test/java/org/exist/indexing/EnforceIndexUseTest.java#L58

Fields should be declared at the top of the class, before any method declarations, constructors, initializers or inner classes.
"<collection xmlns=\"http://exist-db.org/collection-config/1.0\">\n" +
" <index xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n" +
Expand All @@ -78,8 +72,8 @@ public static java.util.Collection<Object[]> data() {

private static final String XML =

Check notice on line 73 in extensions/indexes/indexes-integration-tests/src/test/java/org/exist/indexing/EnforceIndexUseTest.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

extensions/indexes/indexes-integration-tests/src/test/java/org/exist/indexing/EnforceIndexUseTest.java#L73

Fields should be declared at the top of the class, before any method declarations, constructors, initializers or inner classes.
"<root>\n" +
"<foo bar=\"baz\"/>\n" +
"</root>";
"<foo bar=\"baz\"/>\n" +
"</root>";

@Test
public void matchesWithDiffrentIndexStyles() throws PermissionDeniedException, EXistException, XPathException {
Expand Down Expand Up @@ -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()));
Expand All @@ -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();
Expand Down Expand Up @@ -165,5 +166,8 @@ public void cleanup() throws EXistException, PermissionDeniedException, IOExcept

transaction.commit();
}

existEmbeddedServer.stopDb(true);
existEmbeddedServer = null;
}
}

0 comments on commit e8c9b5f

Please sign in to comment.