1 28 29 package com.hp.hpl.jena.regression; 30 31 import com.hp.hpl.jena.rdf.model.*; 32 33 34 import junit.framework.TestCase; 35 36 57 public class TestCaseBasic extends TestCase { 58 59 protected Model m1 = null; 60 protected Model m2 = null; 61 protected Model m3 = null; 62 protected Model m4 = null; 63 64 public TestCaseBasic(String name) { 65 super(name); 66 } 67 68 public void test0() { 69 empty(m1); 71 empty(m2); 72 empty(m3); 73 empty(m4); 74 } 75 76 protected void empty(Model m) { 77 try { 78 StmtIterator iter = m.listStatements(); 79 while (iter.hasNext()) { 80 iter.nextStatement(); 81 iter.remove(); 82 } 83 assertTrue(m.size() == 0); 84 } catch (Exception e) { 85 System.err.println(e); 86 assertTrue(false); 87 } 88 } 89 90 public void test1() { 91 try { 92 Regression test = new Regression(); 93 test.test1(m1); 94 assertTrue(!test.getErrors()); 95 } catch (Exception e) { 96 System.out.println(e); 97 assertTrue(false); 98 } 99 } 100 101 public void test2() { 102 try { 103 Regression test = new Regression(); 104 test.test2(m1); 105 assertTrue(!test.getErrors()); 106 } catch (Exception e) { 107 System.out.println(e); 108 assertTrue(false); 109 } 110 } 111 112 public void test3() { 113 try { 114 Regression test = new Regression(); 115 test.test3(m1); 116 assertTrue(!test.getErrors()); 117 } catch (Exception e) { 118 System.out.println(e); 119 assertTrue(false); 120 } 121 } 122 123 public void test4() { 124 try { 125 Regression test = new Regression(); 126 test.test4(m1); 127 assertTrue(!test.getErrors()); 128 } catch (Exception e) { 129 System.out.println(e); 130 assertTrue(false); 131 } 132 } 133 134 public void test5() { 135 try { 136 Regression test = new Regression(); 137 test.test5(m1); 138 assertTrue(!test.getErrors()); 139 } catch (Exception e) { 140 System.out.println(e); 141 assertTrue(false); 142 } 143 } 144 145 public void test6() { 146 try { 147 Regression test = new Regression(); 148 test.test6(m1); 149 assertTrue(!test.getErrors()); 150 } catch (Exception e) { 151 System.out.println(e); 152 assertTrue(false); 153 } 154 } 155 156 public void test7() { 157 try { 158 Regression test = new Regression(); 159 test.test7(m1, m2); 160 assertTrue(!test.getErrors()); 161 } catch (Exception e) { 162 System.out.println(e); 163 assertTrue(false); 164 } 165 } 166 167 public void test8() { 168 try { 169 Regression test = new Regression(); 170 test.test8(m1); 171 assertTrue(!test.getErrors()); 172 } catch (Exception e) { 173 System.out.println(e); 174 assertTrue(false); 175 } 176 } 177 178 public void test9() { 179 try { 180 Regression test = new Regression(); 181 test.test9(m2); 182 assertTrue(!test.getErrors()); 183 } catch (Exception e) { 184 System.out.println(e); 185 assertTrue(false); 186 } 187 } 188 189 public void test10() { 190 try { 191 Regression test = new Regression(); 192 test.test10(m3); 193 assertTrue(!test.getErrors()); 194 } catch (Exception e) { 195 System.out.println(e); 196 assertTrue(false); 197 } 198 } 199 200 public void test11() { 201 try { 202 Regression test = new Regression(); 203 test.test11(m1, m2); 204 assertTrue(!test.getErrors()); 205 } catch (Exception e) { 206 System.out.println(e); 207 assertTrue(false); 208 } 209 } 210 211 public void test12() { 212 try { 213 Regression test = new Regression(); 214 test.test12(m1); 215 assertTrue(!test.getErrors()); 216 } catch (Exception e) { 217 System.out.println(e); 218 assertTrue(false); 219 } 220 } 221 222 public void test13() { 223 try { 224 Regression test = new Regression(); 225 test.test13(m1); 226 assertTrue(!test.getErrors()); 227 } catch (Exception e) { 228 System.out.println(e); 229 assertTrue(false); 230 } 231 } 232 233 public void test14() { 234 try { 235 Regression test = new Regression(); 236 test.test14(m1); 237 assertTrue(!test.getErrors()); 238 } catch (Exception e) { 239 System.out.println(e); 240 assertTrue(false); 241 } 242 } 243 244 public void test15() { 245 try { 246 Regression test = new Regression(); 247 test.test15(m1); 248 assertTrue(!test.getErrors()); 249 } catch (Exception e) { 250 System.out.println(e); 251 assertTrue(false); 252 } 253 } 254 255 public void test16() { 256 try { 257 Regression test = new Regression(); 258 test.test16(m1); 259 assertTrue(!test.getErrors()); 260 } catch (Exception e) { 261 System.out.println(e); 262 assertTrue(false); 263 } 264 } 265 266 public void test17() { 267 try { 268 Regression test = new Regression(); 269 test.test17(m1); 270 assertTrue(!test.getErrors()); 271 } catch (Exception e) { 272 System.out.println(e); 273 assertTrue(false); 274 } 275 } 276 277 public void test18() { 278 try { 279 Regression test = new Regression(); 280 test.test18(m4); 281 assertTrue(!test.getErrors()); 282 } catch (Exception e) { 283 System.out.println(e); 284 assertTrue(false); 285 } 286 } 287 288 public void test19() { 289 try { 290 Regression test = new Regression(); 291 test.test19(m2, m3); 292 assertTrue(!test.getErrors()); 293 } catch (Exception e) { 294 System.out.println(e); 295 assertTrue(false); 296 } 297 } 298 299 public void test97() { 300 try { 301 Regression test = new Regression(); 302 test.test97(m1); 303 assertTrue(!test.getErrors()); 304 } catch (Exception e) { 305 System.out.println(e); 306 assertTrue(false); 307 } 308 } 309 private GetModel getGetModel() { 310 return new GetModel() { 311 312 Model cache[] = new Model[4]; 313 int i = 4; 314 public Model get() { 315 if (i == 4) { 316 try { 317 tearDown(); 318 setUp(); 319 } catch (Exception e) { 320 throw new RuntimeException (e.getMessage()); 321 } 322 cache[0] = m1; 323 cache[1] = m2; 324 cache[2] = m3; 325 cache[3] = m4; 326 i = 0; 327 } 328 return cache[i++]; 329 } 330 }; 331 } 332 public void testModelEquals() { 333 try { 334 testModelEquals test = new testModelEquals(); 335 test.test(getGetModel()); 336 assertTrue(!test.getErrors()); 337 } catch (Exception e) { 338 System.out.println(e); 339 assertTrue(false); 340 } 341 } 342 public void testMatch() { 343 try { 344 testMatch test = new testMatch(0xfab, getGetModel()); 345 test.test(); 346 assertTrue(!test.getErrors()); 347 } catch (Exception e) { 348 System.out.println(e); 349 assertTrue(false); 350 } 351 } 352 358 public void testNTripleReader() { 359 try { 360 testNTripleReader test = new testNTripleReader(); 361 test.test(m1); 362 assertTrue(!test.getErrors()); 363 } catch (Exception e) { 364 System.out.println(e); 365 assertTrue(false); 366 } 367 } 368 373 public void testReaderInterface() { 374 try { 375 testReaderInterface test = new testReaderInterface(); 376 test.test(m1); 377 assertTrue(!test.getErrors()); 378 } catch (Exception e) { 379 System.out.println(e); 380 assertTrue(false); 381 } 382 } 383 384 public void soaktest() { try { 386 int errCount = 0; 387 388 for (int i = 1; i <= 100; i++) { 389 Regression test = new Regression(); 390 test0(); 391 test.test1(m1); 392 test.test2(m1); 393 test.test3(m1); 394 test.test4(m1); 395 test.test5(m1); 396 test.test6(m1); 397 test.test7(m1, m2); 398 test.test8(m1); 399 test.test9(m2); 400 test.test10(m3); 401 test.test11(m1, m2); 402 test.test12(m1); 403 test.test13(m1); 404 test.test14(m1); 405 test.test15(m1); 406 test.test16(m1); 407 test.test17(m1); 408 test.test18(m4); 409 test.test19(m2, m3); 410 test.test97(m1); 411 if (test.getErrors()) 412 errCount++; 413 if ((i % 10) == 0) { 414 System.out.println( 415 "error count = " + errCount + " rounds = " + i); 416 } 417 } 418 } catch (Exception e) { 419 System.out.println(e); 420 assertTrue(false); 421 } 422 } 423 } | Popular Tags |