Skip to content

Commit

Permalink
GH-4886 mint new directories for the LmdbStore tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hmottestad committed Jan 29, 2024
1 parent 5d82552 commit 6824528
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package org.eclipse.rdf4j.sail.lmdb;

import java.io.File;
import java.util.UUID;

import org.eclipse.rdf4j.repository.Repository;
import org.eclipse.rdf4j.repository.dataset.DatasetRepository;
Expand All @@ -29,7 +30,11 @@ public class LmdbPARQL11UpdateComplianceTest extends SPARQL11UpdateComplianceTes

@Override
protected Repository newRepository() throws Exception {

var temp = new File(folder, UUID.randomUUID().toString());
temp.mkdir();

return new DatasetRepository(
new SailRepository(new LmdbStore(folder, new LmdbStoreConfig("spoc"))));
new SailRepository(new LmdbStore(temp, new LmdbStoreConfig("spoc"))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package org.eclipse.rdf4j.sail.lmdb;

import java.io.File;
import java.util.UUID;

import org.eclipse.rdf4j.repository.Repository;
import org.eclipse.rdf4j.repository.dataset.DatasetRepository;
Expand All @@ -29,8 +30,10 @@ public class LmdbSPARQL11QueryComplianceTest extends SPARQL11QueryComplianceTest

@Override
protected Repository newRepository() throws Exception {
var temp = new File(folder, UUID.randomUUID().toString());
temp.mkdir();
return new DatasetRepository(
new SailRepository(new LmdbStore(folder, new LmdbStoreConfig("spoc"))));
new SailRepository(new LmdbStore(temp, new LmdbStoreConfig("spoc"))));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -134,48 +134,41 @@ protected final void runTest() throws Exception {

logger.debug("running {}", getName());

RepositoryConnection con = dataRep.getConnection();
RepositoryConnection erCon = expectedResultRepo.getConnection();
try {
String updateString = readUpdateString();
try (RepositoryConnection con = dataRep.getConnection()) {
try (RepositoryConnection erCon = expectedResultRepo.getConnection()) {
String updateString = readUpdateString();

con.begin();
con.begin();

Update update = con.prepareUpdate(QueryLanguage.SPARQL, updateString, requestFile);
Update update = con.prepareUpdate(QueryLanguage.SPARQL, updateString, requestFile);

assertThatNoException().isThrownBy(() -> {
int hashCode = update.hashCode();
if (hashCode == System.identityHashCode(update)) {
throw new UnsupportedOperationException(
"hashCode() result is the same as the identityHashCode in "
+ update.getClass().getName());
}
});
assertThatNoException().isThrownBy(() -> {
int hashCode = update.hashCode();
if (hashCode == System.identityHashCode(update)) {
throw new UnsupportedOperationException(
"hashCode() result is the same as the identityHashCode in "
+ update.getClass().getName());
}
});

update.setDataset(dataset);
update.execute();
update.setDataset(dataset);
update.execute();

con.commit();
con.commit();

// check default graph
logger.info("checking default graph");
compareGraphs(Iterations.asList(con.getStatements(null, null, null, true, (Resource) null)),
Iterations.asList(erCon.getStatements(null, null, null, true, (Resource) null)));
// check default graph
logger.info("checking default graph");
compareGraphs(Iterations.asList(con.getStatements(null, null, null, true, (Resource) null)),
Iterations.asList(erCon.getStatements(null, null, null, true, (Resource) null)));

for (String namedGraph : inputNamedGraphs.keySet()) {
logger.info("checking named graph {}", namedGraph);
IRI contextURI = con.getValueFactory().createIRI(namedGraph.replaceAll("\"", ""));
compareGraphs(Iterations.asList(con.getStatements(null, null, null, true, contextURI)),
Iterations.asList(erCon.getStatements(null, null, null, true, contextURI)));
}

for (String namedGraph : inputNamedGraphs.keySet()) {
logger.info("checking named graph {}", namedGraph);
IRI contextURI = con.getValueFactory().createIRI(namedGraph.replaceAll("\"", ""));
compareGraphs(Iterations.asList(con.getStatements(null, null, null, true, contextURI)),
Iterations.asList(erCon.getStatements(null, null, null, true, contextURI)));
}
} catch (Exception e) {
if (con.isActive()) {
con.rollback();
}
throw e;
} finally {
con.close();
erCon.close();
}
}

Expand Down Expand Up @@ -229,7 +222,7 @@ public void setUp() throws Exception {
}

@Override
public void tearDown() throws Exception {
public void tearDown() {
if (dataRep != null) {
clear(dataRep);
dataRep.shutDown();
Expand Down

0 comments on commit 6824528

Please sign in to comment.