1 19 20 package com.hp.hpl.jena.reasoner.dig.test; 23 24 25 26 import java.util.*; 29 30 import org.apache.commons.logging.Log; 31 import org.apache.commons.logging.LogFactory; 32 33 import com.hp.hpl.jena.ontology.*; 34 import com.hp.hpl.jena.ontology.OntModelSpec; 35 import com.hp.hpl.jena.rdf.model.ModelFactory; 36 import com.hp.hpl.jena.reasoner.dig.DIGAdapter; 37 38 import junit.framework.*; 39 40 41 50 public class TestRacer 51 extends TestCase 52 { 53 56 59 62 65 68 public void setUp() { 69 OntDocumentManager.getInstance().reset( true ); 71 } 72 73 74 public void testRacerName() { 75 DIGAdapter r = new DIGAdapter( OntModelSpec.OWL_DL_MEM, ModelFactory.createOntologyModel().getGraph() ); 76 assertEquals( "Name should be racer", "Racer", r.getDigIdentifier().getName() ); 77 } 78 79 public void testRacerVersion() { 80 DIGAdapter r = new DIGAdapter( OntModelSpec.OWL_DL_MEM, ModelFactory.createOntologyModel().getGraph() ); 81 assertNotNull( "Version should be non-null", r.getDigIdentifier().getVersion() ); 82 } 83 84 public void testRacerMessage() { 85 DIGAdapter r = new DIGAdapter( OntModelSpec.OWL_DL_MEM, ModelFactory.createOntologyModel().getGraph() ); 86 assertNotNull( "Message should be non-null", r.getDigIdentifier().getMessage() ); 87 } 88 89 public void testRacerSupportsLanguage() { 90 DIGAdapter r = new DIGAdapter( OntModelSpec.OWL_DL_MEM, ModelFactory.createOntologyModel().getGraph() ); 91 iteratorTest( r.getDigIdentifier().supportsLanguage(), 92 new Object [] {"top", "bottom", "catom", "ratom", "and", "or", 93 "not", "some", "all", "atmost", "atleast", "inverse", "feature", "attribute", 94 "intmin", "intmax", "intrange", "intequals", "defined", "stringequals"} ); 95 } 96 97 public void testRacerSupportsTell() { 98 DIGAdapter r = new DIGAdapter( OntModelSpec.OWL_DL_MEM, ModelFactory.createOntologyModel().getGraph() ); 99 iteratorTest( r.getDigIdentifier().supportsTell(), 100 new Object [] {"defconcept", "defrole", "deffeature", "defattribute", "defindividual", "impliesc", "equalc", 101 "disjoint", "impliesr", "domain", "range", "rangeint", "transitive", "functional", 102 "instanceof", "related", "value", "equalr", "rangestring"} ); 103 } 104 105 public void testRacerSupportsAsk() { 106 DIGAdapter r = new DIGAdapter( OntModelSpec.OWL_DL_MEM, ModelFactory.createOntologyModel().getGraph() ); 107 iteratorTest( r.getDigIdentifier().supportsAsk(), 108 new Object [] {"allConceptNames", "allRoleNames", "allIndividuals", "satisfiable", "subsumes", 109 "disjoint", "parents", "children", "descendants", "ancestors", "equivalents", 110 "rparents", "rchildren", "rancestors", "rdescendants", "instances", "types", 111 "instance", "roleFillers", "relatedIndividuals", "toldValues", } ); 112 } 113 114 117 118 protected void iteratorTest( Iterator i, Object [] expected ) { 119 assertNotNull( "Iterator should not be null", i ); 120 121 Log logger = LogFactory.getLog( getClass() ); 122 List expList = new ArrayList(); 123 for (int j = 0; j < expected.length; j++) { 124 expList.add( expected[j] ); 125 } 126 127 while (i.hasNext()) { 128 Object next = i.next(); 129 130 if (!expList.contains( next )) { 132 logger.debug( getName() + " - Unexpected iterator result: " + next ); 133 } 134 135 assertTrue( "Value " + next + " was not expected as a result from this iterator ", expList.contains( next ) ); 136 assertTrue( "Value " + next + " was not removed from the list ", expList.remove( next ) ); 137 } 138 139 if (!(expList.size() == 0)) { 140 logger.debug( getName() + "Expected iterator results not found" ); 141 for (Iterator j = expList.iterator(); j.hasNext(); ) { 142 logger.debug( getName() + " - missing: " + j.next() ); 143 } 144 } 145 assertEquals( "There were expected elements from the iterator that were not found", 0, expList.size() ); 146 } 147 148 149 153 } 154 155 156 182 | Popular Tags |