Skip to content

Commit 92a5f68

Browse files
committed
GH-5167 add tests
1 parent b7dccf4 commit 92a5f68

93 files changed

Lines changed: 1591 additions & 7 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/AbstractShaclTest.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
package org.eclipse.rdf4j.sail.shacl;
1313

14+
import static org.junit.jupiter.api.parallel.ExecutionMode.CONCURRENT;
1415
import static org.junit.jupiter.params.provider.Arguments.arguments;
1516

1617
import java.io.File;
@@ -83,6 +84,7 @@
8384
import org.junit.jupiter.api.AfterEach;
8485
import org.junit.jupiter.api.Assertions;
8586
import org.junit.jupiter.api.BeforeAll;
87+
import org.junit.jupiter.api.parallel.Execution;
8688
import org.junit.jupiter.api.parallel.Isolated;
8789
import org.junit.jupiter.params.provider.Arguments;
8890
import org.slf4j.Logger;
@@ -117,7 +119,7 @@ abstract public class AbstractShaclTest {
117119
"test-cases/path/zeroOrOnePath"
118120

119121
);
120-
public static final Set<IsolationLevels> ISOLATION_LEVELS = Set.of(
122+
public static final List<IsolationLevels> ISOLATION_LEVELS = List.of(
121123
IsolationLevels.NONE,
122124
IsolationLevels.SNAPSHOT,
123125
IsolationLevels.SERIALIZABLE
@@ -555,16 +557,21 @@ void referenceImplementationTestCaseValidation(TestCase testCase) {
555557
return;
556558
}
557559

558-
// uses rsx:nodeShape
560+
// uses rsx:targetShape
559561
if (testCase.testCasePath.startsWith("test-cases/qualifiedShape/complex/")) {
560562
return;
561563
}
562564

563-
// uses rsx:nodeShape
565+
// uses rsx:targetShape
564566
if (testCase.testCasePath.startsWith("test-cases/complex/targetShapeAndQualifiedShape/")) {
565567
return;
566568
}
567569

570+
// uses rsx:targetShape
571+
if (testCase.testCasePath.startsWith("test-cases/path/sequencePathTargetShape")) {
572+
return;
573+
}
574+
568575
// sh:shapesGraph
569576
if (testCase.testCasePath.startsWith("test-cases/datatype/simpleNamedGraph/")) {
570577
return;
@@ -1055,7 +1062,13 @@ void runParsingTest(TestCase testCase) {
10551062
return;
10561063
}
10571064

1058-
SailRepository shaclRepository = getShaclSail(testCase);
1065+
SailRepository shaclRepository;
1066+
try {
1067+
shaclRepository = getShaclSail(testCase);
1068+
} catch (Exception e) {
1069+
System.err.println(testCase.getTestCasePath() + "shacl.trig");
1070+
throw e;
1071+
}
10591072
try {
10601073

10611074
List<ContextWithShape> shapes = ((ShaclSail) shaclRepository.getSail()).getCachedShapes()

core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/Utils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public static void loadInitialData(SailRepository repo, String resourceName) thr
137137

138138
try (RepositoryConnection conn = repo.getConnection()) {
139139
conn.begin(IsolationLevels.NONE, ShaclSail.TransactionSettings.ValidationApproach.Disabled);
140-
conn.add(initialData, "", RDFFormat.TURTLE);
140+
conn.add(initialData, "", RDFFormat.TRIG);
141141
conn.commit();
142142
}
143143
}

core/sail/shacl/src/test/resources/test-cases/hasValue/targetShapeAnd3/invalid/case3/query1.rq

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
55
PREFIX sh: <http://www.w3.org/ns/shacl#>
66
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
77

8-
DELETE DATA {
9-
ex:validPerson1 ex:info "red" .
8+
INSERT DATA {
9+
ex:validPerson1 ex:info "blue", "red" .
1010
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
PREFIX ex: <http://example.com/ns#>
2+
PREFIX owl: <http://www.w3.org/2002/07/owl#>
3+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
4+
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
5+
PREFIX sh: <http://www.w3.org/ns/shacl#>
6+
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
7+
8+
DELETE DATA {
9+
ex:validPerson1 ex:info "red" .
10+
}

core/sail/shacl/src/test/resources/test-cases/hasValue/targetShapeAnd3/invalid/case3/initialData.trig renamed to core/sail/shacl/src/test/resources/test-cases/hasValue/targetShapeAnd3/invalid/case4/initialData.trig

File renamed without changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
PREFIX ex: <http://example.com/ns#>
2+
PREFIX owl: <http://www.w3.org/2002/07/owl#>
3+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
4+
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
5+
PREFIX sh: <http://www.w3.org/ns/shacl#>
6+
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
7+
8+
DELETE DATA {
9+
ex:validPerson1 ex:info "red" .
10+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@prefix ex: <http://example.com/ns#> .
2+
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
3+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
4+
@prefix sh: <http://www.w3.org/ns/shacl#> .
5+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
6+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
7+
@prefix rsx: <http://rdf4j.org/shacl-extensions#> .
8+
@prefix rdf4j: <http://rdf4j.org/schema/rdf4j#> .
9+
10+
[] a sh:ValidationReport;
11+
rdf4j:truncated false;
12+
sh:conforms false;
13+
sh:result [ a sh:ValidationResult;
14+
rsx:shapesGraph rdf4j:SHACLShapeGraph;
15+
sh:focusNode ex:validPerson1;
16+
sh:resultPath ex:info2;
17+
sh:resultSeverity sh:Violation;
18+
sh:sourceConstraintComponent sh:MinCountConstraintComponent;
19+
sh:sourceShape [ a sh:PropertyShape;
20+
sh:minCount 1;
21+
sh:path ex:info2
22+
]
23+
] .
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
PREFIX ex: <http://example.com/ns#>
2+
PREFIX owl: <http://www.w3.org/2002/07/owl#>
3+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
4+
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
5+
PREFIX sh: <http://www.w3.org/ns/shacl#>
6+
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
7+
8+
INSERT DATA {
9+
10+
ex:person1 a ex:Person.
11+
12+
ex:person1 ex:knows1 ex:person2 .
13+
ex:person2 ex:knows2 ex:person3 .
14+
ex:person3 ex:knows3 ex:person4 .
15+
ex:person4 ex:knows4 ex:person5 .
16+
ex:person5 ex:knows5 ex:person6 .
17+
ex:person6 ex:knows6 ex:person7 .
18+
ex:person7 ex:knows7 ex:person8 .
19+
ex:person8 ex:knows8 ex:person9 .
20+
ex:person9 ex:knows9 ex:person10 .
21+
ex:person10 ex:knows10 ex:person11 .
22+
ex:person11 rdf:type ex:NotPerson .
23+
24+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@prefix ex: <http://example.com/ns#> .
2+
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
3+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
4+
@prefix sh: <http://www.w3.org/ns/shacl#> .
5+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
6+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
7+
@prefix rsx: <http://rdf4j.org/shacl-extensions#> .
8+
@prefix rdf4j: <http://rdf4j.org/schema/rdf4j#> .
9+
10+
[] a sh:ValidationReport;
11+
rdf4j:truncated false;
12+
sh:conforms false;
13+
sh:result [ a sh:ValidationResult;
14+
rsx:shapesGraph rdf4j:SHACLShapeGraph;
15+
sh:focusNode ex:person6;
16+
sh:resultPath _:dc6027fb6bea4bc5aa60e7ed606c2db116354;
17+
sh:resultSeverity sh:Violation;
18+
sh:sourceConstraintComponent sh:HasValueConstraintComponent;
19+
sh:sourceShape [ a sh:PropertyShape;
20+
sh:hasValue ex:Person;
21+
sh:path _:dc6027fb6bea4bc5aa60e7ed606c2db116354
22+
]
23+
] .
24+
25+
_:dc6027fb6bea4bc5aa60e7ed606c2db116354 rdf:first ex:knows6;
26+
rdf:rest (ex:knows7 ex:knows8 ex:knows9 ex:knows10 rdf:type) .
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
PREFIX ex: <http://example.com/ns#>
2+
PREFIX owl: <http://www.w3.org/2002/07/owl#>
3+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
4+
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
5+
PREFIX sh: <http://www.w3.org/ns/shacl#>
6+
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
7+
8+
INSERT DATA {
9+
10+
ex:person1 a ex:Person.
11+
12+
ex:person1 ex:knows1 ex:person2 .
13+
ex:person2 ex:knows2 ex:person3 .
14+
ex:person3 ex:knows3 ex:person4 .
15+
ex:person4 ex:knows4 ex:person5 .
16+
ex:person5 ex:knows5 ex:person6 .
17+
ex:person6 ex:knows6 ex:person7 .
18+
ex:person7 ex:knows7 ex:person8 .
19+
ex:person8 ex:knows8 ex:person9 .
20+
ex:person9 ex:knows9 ex:person10 .
21+
ex:person10 ex:knows10 ex:person11 .
22+
ex:person11 rdf:type ex:Person .
23+
}

0 commit comments

Comments
 (0)