88import com .google .gson .JsonObject ;
99import com .hp .hpl .jena .query .Dataset ;
1010import com .hp .hpl .jena .rdf .model .Model ;
11- import com .hp .hpl .jena .rdf .model .ModelFactory ;
1211import com .hp .hpl .jena .rdf .model .Property ;
1312import com .hp .hpl .jena .rdf .model .Resource ;
1413import com .hp .hpl .jena .tdb .TDBFactory ;
@@ -32,6 +31,8 @@ public class JenaTDBDataSourceTest {
3231 private static Dataset dataset ;
3332 private static File jena ;
3433
34+ private final static String PREFIX = "http://test.ldf.org/" ;
35+
3536 @ BeforeClass
3637 public static void setUpClass () throws Exception {
3738 String tmpdir = System .getProperty ("java.io.tmpdir" );
@@ -54,8 +55,13 @@ public static void setUpClass() throws Exception {
5455
5556 @ AfterClass
5657 public static void tearDownClass () throws Exception {
57- dataset .end ();
5858 TDBFactory .release (dataset );
59+ File [] files = jena .listFiles ();
60+ for (File f : files ) {
61+ f .delete ();
62+ }
63+ jena .delete ();
64+
5965 }
6066
6167 @ Before
@@ -68,16 +74,16 @@ public void setUp() throws Exception {
6874 int objs = 17 ;
6975
7076 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 );
7278 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 );
7480 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 );
7682 model .add (subj , pred , obj );
7783 }
7884 }
7985 }
80- model .commit ();
86+ model .close ();
8187 }
8288
8389 /**
@@ -88,21 +94,21 @@ public void setUp() throws Exception {
8894 public void testEstimate () {
8995 Model model = dataset .getDefaultModel ();
9096
91- Resource subj = model .createResource ("http://test.ldf.org/ s/1" );
97+ Resource subj = model .createResource (PREFIX + " s/1" );
9298 Property pred = null ;
9399 Resource obj = null ;
94100
95101 long offset = 0 ;
96102 long limit = 50 ;
103+
97104 TriplePatternFragment fragment =
98105 tdb .getFragment (subj , pred , obj , offset , limit );
99106 long totalSize = fragment .getTotalSize ();
100-
101- Assert .assertTrue ("Estimate is fake" , totalSize != 51 );
107+
108+ Assert .assertTrue ("Estimate is fake: " + totalSize , totalSize != 51 );
102109 }
103110
104111 @ After
105112 public void tearDown () throws Exception {
106113 }
107-
108114}
0 commit comments