KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > ontology > impl > test > TestIndividual


1 /*****************************************************************************
2  * Source code information
3  * -----------------------
4  * Original author Ian Dickinson, HP Labs Bristol
5  * Author email Ian.Dickinson@hp.com
6  * Package Jena 2
7  * Web http://sourceforge.net/projects/jena/
8  * Created 23-May-2003
9  * Filename $RCSfile: TestIndividual.java,v $
10  * Revision $Revision: 1.7 $
11  * Release status $State: Exp $
12  *
13  * Last modified on $Date: 2005/02/21 12:07:18 $
14  * by $Author: andy_seaborne $
15  *
16  * (c) Copyright 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
17  * (see footer for full conditions)
18  *****************************************************************************/

19
20 // Package
21
///////////////
22
package com.hp.hpl.jena.ontology.impl.test;
23
24
25 // Imports
26
///////////////
27
import junit.framework.TestSuite;
28
29 import com.hp.hpl.jena.ontology.*;
30
31
32 /**
33  * <p>
34  * Unit tests for ontology individuals
35  * </p>
36  *
37  * @author Ian Dickinson, HP Labs
38  * (<a HREF="mailto:Ian.Dickinson@hp.com" >email</a>)
39  * @version CVS $Id: TestIndividual.java,v 1.7 2005/02/21 12:07:18 andy_seaborne Exp $
40  */

41 public class TestIndividual
42     extends OntTestBase
43 {
44     // Constants
45
//////////////////////////////////
46

47     // Static variables
48
//////////////////////////////////
49

50
51
52     // Instance variables
53
//////////////////////////////////
54

55     // Constructors
56
//////////////////////////////////
57

58     static public TestSuite suite() {
59         return new TestIndividual( "TestIndividual" );
60     }
61     
62     public TestIndividual( String JavaDoc name ) {
63         super( name );
64     }
65     
66     
67     // External signature methods
68
//////////////////////////////////
69

70     public OntTestCase[] getTests() {
71         return new OntTestCase[] {
72             new OntTestCase( "Individual.sameAs", true, false, true, false ) {
73                 /** Note: 6/Nov/2003 - updated to use sameAs not sameIndividualAs, following changes to OWL spec */
74                 public void ontTest( OntModel m ) throws Exception JavaDoc {
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 JavaDoc[] {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     // Internal implementation methods
104
//////////////////////////////////
105

106     //==============================================================================
107
// Inner class definitions
108
//==============================================================================
109

110 }
111
112
113 /*
114     (c) Copyright 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
115     All rights reserved.
116
117     Redistribution and use in source and binary forms, with or without
118     modification, are permitted provided that the following conditions
119     are met:
120
121     1. Redistributions of source code must retain the above copyright
122        notice, this list of conditions and the following disclaimer.
123
124     2. Redistributions in binary form must reproduce the above copyright
125        notice, this list of conditions and the following disclaimer in the
126        documentation and/or other materials provided with the distribution.
127
128     3. The name of the author may not be used to endorse or promote products
129        derived from this software without specific prior written permission.
130
131     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
132     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
133     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
134     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
135     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
136     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
137     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
138     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
139     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
140     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
141 */

142
143
144
Popular Tags