1 6 7 package com.hp.hpl.jena.rdf.arp.test; 8 9 import junit.framework.*; 10 import java.util.zip.*; 11 import java.io.*; 12 13 import com.hp.hpl.jena.rdf.model.*; 14 import com.hp.hpl.jena.rdf.model.impl.*; 15 import java.util.*; 16 import com.hp.hpl.jena.rdf.arp.*; 17 import com.hp.hpl.jena.vocabulary.*; 18 import com.hp.hpl.jena.shared.*; 19 import com.hp.hpl.jena.shared.impl.JenaParameters; 20 import com.hp.hpl.jena.shared.wg.*; 21 import com.hp.hpl.jena.shared.wg.URI; 22 23 import com.hp.hpl.jena.reasoner.test.*; 24 import com.hp.hpl.jena.reasoner.rulesys.*; 25 26 import org.xml.sax.*; 27 31 class WGTestSuite extends TestSuite implements ARPErrorNumbers { 32 static private Resource jena2; 33 static private Model testResults; 34 static private void initResults() { 35 logging = true; 36 testResults = ModelFactory.createDefaultModel(); 37 jena2 = testResults.createResource(BASE_RESULTS_URI + "#jena2"); 38 jena2.addProperty(RDFS.comment, 39 testResults.createLiteral( 40 "<a xmlns=\"http://www.w3.org/1999/xhtml\" HREF=\"http://jena.sourceforce.net/\">Jena2</a> is a" + 41 " Semantic Web framework in Java" + 42 " available from <a xmlns=\"http://www.w3.org/1999/xhtml\" HREF=\"http://www.sourceforce.net/projects/jena\">" + 43 "sourceforge</a> CVS.", 44 true) 45 ); 46 jena2.addProperty(RDFS.label, "Jena2"); 47 testResults.setNsPrefix("results", OWLResults.NS); 48 } 49 static void logResult(Resource test, int type) { 50 if (!logging) return; 51 Resource rslt; 52 switch (type) { 53 case WGReasonerTester.NOT_APPLICABLE: 54 return; 55 case WGReasonerTester.FAIL: 56 rslt = OWLResults.FailingRun; 57 break; 58 case WGReasonerTester.PASS: 59 rslt = OWLResults.PassingRun; 60 break; 61 case WGReasonerTester.INCOMPLETE: 62 rslt = OWLResults.IncompleteRun; 63 break; 64 default: 65 throw new BrokenException("Unknown result type"); 66 } 67 Resource result = 68 testResults 69 .createResource() 70 .addProperty(RDF.type, OWLResults.TestRun) 71 .addProperty(RDF.type, rslt) 72 .addProperty(OWLResults.test, test ) 73 .addProperty(OWLResults.system, jena2); 74 } 75 private static boolean logging = false; 76 private static String BASE_RESULTS_URI = "http://jena.sourceforge.net/data/rdf-results.rdf"; 77 static public boolean checkMessages = false; 78 static private boolean doSemanticTests() { 79 return ARPTests.internet; 80 } 81 static private boolean inDevelopment = false; 82 Model loadRDF(InFactoryX in, RDFErrorHandler eh, String base) 83 throws IOException { 84 Model model = ModelFactory.createDefaultModel(); 85 JenaReader jr = new JenaReader(); 86 87 if (eh != null) 88 jr.setErrorHandler(eh); 89 jr.setProperty("error-mode", "strict"); 90 91 if ( base.indexOf("/xmlns/") != -1 92 || base.indexOf("/comments/") != -1 ) 93 jr.setProperty("embedding","true"); 94 InputStream inx = in.open(); 95 jr.read(model, inx, base); 96 inx.close(); 97 return model; 98 } 99 100 static Model loadNT(InputStream in, String base) throws IOException { 101 Model model = ModelFactory.createDefaultModel(); 102 model.read(in, base, "N-TRIPLE"); 103 in.close(); 104 return model; 105 } 106 107 static private class DummyTest extends TestCase { 108 DummyTest() { 109 super("save results"); 110 } 111 public void runTest() throws IOException { 112 if (logging) { 113 RDFWriter w = testResults.getWriter("RDF/XML-ABBREV"); 114 w.setProperty("xmlbase",BASE_RESULTS_URI ); 115 OutputStream out; 116 try { 117 out = new FileOutputStream("/tmp/rdf-results.rdf"); 118 } 119 catch (Exception e){ 120 out = System.out; 121 } 122 w.write(testResults,out,BASE_RESULTS_URI); 123 out.close(); 124 } 125 } 126 } 127 static String testNS = 128 "http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#"; 129 130 static String jjcNS = "http://jcarroll.hpl.hp.com/testSchema#"; 131 132 static private Property status; 134 static private Property input; 135 static private Property output; 136 static private Property warning; 137 static private Property errorCodes; 138 139 static { 140 status = new PropertyImpl(testNS, "status"); 141 input = new PropertyImpl(testNS, "inputDocument"); 142 output = new PropertyImpl(testNS, "outputDocument"); 143 warning = new PropertyImpl(testNS, "warning"); 144 errorCodes = new PropertyImpl(jjcNS, "error"); 145 } 146 147 static private Resource rdfxml = 148 new ResourceImpl(testNS, "RDF-XML-Document"); 149 150 static private Resource ntriple = new ResourceImpl(testNS, "NT-Document"); 151 153 private URI testDir; 154 155 private Act noop = new Act() { 156 public void act(Resource r) { 157 } 158 }; 159 160 private Act semTest = new Act() { 161 public void act(Resource r) { 162 if (doSemanticTests()){ 163 addTest(r, new ReasoningTest(r)); 164 } 165 } 166 }; 167 168 TestInputStreamFactory factory; 169 170 static private Collection misc = 171 Arrays.asList( 172 new String [] { "http://www.w3.org/2000/10/rdf-tests/rdfcore/rdfms-uri-substructure/error001" }); 173 174 private Map behaviours = new HashMap(); 175 176 { 177 behaviours 178 .put(new ResourceImpl(testNS + "PositiveParserTest"), new Act() { 179 public void act(Resource r) { 180 if (r.hasProperty(warning)) { 183 addTest(r, new WarningTest(r)); 184 } else { 185 addTest(r, new PositiveTest(r)); 186 } 187 } 188 }); 189 behaviours 190 .put(new ResourceImpl(testNS + "NegativeParserTest"), new Act() { 191 public void act(Resource r) { 192 addTest(r, new NegativeTest(r)); 194 } 195 }); 196 behaviours.put(new ResourceImpl(testNS + "False-Document"), noop); 197 behaviours.put(new ResourceImpl(testNS + "RDF-XML-Document"), noop); 198 behaviours.put(new ResourceImpl(testNS + "NT-Document"), noop); 199 behaviours.put( 200 new ResourceImpl(testNS + "PositiveEntailmentTest"), 201 semTest); 202 behaviours.put( 203 new ResourceImpl(testNS + "NegativeEntailmentTest"), 204 semTest); 205 behaviours 206 .put(new ResourceImpl(testNS + "MiscellaneousTest"), new Act() { 207 public void act(Resource r) { 208 String uri = r.getURI(); 209 if (!misc.contains(uri)) 210 System.err.println( 211 "MiscellaneousTest: " + uri + " - ignored!"); 212 } 213 }); 214 } 215 216 private Model loadRDF(final TestInputStreamFactory fact, 217 final String file) { 218 Model m = null; 219 String base = fact.getBase().toString(); 220 if (!base.endsWith("/")) 221 base = base + "/"; 222 223 try { 224 InputStream in = fact.fullyOpen(file); 225 if (in == null ) 226 return null; 227 in.close(); 228 m = loadRDF(new InFactoryX(){ 229 public InputStream open() throws IOException { 230 return fact.fullyOpen(file); 231 } }, null, base + file); 232 } catch (JenaException e) { 233 throw e; 235 } catch (Exception e) { 236 if (file.equals("Manifest.rdf")) { 238 System.err.println("Failed to open Manifest.rdf"); 239 e.printStackTrace(); 240 } 241 } 242 return m; 243 } 244 245 249 String createMe; 250 251 WGTestSuite(TestInputStreamFactory fact, String name, boolean dynamic) { 252 super(name); 253 factory = fact; 254 testDir = fact.getBase(); 255 if (dynamic) 256 try { 257 String wgDir = ARPTests.wgTestDir.toString(); 258 System.err.println(wgDir); 259 wgReasoner = new WGReasonerTester("Manifest",wgDir); 260 createMe = 261 "new " 262 + this.getClass().getName() 263 + "(" 264 + fact.getCreationJava() 265 + ", \"" 266 + name 267 + "\", false )"; 268 Model m = loadRDF(fact, "Manifest.rdf"); 269 Model extra = loadRDF(fact, "Manifest-extra.rdf"); 271 Model wrong = loadRDF(fact, "Manifest-wrong.rdf"); 273 275 if (extra != null) 276 m = m.add(extra); 277 if (wrong != null) 278 m = m.difference(wrong); 279 StmtIterator si = 282 m.listStatements( null, RDF.type, (RDFNode) null ); 283 284 while (si.hasNext()) { 285 Statement st = si.nextStatement(); 286 Act action = (Act) behaviours.get(st.getObject()); 287 if (action == null) { 288 System.err.println( 289 "Unknown test class: " 290 + ((Resource) st.getObject()).getURI()); 291 } else { 292 action.act(st.getSubject()); 293 } 294 } 295 if ( ARPTests.internet) { 296 initResults(); 297 addTest(new DummyTest()); 298 } 299 } catch (RuntimeException re) { 300 re.printStackTrace(); 301 throw re; 302 } catch (Exception e) { 303 e.printStackTrace(); 304 throw new JenaException( e ); 305 306 } 307 } 308 309 311 static TestSuite suite(URI testDir, String d, String nm) { 312 return new WGTestSuite( 313 new TestInputStreamFactory(testDir, d), 314 nm, 315 true); 316 } 317 318 static TestSuite suite(URI testDir, URI d, String nm) { 319 return new WGTestSuite( 320 new TestInputStreamFactory(testDir, d), 321 nm, 322 true); 323 } 324 325 private Map parts = new HashMap(); 326 327 private void addTest(Resource key, TestCase test) { 328 String keyName = 329 key.hasProperty(status) 330 ? key.getRequiredProperty(status).getString() 331 : "no status"; 332 TestSuite sub = (TestSuite) parts.get(keyName); 333 if (sub == null) { 334 if ( keyName.equals("OBSOLETED")) 335 return; 336 if ( keyName.equals("OBSOLETE")) 337 return; 338 if ( keyName.equals("NOT_APPROVED")) 339 return; 340 sub = new TestSuite(); 341 sub.setName(keyName); 342 parts.put(keyName, sub); 343 addTest(sub); 344 } 345 sub.addTest(test); 346 } 347 348 final static String errorLevelName[] = 349 new String [] { "warning", "error", "fatal error" }; 350 351 interface Act { 352 void act(Resource r) ; 353 } 354 private WGReasonerTester wgReasoner; 355 class ReasoningTest extends Test { 356 ReasoningTest(Resource r) { 357 super(r); 358 } 359 protected void runTest() throws IOException { 360 int rslt = WGReasonerTester.FAIL; 361 try { 362 JenaParameters.enableWhitespaceCheckingOfTypedLiterals = true; 363 Resource config = ModelFactory.createDefaultModel().createResource() 364 .addProperty(ReasonerVocabulary.PROPsetRDFSLevel, "full"); 365 rslt = wgReasoner.runTestDetailedResponse(testID.getURI(), 366 RDFSRuleReasonerFactory.theInstance(),this,config); 367 } finally { 368 logResult(testID,rslt); 369 } 370 } 372 375 String createMe() { 376 throw new UnsupportedOperationException (); 377 } 378 381 void reallyRunTest() { 382 throw new BrokenException(""); 383 } 384 385 } 386 387 abstract class Test extends TestCase implements RDFErrorHandler { 388 Resource testID; 389 String createURI() { 390 return "\"" + testID.getURI() + "\""; 391 } 392 abstract String createMe(); 393 Test(Resource r) { 394 super( 395 WGTestSuite 396 .this 397 .testDir 398 .relativize(URI.create(r.getURI())) 399 .toString()); 400 testID = r; 401 } 402 String create(Property p) { 403 Resource file = testID.getRequiredProperty(p).getResource(); 404 Resource t = file.getRequiredProperty(RDF.type).getResource(); 405 if (ntriple.equals(t)) { 406 return "\"" + file.getURI() + "\",false"; 407 } else if (rdfxml.equals(t)) { 408 return "\"" + file.getURI() + "\",true"; 409 } else { 410 return "Unrecognized file type: " + t; 411 } 412 } 413 Model read(Property p) throws IOException { 414 Resource file = testID.getRequiredProperty(p).getResource(); 415 Resource t = file.getRequiredProperty(RDF.type).getResource(); 416 final String uri = file.getURI(); 417 if (ntriple.equals(t)) { 418 return loadNT(factory.open(uri),uri); 419 } else if (rdfxml.equals(t)) { 420 return loadRDF( 421 new InFactoryX(){ 422 423 public InputStream open() throws IOException { 424 return factory.open(uri); 425 } 426 } 427 , this, uri); 428 } else { 429 fail("Unrecognized file type: " + t); 430 } 431 return null; 432 } 433 protected void runTest() throws IOException { 434 int rslt = WGReasonerTester.FAIL; 435 try { 436 reallyRunTest(); 437 rslt = WGReasonerTester.PASS; 438 } 439 finally { 440 logResult(testID,rslt); 441 } 442 } 443 abstract void reallyRunTest(); 444 public void warning(Exception e) { 445 error(0, e); 446 } 447 public void error(Exception e) { 448 error(1, e); 449 } 450 public void fatalError(Exception e) { 451 error(2, e); 452 } 453 private void error(int level, Exception e) { 454 if (e instanceof ParseException) { 456 int eCode = ((ParseException) e).getErrorNumber(); 457 if (eCode == ERR_SYNTAX_ERROR) { 458 String msg = e.getMessage(); 459 if (msg.indexOf("Unusual") != -1 460 || msg.indexOf("Internal") != -1) { 461 System.err.println(testID.getURI()); 462 System.err.println(msg); 463 fail(msg); 464 } 465 if (checkMessages) { 466 System.err.println(testID.getURI()); 467 System.err.println(msg); 468 } 469 } 470 onError(level, eCode); 471 } 472 475 else if (e instanceof SAXException) { 476 fail("Not expecting a SAXException: " + e.getMessage()); 477 } else { 478 fail("Not expecting an Exception: " + e.getMessage()); 479 } 480 } 481 482 private void println(String m) { 483 System.err.println(m); 484 } 485 void onError(int level, int num) { 486 String msg = 487 "Parser reports unexpected " 488 + errorLevelName[level] 489 + ": " 490 + JenaReader.errorCodeName(num); 491 println(msg); 492 fail(msg); 493 } 494 } 495 496 class PositiveTest extends NegativeTest { 497 String createMe() { 498 return createURI() + "," + create(input) + "," + create(output); 499 } 500 PositiveTest(Resource nm) { 501 super(nm); 502 expectedLevel = -1; 503 } 504 protected void reallyRunTest() { 505 try { 506 Model m2 = read(output); 507 super.reallyRunTest(); 508 if (!m1.equals(m2)) { 509 save(output); 510 assertTrue(m1.isIsomorphicWith( m2 ) ); 511 } 512 } catch (RuntimeException e) { 513 throw e; 514 } catch (Exception e) { 515 fail(e.getMessage()); 516 } 517 } 518 void initExpected() { 519 expected = new HashSet(); 520 } 521 } 522 523 class WarningTest extends PositiveTest { 524 String createMe() { 525 return createURI() 526 + "," 527 + create(input) 528 + "," 529 + create(output) 530 + "," 531 + createExpected(); 532 } 533 WarningTest(Resource nm) { 534 super(nm); 535 expectedLevel = 0; 536 } 537 void initExpected() { 538 initExpectedFromModel(); 539 } 540 } 541 542 class NegativeTest extends Test { 543 Model m1; 544 Set expected; 545 int expectedLevel = 1; 546 private Set found = new HashSet(); 547 private int errorCnt[] = new int[] { 0, 0, 0 }; 548 String createExpected() { 549 String rslt = "new int[]{"; 550 if ( expected == null) 551 return "null"; 552 Iterator it = expected.iterator(); 553 while (it.hasNext()) 554 rslt += it.next() + ", "; 555 return rslt + "}"; 556 } 557 String createMe() { 558 return createURI() + "," + create(input) + "," + createExpected(); 559 } 560 NegativeTest(Resource nm) { 561 super(nm); 562 initExpected(); 563 } 564 void save(Property p) { 565 if (factory.savable()) { 566 String uri = testID.getRequiredProperty(p).getResource().getURI(); 567 int suffix = uri.lastIndexOf('.'); 568 String saveUri = uri.substring(0, suffix) + ".ntx"; 569 try { 571 OutputStream w = factory.openOutput(saveUri); 572 m1.write(w, "N-TRIPLE"); 573 w.close(); 574 } catch (IOException e) { 575 throw new JenaException( e ); 576 } 577 } 578 } 579 void initExpectedFromModel() { 580 StmtIterator si = testID.listProperties(errorCodes); 581 if (si.hasNext()) { 582 expected = new HashSet(); 583 while (si.hasNext()) { 584 String uri = si.nextStatement().getResource().getURI(); 585 String fieldName = uri.substring(uri.lastIndexOf('#') + 1); 586 expected.add(new Integer (JenaReader.errorCode(fieldName))); 587 } 588 } 589 } 590 void initExpected() { 591 initExpectedFromModel(); 592 } 593 protected void reallyRunTest() { 594 try { 595 m1 = read(input); 596 597 if (expectedLevel == 1 598 && expected == null 599 && errorCnt[2] == 0 600 && errorCnt[1] == 0) 601 save(input); 602 } catch (JenaException re) { 603 if (re.getCause() instanceof SAXException) { 604 } else { 606 fail(re.getMessage()); 607 } 608 } catch (IOException ioe) { 609 fail(ioe.getMessage()); 610 } 611 if (expected != null && !expected.equals(found)) { 612 Set dup = new HashSet(); 613 dup.addAll(found); 614 dup.removeAll(expected); 615 expected.removeAll(found); 616 Iterator it = expected.iterator(); 617 while (it.hasNext()) { 618 int eCode = ((Integer ) it.next()).intValue(); 619 String msg = 620 "Expected error " 621 + JenaReader.errorCodeName(eCode) 622 + ", was not detected."; 623 if (errorCnt[2] == 0) 624 fail(msg); 625 else if ( 626 eCode == ERR_SYNTAX_ERROR 627 && getName().startsWith("rdf-nnn/67_") 628 && "1234".indexOf( 629 getName().charAt("rdf-nnn/67_".length())) 630 != -1) { 631 635 } else { 636 System.err.println("Test: " + getName()); 637 System.err.println(msg); 638 } 639 } 640 it = dup.iterator(); 641 while (it.hasNext()) 642 fail( 643 "Detected error " 644 + JenaReader.errorCodeName( 645 ((Integer ) it.next()).intValue()) 646 + ", was not expected."); 647 } 648 for (int j = 2; j >= 0; j--) 649 if (j == expectedLevel) { 650 if (errorCnt[j] == 0 && (j != 1 || errorCnt[2] == 0)) 651 fail( 652 "No " 653 + errorLevelName[expectedLevel] 654 + " in input file of class " 655 + getClass().getName()); 656 } else if (expected == null) { 657 if (errorCnt[j] != 0) 658 fail( 659 "Inappropriate " 660 + errorLevelName[j] 661 + " in input file of class " 662 + getClass().getName()); 663 } 664 665 } 666 void onError(int level, int id) { 667 Integer err = new Integer (id); 668 found.add(err); 669 errorCnt[level]++; 670 if (expected != null) { 671 if (!expected.contains(err)) 672 super.onError(level, id); 673 } else if (inDevelopment) { 674 System.err.println( 675 "<rdf:Description rdf:about='" 676 + testID.getURI() 677 + "'>\n" 678 + "<jjc:error rdf:resource='" 679 + jjcNS 680 + JenaReader.errorCodeName(id) 681 + "'/>\n</rdf:Description>"); 682 } 683 } 684 } 685 class Test2 extends TestCase implements RDFErrorHandler { 686 Test2(String r) { 688 super( 689 WGTestSuite.this.testDir.relativize(URI.create(r)).toString()); 690 } 692 Model read(String file, boolean type) throws IOException { 693 if (!type) { 694 return loadNT(factory.open(file),file); 695 } else { 696 final String uri = file; 697 return loadRDF( 698 new InFactoryX(){ 699 700 public InputStream open() throws IOException { 701 return factory.open(uri); 702 } 703 } 704 705 , this, uri); 706 } 707 } 708 709 public void warning(Exception e) { 710 error(0, e); 711 } 712 713 public void error(Exception e) { 714 error(1, e); 715 } 716 717 public void fatalError(Exception e) { 718 error(2, e); 719 } 720 721 private void error(int level, Exception e) { 722 if (e instanceof ParseException) { 724 int eCode = ((ParseException) e).getErrorNumber(); 725 if (eCode == ERR_SYNTAX_ERROR) { 726 String msg = e.getMessage(); 727 if (msg.indexOf("Unusual") != -1 728 || msg.indexOf("Internal") != -1) { 729 System.err.println(getName()); 730 System.err.println(msg); 731 fail(msg); 732 } 733 739 } 740 onError(level, eCode); 741 } 744 else if (e instanceof SAXException) { 745 fail("Not expecting a SAXException: " + e.getMessage()); 746 } else { 747 fail("Not expecting an Exception: " + e.getMessage()); 748 } 749 } 750 751 private void println(String m) { 752 System.err.println(m); 753 } 754 void onError(int level, int num) { 755 String msg = 756 "Parser reports unexpected " 757 + errorLevelName[level] 758 + ": " 759 + JenaReader.errorCodeName(num); 760 println(msg); 761 fail(msg); 762 } 763 } 764 765 class PositiveTest2 extends NegativeTest2 { 766 String out; 767 boolean outtype; 768 PositiveTest2( 769 String uri, 770 String in, 771 boolean intype, 772 String out, 773 boolean outtype) { 774 this(uri, in, intype, out, outtype, new int[] { 775 }); 776 } 777 778 PositiveTest2( 779 String uri, 780 String in, 781 boolean intype, 782 String out, 783 boolean outtype, 784 int errs[]) { 785 super(uri, in, intype, errs); 786 expectedLevel = -1; 787 this.out = out; 788 this.outtype = outtype; 789 } 790 protected void runTest() { 791 try { 792 Model m2 = read(out, outtype); 793 super.runTest(); 794 if (!m1.isIsomorphicWith(m2)) { 795 System.err.println("====="); 797 m1.write(System.err,"N-TRIPLE"); 798 System.err.println("====="); 799 m2.write(System.err,"N-TRIPLE"); 800 System.err.println("====="); 801 fail("Models were not equal."); 802 } 803 } catch (RuntimeException e) { 804 throw e; 805 } catch (Exception e) { 806 fail(e.getMessage()); 807 } 808 } 809 void initExpected() { 810 expected = new HashSet(); 811 } 812 } 813 814 class WarningTest2 extends PositiveTest2 { 815 WarningTest2( 816 String uri, 817 String in, 818 boolean intype, 819 String out, 820 boolean outtype, 821 int errs[]) { 822 super(uri, in, intype, out, outtype, errs); 823 expectedLevel = 0; 824 } 825 } 826 827 class NegativeTest2 extends Test2 { 828 Model m1; 829 Set expected; 830 int expectedLevel = 1; 831 String in; 832 boolean intype; 833 private Set found = new HashSet(); 834 private int errorCnt[] = new int[] { 0, 0, 0 }; 835 NegativeTest2(String uri, String in, boolean intype, int errs[]) { 836 super(uri); 837 this.in = in; 838 this.intype = intype; 839 840 initExpected(errs); 841 } 842 859 void initExpected(int errs[]) { 860 if ( errs == null ) 861 return; 862 if (errs.length != 0) 863 expected = new HashSet(); 864 for (int i = 0; i < errs.length; i++) { 865 866 expected.add(new Integer (errs[i])); 867 } 868 } 869 protected void runTest() { 870 try { 871 m1 = read(in, intype); 872 879 } catch (JenaException re) { 880 if (re.getCause() instanceof SAXException) { 882 } else { 884 fail(re.getMessage()); 885 } 886 } catch (IOException ioe) { 887 fail(ioe.getMessage()); 888 } 889 if (expected != null && !expected.equals(found)) { 890 Set dup = new HashSet(); 891 dup.addAll(found); 892 dup.removeAll(expected); 893 expected.removeAll(found); 894 Iterator it = expected.iterator(); 895 while (it.hasNext()) { 896 int eCode = ((Integer ) it.next()).intValue(); 897 String msg = 898 "Expected error " 899 + JenaReader.errorCodeName(eCode) 900 + ", was not detected."; 901 if (errorCnt[2] == 0) { 902 fail(msg); 903 } else { 904 System.err.println("Test: " + getName()); 905 System.err.println(msg); 906 } 907 } 908 it = dup.iterator(); 909 while (it.hasNext()) 910 fail( 911 "Detected error " 912 + JenaReader.errorCodeName( 913 ((Integer ) it.next()).intValue()) 914 + ", was not expected."); 915 } 916 for (int j = 2; j >= 0; j--) 917 if (j == expectedLevel) { 918 if (errorCnt[j] == 0 && (j != 1 || errorCnt[2] == 0)) 919 fail( 920 "No " 921 + errorLevelName[expectedLevel] 922 + " in input file of class " 923 + getClass().getName()); 924 } else if (expected == null) { 925 if (errorCnt[j] != 0) 926 fail( 927 "Inappropriate " 928 + errorLevelName[j] 929 + " in input file of class " 930 + getClass().getName()); 931 } 932 933 } 934 void onError(int level, int id) { 935 Integer err = new Integer (id); 936 found.add(err); 937 errorCnt[level]++; 938 if (expected != null) { 939 if (!expected.contains(err)) 940 super.onError(level, id); 941 } 942 953 } 954 } 955 TestCase createPositiveTest( 956 String uri, 957 String in, 958 boolean intype, 959 String out, 960 boolean outtype) { 961 return new PositiveTest2(uri, in, intype, out, outtype); 962 } 963 TestCase createWarningTest( 964 String uri, 965 String in, 966 boolean intype, 967 String out, 968 boolean outtype, 969 int e[]) { 970 return new WarningTest2(uri, in, intype, out, outtype, e); 971 } 972 TestCase createNegativeTest( 973 String uri, 974 String in, 975 boolean intype, 976 int e[]) { 977 return new NegativeTest2(uri, in, intype, e); 978 } 979 } 980 1011 | Popular Tags |