1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package test.wsmo4j.validator;
19
20 import java.io.InputStream;
21 import java.io.InputStreamReader;
22
23 import org.omwg.ontology.Ontology;
24 import org.wsmo.factory.Factory;
25 import org.wsmo.validator.WsmlValidator;
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 public class ValidatorFileTests extends ValidatorTestCase {
43
44
45
46
47
48 public void testValidCoreModel()throws Exception {
49
50 InputStream is = this.getClass().getClassLoader().getResourceAsStream(
51 "test/wsmo4j/validator/valid_wsml_core_test.wsml");
52 assertNotNull(is);
53
54 ontology = (Ontology)parser.parse(new InputStreamReader(is))[0];
55
56 WsmlValidator w = Factory.createWsmlValidator(null);
57 boolean b = w.isValid(ontology, "http://www.wsmo.org/wsml/wsml-syntax/wsml-core", errors, warnings);
58
59
60 assertTrue(b);
61 }
62
63
64
65
66
67
68 public void testValidConceptModel()throws Exception {
69
70 InputStream is = this.getClass().getClassLoader().getResourceAsStream(
71 "test/wsmo4j/validator/valid_wsml_core_conceptual_test.wsml");
72 assertNotNull(is);
73
74 ontology = (Ontology)parser.parse(new InputStreamReader(is))[0];
75
76 WsmlValidator w = Factory.createWsmlValidator(null);
77 boolean b = w.isValid(ontology, "http://www.wsmo.org/wsml/wsml-syntax/wsml-core", errors, warnings);
78
79
80 assertTrue(b);
81 }
82
83
84
85
86
87
88
89 public void testInvalidConceptModel() throws Exception {
90
91 InputStream is = this.getClass().getClassLoader().getResourceAsStream(
92 "test/wsmo4j/validator/invalid_wsml_core_conceptual_test.wsml");
93 assertNotNull(is);
94
95 ontology = (Ontology)parser.parse(new InputStreamReader(is))[0];
96
97 WsmlValidator w = Factory.createWsmlValidator(null);
98 boolean b = w.isValid(ontology, "http://www.wsmo.org/wsml/wsml-syntax/wsml-core", errors, warnings);
99
100
101 assertFalse(b);
102 }
103
104
105
106
107
108
109
110 public void testInvalidCoreModel()throws Exception {
111
112 InputStream is = this.getClass().getClassLoader().getResourceAsStream(
113 "test/wsmo4j/validator/invalid_wsml_core_test.wsml");
114 assertNotNull(is);
115
116 ontology = (Ontology)parser.parse(new InputStreamReader(is))[0];
117
118 WsmlValidator w = Factory.createWsmlValidator(null);
119 boolean b = w.isValid(ontology, "http://www.wsmo.org/wsml/wsml-syntax/wsml-core", errors, warnings);
120
121
122 assertFalse(b);
123 }
124
125
126
127
128
129 public void testValidDLModel()throws Exception {
130
131 InputStream is = this.getClass().getClassLoader().getResourceAsStream(
132 "test/wsmo4j/validator/valid_wsml_dl_test.wsml");
133 assertNotNull(is);
134
135 ontology = (Ontology)parser.parse(new InputStreamReader(is))[0];
136
137 WsmlValidator w = Factory.createWsmlValidator(null);
138 boolean b = w.isValid(ontology, "http://www.wsmo.org/wsml/wsml-syntax/wsml-dl", errors, warnings);
139
140
141 assertTrue(b);
142 }
143
144
145
146
147
148 public void testFlightModel()throws Exception {
149
150 InputStream is = this.getClass().getClassLoader().getResourceAsStream(
151 "test/wsmo4j/validator/valid_wsml_flight_test.wsml");
152 assertNotNull(is);
153
154 ontology = (Ontology)parser.parse(new InputStreamReader(is))[0];
155 WsmlValidator w = Factory.createWsmlValidator(null);
156 boolean b = w.isValid(ontology, "http://www.wsmo.org/wsml/wsml-syntax/wsml-flight", errors, warnings);
157
158
159 assertTrue(b);
160 }
161
162
163
164
165
166
167
168 public void testInvalidFlightModel()throws Exception {
169
170 InputStream is = this.getClass().getClassLoader().getResourceAsStream(
171 "test/wsmo4j/validator/invalid_wsml_flight_test.wsml");
172 assertNotNull(is);
173
174 ontology = (Ontology)parser.parse(new InputStreamReader(is))[0];
175
176 WsmlValidator w = Factory.createWsmlValidator(null);
177 boolean b = w.isValid(ontology, "http://www.wsmo.org/wsml/wsml-syntax/wsml-flight", errors, warnings);
178
179
180 assertFalse(b);
181 }
182
183
184
185
186
187 public void testRuleModel()throws Exception {
188
189 InputStream is = this.getClass().getClassLoader().getResourceAsStream(
190 "test/wsmo4j/validator/valid_wsml_rule_test.wsml");
191 assertNotNull(is);
192
193 ontology = (Ontology)parser.parse(new InputStreamReader(is))[0];
194
195 WsmlValidator w = Factory.createWsmlValidator(null);
196 boolean b = w.isValid(ontology, "http://www.wsmo.org/wsml/wsml-syntax/wsml-rule", errors, warnings);
197
198
199 assertTrue(b);
200 }
201
202
203
204
205
206
207
208 public void testInvalidRuleModel()throws Exception {
209
210 InputStream is = this.getClass().getClassLoader().getResourceAsStream(
211 "test/wsmo4j/validator/invalid_wsml_rule_test.wsml");
212 assertNotNull(is);
213
214 ontology = (Ontology)parser.parse(new InputStreamReader(is))[0];
215
216 WsmlValidator w = Factory.createWsmlValidator(null);
217 boolean b = w.isValid(ontology, "http://www.wsmo.org/wsml/wsml-syntax/wsml-rule", errors, warnings);
218
219
220 assertFalse(b);
221 }
222
223 }
224
225
226
227
228
229
230
231
232
233