1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package test.wsmo4j.common;
19
20 import org.omwg.ontology.*;
21 import org.wsmo.common.*;
22 import org.wsmo.common.exception.*;
23 import org.wsmo.factory.*;
24 import org.wsmo.wsml.*;
25
26 import test.wsmo4j.Wsmo4jTestCase;
27
28
29
30
31
32
33
34
35
36 public class IDReferenceTest extends Wsmo4jTestCase {
37
38 private static final String DEFAULT_NS = "http://ex.org#";
39
40 private Parser parser = Factory.createParser(null);
41
42 public void testIDReference() throws Exception {
43 String test = "namespace _\"http://ex.org#\" \n" +
44 "ontology ont"+System.currentTimeMillis()+" \n" +
45 "concept car subConceptOf vehicle \n"+
46 "concept vehicle \n" +
47 " \n ";
48 Ontology o = (Ontology)parser.parse(new StringBuffer(test))[0];
49 Concept airplaine =
50 o.findConcept(factory.createIRI(DEFAULT_NS+"vehicle"));
51 assertEquals(1,airplaine.listSubConcepts().size());
52 }
53
54
55 Relation relation = null;
56
57
58
59
60
61 public void testMetaModeling() throws Exception {
62 IRI duplicatedIRI = factory.createIRI("http://duplicated/iri");
63
64
65 Concept concept = factory.createConcept(duplicatedIRI);
66
67 relation = factory.createRelation(duplicatedIRI);
68
69 assertEquals("Duplicated IRI fails!", concept, factory.getConcept(duplicatedIRI));
70 assertEquals("Duplicated IRI fails!", relation, factory.getRelation(duplicatedIRI));
71 }
72
73
74
75
76
77
78 public void testWSMOObjectRemoval() throws Exception {
79 System.gc();
80 IRI duplicatedIRI = factory.createIRI("http://duplicated/iri");
81
82 try {
83 Relation relation = factory.getRelation(duplicatedIRI);
84 relation.listRelationInstances();
85 }
86 catch (SynchronisationException e) {
87 e.printStackTrace();
88 fail("Object was removed!");
89 }
90
91 try {
92
93 factory.getConcept(duplicatedIRI).createAttribute(duplicatedIRI);
94 fail("Removal test fails");
95 }
96 catch (SynchronisationException e) {
97 assertTrue("Object is removed!", true);
98 }
99 }
100
101 public void testMetaModelling2() throws Exception{
102 IRI aircraft = factory.createIRI("http://ex.org#aircraft");
103 IRI boing747 = factory.createIRI("http://ex.org#boing747");
104 IRI af1 = factory.createIRI("http://ex.org#airforceone");
105 Concept C_aircraft = factory.getConcept(aircraft);
106 Instance I_boing747 = factory.createInstance(boing747);
107 Concept C_boing747 = factory.getConcept(boing747);
108 Instance I_af1 = factory.createInstance(af1);
109 I_boing747.addConcept(C_aircraft);
110 I_af1.addConcept(C_boing747);
111 }
112 }
113
114
115
116
117
118
119
120
121
122
123
124
125