1 19 20 package com.hp.hpl.jena.ontology.impl.test; 23 24 25 import junit.framework.TestSuite; 28 29 import com.hp.hpl.jena.ontology.*; 30 31 32 41 public class TestIndividual 42 extends OntTestBase 43 { 44 47 50 51 52 55 58 static public TestSuite suite() { 59 return new TestIndividual( "TestIndividual" ); 60 } 61 62 public TestIndividual( String name ) { 63 super( name ); 64 } 65 66 67 70 public OntTestCase[] getTests() { 71 return new OntTestCase[] { 72 new OntTestCase( "Individual.sameAs", true, false, true, false ) { 73 74 public void ontTest( OntModel m ) throws Exception { 75 Profile prof = m.getProfile(); 76 OntClass A = m.createClass( NS + "A" ); 77 Individual x = m.createIndividual( A ); 78 Individual y = m.createIndividual( A ); 79 Individual z = m.createIndividual( A ); 80 81 x.addSameAs( y ); 82 assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.SAME_AS() ) ); 83 assertEquals( "x should be the same as y", y, x.getSameAs() ); 84 assertTrue( "x should be the same as y", x.isSameAs( y ) ); 85 86 x.addSameAs( z ); 87 assertEquals( "Cardinality should be 2", 2, x.getCardinality( prof.SAME_AS() ) ); 88 iteratorTest( x.listSameAs(), new Object [] {z,y} ); 89 90 x.setSameAs( z ); 91 assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.SAME_AS() ) ); 92 assertEquals( "x should be same indiv. as z", z, x.getSameAs() ); 93 94 x.removeSameAs( y ); 95 assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.SAME_AS() ) ); 96 x.removeSameAs( z ); 97 assertEquals( "Cardinality should be 0", 0, x.getCardinality( prof.SAME_AS() ) ); 98 } 99 }, 100 }; 101 } 102 103 106 110 } 111 112 113 142 143 144 | Popular Tags |