1 package gate.creole.ontology;
2
3 import java.net.MalformedURLException;
4 import java.net.URL;
5 import java.util.List;
6 import java.util.Set;
7 import gate.annotation.TestAnnotation;
8 import gate.creole.ResourceInstantiationException;
9 import gate.creole.ontology.jena.JenaOntologyImpl;
10 import junit.framework.Test;
11 import junit.framework.TestCase;
12 import junit.framework.TestSuite;
13
14
18 public class TestOntologyAPI extends TestCase {
19 public static void main(String[] args) {
20 junit.textui.TestRunner.run(TestOntologyAPI.class);
21 }
22
23 public TestOntologyAPI(String arg0) {
24 super(arg0);
25 }
26
27 protected void setUp() throws Exception {
28 super.setUp();
29 }
30
31 protected void tearDown() throws Exception {
32 super.tearDown();
33 }
34
35 public void testLoadingOWLOntology() throws MalformedURLException,
38 ResourceInstantiationException {
39 JenaOntologyImpl onto = new JenaOntologyImpl();
40 URL url = new URL("http://gate.ac.uk/tests/demo.owl");
41 onto.load(url, JenaOntologyImpl.OWL_LITE);
42 Ontology ontology = (Ontology)onto;
44 int classNum = ontology.getClasses().size();
45 assertEquals(classNum, 18);
46 TClass aClass = ontology.getClassByName(null);
48 assertNull(aClass);
49 Set topclasses = ontology.getTopClasses();
51 assertEquals(topclasses.size(), 5);
52 aClass = ontology.getClassByName("Department");
54 assertNotNull(aClass);
55 List supclassbydist = aClass.getSuperClassesVSDistance();
57 assertEquals(supclassbydist.size(), 2);
59 aClass = ontology.getClassByName("Organization");
61 assertNotNull(aClass);
62 assertTrue(aClass.isTopClass());
63 List subclasses = aClass.getSubClassesVSDistance();
64 assertEquals(subclasses.size(), 2);
65 }
66
67 public static Test suite() {
68 return new TestSuite(TestOntologyAPI.class);
69 }
71 }
72