10
10
*******************************************************************************/
11
11
package org .eclipse .rdf4j .testsuite .sparql ;
12
12
13
+ import static org .junit .jupiter .api .Assertions .fail ;
14
+
13
15
import java .io .File ;
14
16
import java .io .IOException ;
17
+ import java .util .concurrent .atomic .AtomicInteger ;
15
18
import java .util .stream .Stream ;
16
19
17
20
import org .eclipse .rdf4j .common .annotation .Experimental ;
@@ -56,92 +59,92 @@ public abstract class RepositorySPARQLComplianceTestSuite {
56
59
57
60
@ TestFactory
58
61
Stream <DynamicTest > aggregate () throws RDF4JException , IOException {
59
- return new AggregateTest (getEmptyInitializedRepository () ).tests ();
62
+ return new AggregateTest (this :: getEmptyInitializedRepository ).tests ();
60
63
}
61
64
62
65
@ TestFactory
63
66
Stream <DynamicTest > arbitraryLengthPath () throws RDF4JException , IOException {
64
- return new ArbitraryLengthPathTest (getEmptyInitializedRepository () ).tests ();
67
+ return new ArbitraryLengthPathTest (this :: getEmptyInitializedRepository ).tests ();
65
68
}
66
69
67
70
@ TestFactory
68
71
Stream <DynamicTest > basic () throws RDF4JException , IOException {
69
- return new BasicTest (getEmptyInitializedRepository () ).tests ();
72
+ return new BasicTest (this :: getEmptyInitializedRepository ).tests ();
70
73
}
71
74
72
75
@ TestFactory
73
76
Stream <DynamicTest > bind () throws RDF4JException , IOException {
74
- return new BindTest (getEmptyInitializedRepository () ).tests ();
77
+ return new BindTest (this :: getEmptyInitializedRepository ).tests ();
75
78
}
76
79
77
80
@ TestFactory
78
81
Stream <DynamicTest > builtinFunction () throws RDF4JException , IOException {
79
- return new BuiltinFunctionTest (getEmptyInitializedRepository () ).tests ();
82
+ return new BuiltinFunctionTest (this :: getEmptyInitializedRepository ).tests ();
80
83
}
81
84
82
85
@ TestFactory
83
86
Stream <DynamicTest > construct () throws RDF4JException , IOException {
84
- return new ConstructTest (getEmptyInitializedRepository () ).tests ();
87
+ return new ConstructTest (this :: getEmptyInitializedRepository ).tests ();
85
88
}
86
89
87
90
@ TestFactory
88
91
Stream <DynamicTest > defaultGraph () throws RDF4JException , IOException {
89
- return new DefaultGraphTest (getEmptyInitializedRepository () ).tests ();
92
+ return new DefaultGraphTest (this :: getEmptyInitializedRepository ).tests ();
90
93
}
91
94
92
95
@ TestFactory
93
96
Stream <DynamicTest > describe () throws RDF4JException , IOException {
94
- return new DescribeTest (getEmptyInitializedRepository () ).tests ();
97
+ return new DescribeTest (this :: getEmptyInitializedRepository ).tests ();
95
98
}
96
99
97
100
@ TestFactory
98
101
Stream <DynamicTest > groupBy () throws RDF4JException , IOException {
99
- return new GroupByTest (getEmptyInitializedRepository () ).tests ();
102
+ return new GroupByTest (this :: getEmptyInitializedRepository ).tests ();
100
103
}
101
104
102
105
@ TestFactory
103
106
Stream <DynamicTest > in () throws RDF4JException , IOException {
104
- return new InTest (getEmptyInitializedRepository () ).tests ();
107
+ return new InTest (this :: getEmptyInitializedRepository ).tests ();
105
108
}
106
109
107
110
@ TestFactory
108
111
Stream <DynamicTest > optional () throws RDF4JException , IOException {
109
- return new OptionalTest (getEmptyInitializedRepository () ).tests ();
112
+ return new OptionalTest (this :: getEmptyInitializedRepository ).tests ();
110
113
}
111
114
112
115
@ TestFactory
113
116
Stream <DynamicTest > propertyPath () throws RDF4JException , IOException {
114
- return new PropertyPathTest (getEmptyInitializedRepository () ).tests ();
117
+ return new PropertyPathTest (this :: getEmptyInitializedRepository ).tests ();
115
118
}
116
119
117
120
@ TestFactory
118
121
Stream <DynamicTest > subselect () throws RDF4JException , IOException {
119
- return new SubselectTest (getEmptyInitializedRepository () ).tests ();
122
+ return new SubselectTest (this :: getEmptyInitializedRepository ).tests ();
120
123
}
121
124
122
125
@ TestFactory
123
126
Stream <DynamicTest > union () throws RDF4JException , IOException {
124
- return new UnionTest (getEmptyInitializedRepository () ).tests ();
127
+ return new UnionTest (this :: getEmptyInitializedRepository ).tests ();
125
128
}
126
129
127
130
@ TestFactory
128
131
Stream <DynamicTest > values () throws RDF4JException , IOException {
129
- return new ValuesTest (getEmptyInitializedRepository () ).tests ();
132
+ return new ValuesTest (this :: getEmptyInitializedRepository ).tests ();
130
133
}
131
134
132
135
@ TestFactory
133
136
Stream <DynamicTest > orderBy () throws RDF4JException , IOException {
134
- return new OrderByTest (getEmptyInitializedRepository () ).tests ();
137
+ return new OrderByTest (this :: getEmptyInitializedRepository ).tests ();
135
138
}
136
139
137
140
@ TestFactory
138
141
Stream <DynamicTest > exists () throws RDF4JException , IOException {
139
- return new ExistsTest (getEmptyInitializedRepository () ).tests ();
142
+ return new ExistsTest (this :: getEmptyInitializedRepository ).tests ();
140
143
}
141
144
142
145
@ TestFactory
143
146
Stream <DynamicTest > minus () throws RDF4JException , IOException {
144
- return new MinusTest (getEmptyInitializedRepository () ).tests ();
147
+ return new MinusTest (this :: getEmptyInitializedRepository ).tests ();
145
148
}
146
149
147
150
@ BeforeAll
@@ -157,20 +160,33 @@ public static void tearDownClass() {
157
160
@ TempDir
158
161
private File dataDir ;
159
162
163
+ private static final AtomicInteger tempDirNameForRepoCounter = new AtomicInteger ();
164
+
160
165
protected final RepositoryFactory factory ;
161
166
162
167
public RepositorySPARQLComplianceTestSuite (RepositoryFactory factory ) {
163
168
super ();
164
169
this .factory = factory ;
165
170
}
166
171
167
- public Repository getEmptyInitializedRepository () throws RDF4JException , IOException {
168
- Repository repository = factory .getRepository (factory .getConfig ());
169
- repository .setDataDir (dataDir );
170
- try (RepositoryConnection con = repository .getConnection ()) {
171
- con .clear ();
172
- con .clearNamespaces ();
172
+ public Repository getEmptyInitializedRepository () {
173
+ try {
174
+ Repository repository = factory .getRepository (factory .getConfig ());
175
+ dataDir .mkdir ();
176
+ File tmpDirPerRepo = new File (dataDir , "tmpDirPerRepo" + tempDirNameForRepoCounter .getAndIncrement ());
177
+ if (!tmpDirPerRepo .mkdir ()) {
178
+ fail ("Could not create temporary directory for test" );
179
+ }
180
+ repository .setDataDir (tmpDirPerRepo );
181
+ try (RepositoryConnection con = repository .getConnection ()) {
182
+ con .clear ();
183
+ con .clearNamespaces ();
184
+ }
185
+ return repository ;
186
+
187
+ } catch (RDF4JException e ) {
188
+ fail (e );
189
+ return null ;
173
190
}
174
- return repository ;
175
191
}
176
192
}
0 commit comments