Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
eclipse-rdf4j/rdf4j#1246 shutdown repo to cause error
Browse files Browse the repository at this point in the history
Signed-off-by: Håvard Ottestad <[email protected]>
  • Loading branch information
hmottestad committed Jan 19, 2019
1 parent ea3091b commit 0f0c3e1
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/ShaclTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.eclipse.rdf4j.sail.shacl;

import org.eclipse.rdf4j.IsolationLevels;
import org.eclipse.rdf4j.common.concurrent.locks.Properties;
import org.eclipse.rdf4j.common.io.IOUtil;
import org.eclipse.rdf4j.repository.RepositoryException;
import org.eclipse.rdf4j.repository.sail.SailRepository;
Expand Down Expand Up @@ -154,28 +155,32 @@ private void runTestCase(String shaclPath, String dataPath, ExpectedResult expec
for (int j = 0; j < 100; j++) {

String name = dataPath + "query" + j + ".rq";
InputStream resourceAsStream = ShaclTest.class.getClassLoader().getResourceAsStream(name);
if (resourceAsStream == null) {
continue;
}
try (InputStream resourceAsStream = ShaclTest.class.getClassLoader().getResourceAsStream(name)) {
if (resourceAsStream == null) {
continue;
}

ran = true;
System.out.println(name);
ran = true;
System.out.println(name);

try (SailRepositoryConnection connection = shaclSail.getConnection()) {
connection.begin();
String query = IOUtil.readString(resourceAsStream);
connection.prepareUpdate(query).execute();
connection.commit();
} catch (RepositoryException sailException) {
exception = true;
System.out.println(sailException.getMessage());
try (SailRepositoryConnection connection = shaclSail.getConnection()) {
connection.begin(IsolationLevels.SNAPSHOT);
String query = IOUtil.readString(resourceAsStream);
connection.prepareUpdate(query).execute();
connection.commit();
} catch (RepositoryException sailException) {
exception = true;
System.out.println(sailException.getMessage());

}
} catch (IOException e) {
e.printStackTrace();
}

}

shaclSail.shutDown();

if (ran) {
if (expectedResult == ExpectedResult.valid) {
assertFalse("Expected transaction to succeed", exception);
Expand Down

0 comments on commit 0f0c3e1

Please sign in to comment.