8
8
import com .google .gson .JsonObject ;
9
9
import com .hp .hpl .jena .query .Dataset ;
10
10
import com .hp .hpl .jena .rdf .model .Model ;
11
- import com .hp .hpl .jena .rdf .model .ModelFactory ;
12
11
import com .hp .hpl .jena .rdf .model .Property ;
13
12
import com .hp .hpl .jena .rdf .model .Resource ;
14
13
import com .hp .hpl .jena .tdb .TDBFactory ;
@@ -32,6 +31,8 @@ public class JenaTDBDataSourceTest {
32
31
private static Dataset dataset ;
33
32
private static File jena ;
34
33
34
+ private final static String PREFIX = "http://test.ldf.org/" ;
35
+
35
36
@ BeforeClass
36
37
public static void setUpClass () throws Exception {
37
38
String tmpdir = System .getProperty ("java.io.tmpdir" );
@@ -54,8 +55,13 @@ public static void setUpClass() throws Exception {
54
55
55
56
@ AfterClass
56
57
public static void tearDownClass () throws Exception {
57
- dataset .end ();
58
58
TDBFactory .release (dataset );
59
+ File [] files = jena .listFiles ();
60
+ for (File f : files ) {
61
+ f .delete ();
62
+ }
63
+ jena .delete ();
64
+
59
65
}
60
66
61
67
@ Before
@@ -68,16 +74,16 @@ public void setUp() throws Exception {
68
74
int objs = 17 ;
69
75
70
76
for (int s = 0 ; s < subjs ; s ++) {
71
- Resource subj = model .createResource ("http://test.ldf.org/ s/" + s );
77
+ Resource subj = model .createResource (PREFIX + " s/" + s );
72
78
for (int p = 0 ; p < preds ; p ++) {
73
- Property pred = model .createProperty ("http://test.ldf.org/ p/" + p );
79
+ Property pred = model .createProperty (PREFIX + " p/" + p );
74
80
for (int o = 0 ; o < objs ; o ++) {
75
- Resource obj = model .createResource ("http://test.ldf.org/ o/" + o );
81
+ Resource obj = model .createResource (PREFIX + " o/" + o );
76
82
model .add (subj , pred , obj );
77
83
}
78
84
}
79
85
}
80
- model .commit ();
86
+ model .close ();
81
87
}
82
88
83
89
/**
@@ -88,21 +94,21 @@ public void setUp() throws Exception {
88
94
public void testEstimate () {
89
95
Model model = dataset .getDefaultModel ();
90
96
91
- Resource subj = model .createResource ("http://test.ldf.org/ s/1" );
97
+ Resource subj = model .createResource (PREFIX + " s/1" );
92
98
Property pred = null ;
93
99
Resource obj = null ;
94
100
95
101
long offset = 0 ;
96
102
long limit = 50 ;
103
+
97
104
TriplePatternFragment fragment =
98
105
tdb .getFragment (subj , pred , obj , offset , limit );
99
106
long totalSize = fragment .getTotalSize ();
100
-
101
- Assert .assertTrue ("Estimate is fake" , totalSize != 51 );
107
+
108
+ Assert .assertTrue ("Estimate is fake: " + totalSize , totalSize != 51 );
102
109
}
103
110
104
111
@ After
105
112
public void tearDown () throws Exception {
106
113
}
107
-
108
114
}
0 commit comments