1 19 20 package com.hp.hpl.jena.ontology.impl.test; 23 24 import junit.framework.TestCase; 27 28 import com.hp.hpl.jena.ontology.*; 29 import com.hp.hpl.jena.rdf.model.*; 30 import com.hp.hpl.jena.reasoner.test.TestUtil; 31 32 33 34 35 43 public class TestFrameView 44 extends TestCase 45 { 46 49 public static final String BASE = "http://jena.hpl.hp.com/testing/ontology"; 50 public static final String NS = BASE + "#"; 51 52 55 58 OntModel mInf; 59 OntModel mNoInf; 60 61 OntClass infA; 62 OntClass infB; 63 OntClass infC; 64 65 OntClass noinfA; 66 OntClass noinfB; 67 OntClass noinfC; 68 69 ObjectProperty noinfG; 70 ObjectProperty infG; 71 72 ObjectProperty noinfPa; 73 ObjectProperty noinfPb; 74 ObjectProperty noinfPc; 75 76 ObjectProperty infPa; 77 ObjectProperty infPb; 78 ObjectProperty infPc; 79 80 ObjectProperty noinfQa; 81 ObjectProperty noinfQb; 82 83 ObjectProperty infQa; 84 ObjectProperty infQb; 85 86 OntClass infAnn; 87 OntClass noinfAnn; 88 AnnotationProperty infPann; 89 AnnotationProperty noinfPann; 90 91 OntClass infUnion1; 92 OntClass infUnion2; 93 OntClass noinfUnion1; 94 OntClass noinfUnion2; 95 ObjectProperty infPunion; 96 ObjectProperty noinfPunion; 97 98 OntClass infIntersect1; 99 OntClass infIntersect2; 100 OntClass noinfIntersect1; 101 OntClass noinfIntersect2; 102 ObjectProperty infPintersect; 103 ObjectProperty noinfPintersect; 104 105 108 111 public void setUp() { 112 OntDocumentManager.getInstance().reset(); 113 OntDocumentManager.getInstance().clearCache(); 114 mNoInf = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM ); 115 mNoInf.read( "file:testing/ontology/owl/list-syntax/test-ldp.rdf" ); 116 mInf = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_MICRO_RULE_INF); 118 mInf.read( "file:testing/ontology/owl/list-syntax/test-ldp.rdf" ); 119 120 infA = mInf.getOntClass( NS + "A" ); 121 infB = mInf.getOntClass( NS + "B" ); 122 infC = mInf.getOntClass( NS + "C" ); 123 124 125 noinfA = mNoInf.getOntClass( NS + "A" ); 126 noinfB = mNoInf.getOntClass( NS + "B" ); 127 noinfC = mNoInf.getOntClass( NS + "C" ); 128 129 noinfG = mNoInf.getObjectProperty( NS + "global" ); 130 infG = mInf.getObjectProperty( NS + "global" ); 131 132 noinfPa = mNoInf.getObjectProperty( NS + "pA" ); 133 noinfPb = mNoInf.getObjectProperty( NS + "pB" ); 134 noinfPc = mNoInf.getObjectProperty( NS + "pC" ); 135 136 infPa = mInf.getObjectProperty( NS + "pA" ); 137 infPb = mInf.getObjectProperty( NS + "pB" ); 138 infPc = mInf.getObjectProperty( NS + "pC" ); 139 140 noinfQa = mNoInf.getObjectProperty( NS + "qA" ); 141 noinfQb = mNoInf.getObjectProperty( NS + "qB" ); 142 143 infQa = mInf.getObjectProperty( NS + "qA" ); 144 infQb = mInf.getObjectProperty( NS + "qB" ); 145 146 infAnn = mInf.getOntClass( NS + "HasAnn" ); 147 noinfAnn = mNoInf.getOntClass( NS + "HasAnn" ); 148 infPann = mInf.getAnnotationProperty( NS + "ann" ); 149 noinfPann = mNoInf.getAnnotationProperty( NS + "ann" ); 150 151 infUnion1 = mInf.getOntClass( NS + "Union1" ); 152 infUnion2 = mInf.getOntClass( NS + "Union2" ); 153 noinfUnion1 = mNoInf.getOntClass( NS + "Union1" ); 154 noinfUnion2 = mNoInf.getOntClass( NS + "Union2" ); 155 infPunion = mInf.getObjectProperty( NS + "unionP" ); 156 noinfPunion = mNoInf.getObjectProperty( NS + "unionP" ); 157 158 infIntersect1 = mInf.getOntClass( NS + "Intersect1" ); 159 infIntersect2 = mInf.getOntClass( NS + "Intersect2" ); 160 noinfIntersect1 = mNoInf.getOntClass( NS + "Intersect1" ); 161 noinfIntersect2 = mNoInf.getOntClass( NS + "Intersect2" ); 162 infPintersect = mInf.getObjectProperty( NS + "intersectP" ); 163 noinfPintersect = mNoInf.getObjectProperty( NS + "intersectP" ); 164 } 165 166 public void tearDown() { 167 176 mInf.close(); 177 mInf = null; 178 mNoInf.close(); 179 mNoInf = null; 180 } 181 182 184 public void testLDP_noinfA_nodirect() { 185 TestUtil.assertIteratorValues( this, noinfA.listDeclaredProperties( false ), 186 new Object [] {noinfPa, noinfQa, noinfG, noinfQb} ); 187 } 188 189 public void testHasDP_noinfA_nodirect() { 190 assertTrue( noinfA.hasDeclaredProperty( noinfPa, false ) ); 193 assertFalse( noinfA.hasDeclaredProperty( noinfPb, false ) ); 194 } 195 196 public void testLDP_noinfA_direct() { 197 TestUtil.assertIteratorValues( this, noinfA.listDeclaredProperties( true ), 198 new Object [] {noinfPa, noinfQa, noinfG, noinfQb} ); 199 } 200 201 public void testLDP_infA_nodirect() { 202 TestUtil.assertIteratorValues( this, infA.listDeclaredProperties( false ), 203 new Object [] {infPa, infQa, infQb, noinfG} ); 204 } 205 206 public void testLDP_infA_direct() { 207 TestUtil.assertIteratorValues( this, infA.listDeclaredProperties( true ), 208 new Object [] {infPa, infQa, infQb, noinfG} ); 209 } 210 211 public void testLDP_noinfB_nodirect() { 212 TestUtil.assertIteratorValues( this, noinfB.listDeclaredProperties( false ), 213 new Object [] {noinfPa, noinfPb, noinfQa, noinfG, noinfQb} ); 214 } 215 216 public void testLDP_noinfB_direct() { 217 TestUtil.assertIteratorValues( this, noinfB.listDeclaredProperties( true ), 218 new Object [] {noinfPb} ); 219 } 220 221 public void testLDP_infB_nodirect() { 222 TestUtil.assertIteratorValues( this, infB.listDeclaredProperties( false ), 223 new Object [] {infPa, infPb, infQa, infQb, infG} ); 224 } 225 226 public void testLDP_infB_direct() { 227 TestUtil.assertIteratorValues( this, infB.listDeclaredProperties( true ), 228 new Object [] {infPb} ); 229 } 230 231 public void testLDP_noinfC_nodirect() { 232 TestUtil.assertIteratorValues( this, noinfC.listDeclaredProperties( false ), 234 new Object [] {noinfPa, noinfPb, noinfPc, noinfQa, noinfG, noinfQb} ); 235 } 236 237 public void testLDP_noinfC_direct() { 238 TestUtil.assertIteratorValues( this, noinfC.listDeclaredProperties( true ), 239 new Object [] {noinfPc} ); 240 } 241 242 public void testLDP_infC_nodirect() { 243 TestUtil.assertIteratorValues( this, infC.listDeclaredProperties( false ), 244 new Object [] {infPa, infPb, infPc, infQa, infQb, infG} ); 245 } 246 247 public void testLDP_infC_direct() { 248 TestUtil.assertIteratorValues( this, infC.listDeclaredProperties( true ), 249 new Object [] {infPc} ); 250 } 251 252 253 public void testLDP_noinfAnn_nodirect() { 254 TestUtil.assertIteratorValues( this, noinfAnn.listDeclaredProperties( false ), 256 new Object [] {noinfPann, noinfG, noinfQb} ); 257 } 258 259 public void testLDP_noinfAnn_direct() { 260 TestUtil.assertIteratorValues( this, noinfAnn.listDeclaredProperties( true ), 261 new Object [] {noinfPann, noinfG, noinfQb} ); 262 } 263 264 public void testLDP_infAnn_nodirect() { 265 TestUtil.assertIteratorValues( this, infAnn.listDeclaredProperties( false ), 266 new Object [] {noinfPann, noinfG} ); 267 } 268 269 public void testLDP_infAnn_direct() { 270 TestUtil.assertIteratorValues( this, infAnn.listDeclaredProperties( true ), 271 new Object [] {noinfPann, noinfG} ); 272 } 273 274 275 public void testLDP_noinfUnion_nodirect() { 276 TestUtil.assertIteratorValues( this, noinfUnion1.listDeclaredProperties( false ), 277 new Object [] {noinfG, noinfQb} ); 278 TestUtil.assertIteratorValues( this, noinfUnion2.listDeclaredProperties( false ), 279 new Object [] {noinfG, noinfQb} ); 280 } 281 282 public void testLDP_infUnion_nodirect() { 283 TestUtil.assertIteratorValues( this, infUnion1.listDeclaredProperties( false ), 284 new Object [] {infPunion, infG} ); 285 TestUtil.assertIteratorValues( this, infUnion2.listDeclaredProperties( false ), 286 new Object [] {infPunion, infG} ); 287 } 288 289 public void testLDP_noinfIntersect_nodirect() { 290 TestUtil.assertIteratorValues( this, noinfIntersect1.listDeclaredProperties( false ), 291 new Object [] {noinfG, noinfQb} ); 292 TestUtil.assertIteratorValues( this, noinfIntersect2.listDeclaredProperties( false ), 293 new Object [] {noinfG, noinfQb} ); 294 } 295 296 public void testLDP_infIntersect_nodirect() { 297 TestUtil.assertIteratorValues( this, infIntersect1.listDeclaredProperties( false ), 298 new Object [] {infG} ); 299 TestUtil.assertIteratorValues( this, infIntersect2.listDeclaredProperties( false ), 300 new Object [] {infG} ); 301 } 302 303 305 public void testLDC_noinfPa_nodirect() { 306 TestUtil.assertIteratorValues( this, noinfPa.listDeclaringClasses( false ), 307 new Object [] {noinfA, noinfB, noinfC} ); 308 } 309 310 public void testLDC_infPa_nodirect() { 311 TestUtil.assertIteratorValues( this, infPa.listDeclaringClasses( false ), 312 new Object [] {infA, infB, infC} ); 313 } 314 315 public void testLDC_noinfPb_nodirect() { 316 TestUtil.assertIteratorValues( this, noinfPb.listDeclaringClasses( false ), 317 new Object [] {noinfB, noinfC} ); 318 } 319 320 public void testLDC_infPb_nodirect() { 321 TestUtil.assertIteratorValues( this, infPb.listDeclaringClasses( false ), 322 new Object [] {infC, infB} ); 323 } 324 325 public void testLDC_noinfPc_nodirect() { 326 TestUtil.assertIteratorValues( this, noinfPc.listDeclaringClasses( false ), 327 new Object [] {noinfC} ); 328 } 329 330 public void testLDC_infPc_nodirect() { 331 TestUtil.assertIteratorValues( this, infPc.listDeclaringClasses( false ), 332 new Object [] {infC} ); 333 } 334 335 public void testLDC_noinfPa_direct() { 336 TestUtil.assertIteratorValues( this, noinfPa.listDeclaringClasses( true ), 337 new Object [] {noinfA} ); 338 } 339 340 public void testLDC_infPa_direct() { 341 TestUtil.assertIteratorValues( this, infPa.listDeclaringClasses( true ), 342 new Object [] {infA} ); 343 } 344 345 public void testLDC_noinfPb_direct() { 346 TestUtil.assertIteratorValues( this, noinfPb.listDeclaringClasses( true ), 347 new Object [] {noinfB} ); 348 } 349 350 public void testLDC_infPb_direct() { 351 TestUtil.assertIteratorValues( this, infPb.listDeclaringClasses( true ), 352 new Object [] {infB} ); 353 } 354 355 public void testLDC_noinfPc_direct() { 356 TestUtil.assertIteratorValues( this, noinfPc.listDeclaringClasses( true ), 357 new Object [] {noinfC} ); 358 } 359 360 public void testLDC_infPc_direct() { 361 TestUtil.assertIteratorValues( this, infPc.listDeclaringClasses( true ), 362 new Object [] {infC} ); 363 } 364 365 public void testLDC_noinfG_direct() { 366 TestUtil.assertIteratorValues( this, noinfG.listDeclaringClasses( true ), 367 new Object [] {noinfA, noinfAnn, noinfUnion1, noinfUnion2, mNoInf.getOntClass(NS+"Joint"),noinfIntersect1,noinfIntersect2}, 2 ); 368 } 369 370 public void testLDC_infG_direct() { 371 TestUtil.assertIteratorValues( this, infG.listDeclaringClasses( true ), 372 new Object [] {infA, infAnn, mNoInf.getOntClass(NS+"Joint"),noinfIntersect1,noinfIntersect2}, 1 ); 373 } 374 375 public void testLDC_noinfG_nodirect() { 376 TestUtil.assertIteratorValues( this, noinfG.listDeclaringClasses( false ), 377 new Object [] {noinfA, noinfB, noinfC, noinfUnion1, noinfUnion2, noinfAnn, mNoInf.getOntClass(NS+"Joint"),noinfIntersect1,noinfIntersect2}, 2 ); 378 } 379 380 public void testLDC_infG_nodirect() { 381 TestUtil.assertIteratorValues( this, infG.listDeclaringClasses( false ), 382 new Object [] {infA, infB, infC, infAnn, noinfUnion1, noinfUnion2, mNoInf.getOntClass(NS+"Joint"),noinfIntersect1,noinfIntersect2}, 2 ); 383 } 384 385 386 389 393 } 394 395 396 425 426 | Popular Tags |