Skip to content

Commit c162d02

Browse files
GH-5397 Fix incorrect SHACL format inference
1 parent be76402 commit c162d02

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

tools/console/src/main/java/org/eclipse/rdf4j/console/command/Verify.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ private void shacl(String dataPath, String shaclPath, String reportFile) {
186186
writeln("Loading shapes from " + shaclPath);
187187

188188
URL shaclURL = new URL(shaclPath);
189-
RDFFormat format = Rio.getParserFormatForFileName(reportFile).orElse(RDFFormat.TURTLE);
189+
RDFFormat format = Rio.getParserFormatForFileName(shaclPath).orElse(RDFFormat.TURTLE);
190190

191191
try (SailRepositoryConnection conn = repo.getConnection()) {
192192
conn.begin(IsolationLevels.NONE, ShaclSail.TransactionSettings.ValidationApproach.Disabled);

tools/console/src/test/java/org/eclipse/rdf4j/console/command/VerifyTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,25 @@ public final void testShaclValid() throws IOException {
127127
assertFalse(io.wasErrorWritten());
128128
}
129129

130+
@Test
131+
public final void testShaclInvalidFormat() throws IOException {
132+
File report = new File(locationFile, "testShaclInvalid.nt");
133+
cmd.execute("verify", copyFromRes("ok.ttl"), copyFromRes("shacl_invalid.ttl"), report.toString());
134+
assertTrue(io.wasErrorWritten());
135+
assertTrue(Files.size(report.toPath()) > 0);
136+
}
137+
138+
@Test
139+
public final void testShaclValidFormat() throws IOException {
140+
File report = new File(locationFile, "testShaclValid.nt");
141+
assertTrue(report.createNewFile());
142+
cmd.execute("verify", copyFromRes("ok.ttl"), copyFromRes("shacl_valid.ttl"), report.toString());
143+
144+
verify(mockConsoleIO, never()).writeError(anyString());
145+
assertFalse(Files.size(report.toPath()) > 0);
146+
assertFalse(io.wasErrorWritten());
147+
}
148+
130149
@Test
131150
public final void testShaclValidWorkDir() throws IOException {
132151
setWorkingDir(cmd);

0 commit comments

Comments
 (0)