KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*****************************************************************************
2  * Source code information
3  * -----------------------
4  * Original author Ian Dickinson, HP Labs Bristol
5  * Author email ian.dickinson@hp.com
6  * Package Jena2
7  * Web site http://jena.sourceforge.net
8  * Created 07-Dec-2004
9  * Filename $RCSfile: TestOntClass.java,v $
10  * Revision $Revision: 1.4 $
11  * Release status $State: Exp $
12  *
13  * Last modified on $Date: 2005/04/08 17:38:50 $
14  * by $Author: ian_dickinson $
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 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 /**
33  * <p>
34  * Misc. tests for OntClass, over and above those in
35  * {@link TestClassExpression}
36  * </p>
37  *
38  * @author Ian Dickinson, HP Labs (<a HREF="mailto:Ian.Dickinson@hp.com">email</a>)
39  * @version CVS $Id: TestOntClass.java,v 1.4 2005/04/08 17:38:50 ian_dickinson Exp $
40  */

41 public class TestOntClass
42     extends ModelTestBase
43 {
44     // Constants
45
//////////////////////////////////
46

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

50     private static final String JavaDoc NS = "http://example.com/test#";
51
52     // Instance variables
53
//////////////////////////////////
54

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

58     public TestOntClass( String JavaDoc name ) {
59         super( name );
60     }
61
62     // External signature methods
63
//////////////////////////////////
64

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     // Internal implementation methods
183
//////////////////////////////////
184

185     //==============================================================================
186
// Inner class definitions
187
//==============================================================================
188

189 }
190
191
192
193 /*
194     (c) Copyright 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
195     All rights reserved.
196
197     Redistribution and use in source and binary forms, with or without
198     modification, are permitted provided that the following conditions
199     are met:
200
201     1. Redistributions of source code must retain the above copyright
202        notice, this list of conditions and the following disclaimer.
203
204     2. Redistributions in binary form must reproduce the above copyright
205        notice, this list of conditions and the following disclaimer in the
206        documentation and/or other materials provided with the distribution.
207
208     3. The name of the author may not be used to endorse or promote products
209        derived from this software without specific prior written permission.
210
211     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
212     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
213     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
214     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
215     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
216     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
217     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
218     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
219     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
220     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
221 */

222
223
Popular Tags