1 19 20 package com.hp.hpl.jena.ontology.impl.test; 23 24 25 import com.hp.hpl.jena.ontology.*; 28 import com.hp.hpl.jena.rdf.model.ModelFactory; 29 import com.hp.hpl.jena.rdf.model.test.ModelTestBase; 30 31 32 41 public class TestOntClass 42 extends ModelTestBase 43 { 44 47 50 private static final String NS = "http://example.com/test#"; 51 52 55 58 public TestOntClass( String name ) { 59 super( name ); 60 } 61 62 65 public void testSuperClassNE() { 66 OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM ); 67 OntClass a = m.createClass( NS + "A" ); 68 69 assertNull( a.getSuperClass() ); 70 assertFalse( a.hasSuperClass() ); 71 } 72 73 public void testSubClassNE() { 74 OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM ); 75 OntClass a = m.createClass( NS + "A" ); 76 77 assertNull( a.getSubClass() ); 78 assertFalse( a.hasSubClass() ); 79 } 80 81 public void testCreateIndividual() { 82 OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM ); 83 OntClass a = m.createClass( NS + "A" ); 84 Individual i = a.createIndividual( NS + "i" ); 85 assertTrue( i.hasRDFType(a) ); 86 87 Individual j = a.createIndividual(); 88 assertTrue( j.hasRDFType(a) ); 89 } 90 91 public void testIsHierarchyRoot0() { 92 OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM ); 93 OntClass a = m.createClass( NS + "A" ); 94 OntClass b = m.createClass( NS + "B" ); 95 a.addSubClass( b ); 96 assertTrue( a.isHierarchyRoot() ); 97 assertFalse( b.isHierarchyRoot() ); 98 } 99 100 public void testIsHierarchyRoot1() { 101 OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_RULE_INF ); 102 OntClass a = m.createClass( NS + "A" ); 103 OntClass b = m.createClass( NS + "B" ); 104 a.addSubClass( b ); 105 assertTrue( a.isHierarchyRoot() ); 106 assertFalse( b.isHierarchyRoot() ); 107 } 108 109 public void testIsHierarchyRoot2() { 110 OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_RDFS_INF ); 111 OntClass a = m.createClass( NS + "A" ); 112 OntClass b = m.createClass( NS + "B" ); 113 a.addSubClass( b ); 114 assertTrue( a.isHierarchyRoot() ); 115 assertFalse( b.isHierarchyRoot() ); 116 } 117 118 public void testIsHierarchyRoot3() { 119 OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_TRANS_INF ); 120 OntClass a = m.createClass( NS + "A" ); 121 OntClass b = m.createClass( NS + "B" ); 122 a.addSubClass( b ); 123 assertTrue( a.isHierarchyRoot() ); 124 assertFalse( b.isHierarchyRoot() ); 125 } 126 127 public void testIsHierarchyRoot4() { 128 OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_DL_MEM ); 129 OntClass a = m.createClass( NS + "A" ); 130 OntClass b = m.createClass( NS + "B" ); 131 a.addSubClass( b ); 132 assertTrue( a.isHierarchyRoot() ); 133 assertFalse( b.isHierarchyRoot() ); 134 } 135 136 public void testIsHierarchyRoot5() { 137 OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_LITE_MEM ); 138 OntClass a = m.createClass( NS + "A" ); 139 OntClass b = m.createClass( NS + "B" ); 140 a.addSubClass( b ); 141 assertTrue( a.isHierarchyRoot() ); 142 assertFalse( b.isHierarchyRoot() ); 143 } 144 145 public void testIsHierarchyRoot6() { 146 OntModel m = ModelFactory.createOntologyModel( OntModelSpec.DAML_MEM ); 147 OntClass a = m.createClass( NS + "A" ); 148 OntClass b = m.createClass( NS + "B" ); 149 a.addSubClass( b ); 150 assertTrue( a.isHierarchyRoot() ); 151 assertFalse( b.isHierarchyRoot() ); 152 } 153 154 public void testIsHierarchyRoot7() { 155 OntModel m = ModelFactory.createOntologyModel( OntModelSpec.DAML_MEM_RULE_INF ); 156 OntClass a = m.createClass( NS + "A" ); 157 OntClass b = m.createClass( NS + "B" ); 158 a.addSubClass( b ); 159 assertTrue( a.isHierarchyRoot() ); 160 assertFalse( b.isHierarchyRoot() ); 161 } 162 163 public void testIsHierarchyRoot8() { 164 OntModel m = ModelFactory.createOntologyModel( OntModelSpec.RDFS_MEM ); 165 OntClass a = m.createClass( NS + "A" ); 166 OntClass b = m.createClass( NS + "B" ); 167 a.addSubClass( b ); 168 assertTrue( a.isHierarchyRoot() ); 169 assertFalse( b.isHierarchyRoot() ); 170 } 171 172 public void testIsHierarchyRoot9() { 173 OntModel m = ModelFactory.createOntologyModel( OntModelSpec.RDFS_MEM_RDFS_INF ); 174 OntClass a = m.createClass( NS + "A" ); 175 OntClass b = m.createClass( NS + "B" ); 176 a.addSubClass( b ); 177 assertTrue( a.isHierarchyRoot() ); 178 assertFalse( b.isHierarchyRoot() ); 179 } 180 181 182 185 189 } 190 191 192 193 222 223 | Popular Tags |