Source Code Cross Referenced for TestCreate.java in  » RSS-RDF » Jena-2.5.5 » com » hp » hpl » jena » ontology » impl » test » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » RSS RDF » Jena 2.5.5 » com.hp.hpl.jena.ontology.impl.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*****************************************************************************
002:         * Source code information
003:         * -----------------------
004:         * Original author    Ian Dickinson, HP Labs Bristol
005:         * Author email       Ian.Dickinson@hp.com
006:         * Package            Jena 2
007:         * Web                http://sourceforge.net/projects/jena/
008:         * Created            03-Apr-2003
009:         * Filename           $RCSfile: TestCreate.java,v $
010:         * Revision           $Revision: 1.16 $
011:         * Release status     $State: Exp $
012:         *
013:         * Last modified on   $Date: 2008/01/02 12:08:40 $
014:         *               by   $Author: andy_seaborne $
015:         *
016:         * (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
017:         * (see footer for full conditions)
018:         *****************************************************************************/package com.hp.hpl.jena.ontology.impl.test;
019:
020:        // Imports
021:        ///////////////
022:        import com.hp.hpl.jena.rdf.model.*;
023:        import com.hp.hpl.jena.ontology.*;
024:
025:        import junit.framework.*;
026:
027:        /**
028:         * <p>
029:         * Unit test cases for creating values in ontology models
030:         * </p>
031:         *
032:         * @author Ian Dickinson, HP Labs
033:         *         (<a  href="mailto:Ian.Dickinson@hp.com" >email</a>)
034:         * @version CVS $Id: TestCreate.java,v 1.16 2008/01/02 12:08:40 andy_seaborne Exp $
035:         */
036:        public class TestCreate extends TestCase {
037:            // Constants
038:            //////////////////////////////////
039:            public static final String BASE = "http://jena.hpl.hp.com/testing/ontology";
040:            public static final String NS = BASE + "#";
041:
042:            // Static variables
043:            //////////////////////////////////
044:
045:            protected static CreateTestCase[] testCases = new CreateTestCase[] {
046:                    new CreateTestCase("OWL create ontology",
047:                            ProfileRegistry.OWL_LANG, BASE) {
048:                        public OntResource doCreate(OntModel m) {
049:                            return m.createOntology(BASE);
050:                        }
051:
052:                        public boolean test(OntResource r) {
053:                            return r instanceof  Ontology;
054:                        }
055:                    },
056:                    new CreateTestCase("DAML create ontology",
057:                            ProfileRegistry.DAML_LANG, BASE) {
058:                        public OntResource doCreate(OntModel m) {
059:                            return m.createOntology(BASE);
060:                        }
061:
062:                        public boolean test(OntResource r) {
063:                            return r instanceof  Ontology;
064:                        }
065:                    },
066:
067:                    new CreateTestCase("OWL create class",
068:                            ProfileRegistry.OWL_LANG, NS + "C") {
069:                        public OntResource doCreate(OntModel m) {
070:                            return m.createClass(NS + "C");
071:                        }
072:
073:                        public boolean test(OntResource r) {
074:                            return r instanceof  OntClass;
075:                        }
076:                    },
077:
078:                    new CreateTestCase("OWL create anon complement class",
079:                            ProfileRegistry.OWL_LANG, null) {
080:                        public OntResource doCreate(OntModel m) {
081:                            return m.createComplementClass(null, m
082:                                    .createClass(NS + "A"));
083:                        }
084:
085:                        public boolean test(OntResource r) {
086:                            return r instanceof  OntClass
087:                                    && r instanceof  ComplementClass;
088:                        }
089:                    },
090:                    new CreateTestCase("OWL create anon enumeration class",
091:                            ProfileRegistry.OWL_LANG, null) {
092:                        public OntResource doCreate(OntModel m) {
093:                            OntClass A = m.createClass(NS + "A");
094:                            Individual a0 = m.createIndividual(A);
095:                            Individual a1 = m.createIndividual(A);
096:                            Individual a2 = m.createIndividual(A);
097:                            RDFList l = m.createList(new OntResource[] { a0,
098:                                    a1, a2 });
099:                            return m.createEnumeratedClass(null, l);
100:                        }
101:
102:                        public boolean test(OntResource r) {
103:                            return r instanceof  OntClass
104:                                    && r instanceof  EnumeratedClass;
105:                        }
106:                    },
107:                    new CreateTestCase("OWL create anon union class",
108:                            ProfileRegistry.OWL_LANG, null) {
109:                        public OntResource doCreate(OntModel m) {
110:                            OntClass A = m.createClass(NS + "A");
111:                            Individual a0 = m.createIndividual(A);
112:                            Individual a1 = m.createIndividual(A);
113:                            Individual a2 = m.createIndividual(A);
114:                            RDFList l = m.createList(new OntResource[] { a0,
115:                                    a1, a2 });
116:                            return m.createUnionClass(null, l);
117:                        }
118:
119:                        public boolean test(OntResource r) {
120:                            return r instanceof  OntClass
121:                                    && r instanceof  UnionClass;
122:                        }
123:                    },
124:                    new CreateTestCase("OWL create anon intersection class",
125:                            ProfileRegistry.OWL_LANG, null) {
126:                        public OntResource doCreate(OntModel m) {
127:                            OntClass A = m.createClass(NS + "A");
128:                            Individual a0 = m.createIndividual(A);
129:                            Individual a1 = m.createIndividual(A);
130:                            Individual a2 = m.createIndividual(A);
131:                            RDFList l = m.createList(new OntResource[] { a0,
132:                                    a1, a2 });
133:                            return m.createIntersectionClass(null, l);
134:                        }
135:
136:                        public boolean test(OntResource r) {
137:                            return r instanceof  OntClass
138:                                    && r instanceof  IntersectionClass;
139:                        }
140:                    },
141:
142:                    new CreateTestCase("OWL create class",
143:                            ProfileRegistry.OWL_LANG, NS + "C") {
144:                        public OntResource doCreate(OntModel m) {
145:                            return m.createClass(NS + "C");
146:                        }
147:
148:                        public boolean test(OntResource r) {
149:                            return r instanceof  OntClass;
150:                        }
151:                    },
152:
153:                    new CreateTestCase("DAML create class",
154:                            ProfileRegistry.DAML_LANG, NS + "C") {
155:                        public OntResource doCreate(OntModel m) {
156:                            return m.createClass(NS + "C");
157:                        }
158:
159:                        public boolean test(OntResource r) {
160:                            return r instanceof  OntClass;
161:                        }
162:                    },
163:                    new CreateTestCase("DAML create anon class",
164:                            ProfileRegistry.DAML_LANG, null) {
165:                        public OntResource doCreate(OntModel m) {
166:                            return m.createClass();
167:                        }
168:
169:                        public boolean test(OntResource r) {
170:                            return r instanceof  OntClass;
171:                        }
172:                    },
173:
174:                    new CreateTestCase("DAML create anon complement class",
175:                            ProfileRegistry.DAML_LANG, null) {
176:                        public OntResource doCreate(OntModel m) {
177:                            return m.createComplementClass(null, m
178:                                    .createClass(NS + "A"));
179:                        }
180:
181:                        public boolean test(OntResource r) {
182:                            return r instanceof  OntClass
183:                                    && r instanceof  ComplementClass;
184:                        }
185:                    },
186:                    new CreateTestCase("DAML create anon enumeration class",
187:                            ProfileRegistry.DAML_LANG, null) {
188:                        public OntResource doCreate(OntModel m) {
189:                            OntClass A = m.createClass(NS + "A");
190:                            Individual a0 = m.createIndividual(A);
191:                            Individual a1 = m.createIndividual(A);
192:                            Individual a2 = m.createIndividual(A);
193:                            RDFList l = m.createList(new OntResource[] { a0,
194:                                    a1, a2 });
195:                            return m.createEnumeratedClass(null, l);
196:                        }
197:
198:                        public boolean test(OntResource r) {
199:                            return r instanceof  OntClass
200:                                    && r instanceof  EnumeratedClass;
201:                        }
202:                    },
203:                    new CreateTestCase("DAML create anon union class",
204:                            ProfileRegistry.DAML_LANG, null) {
205:                        public OntResource doCreate(OntModel m) {
206:                            OntClass A = m.createClass(NS + "A");
207:                            Individual a0 = m.createIndividual(A);
208:                            Individual a1 = m.createIndividual(A);
209:                            Individual a2 = m.createIndividual(A);
210:                            RDFList l = m.createList(new OntResource[] { a0,
211:                                    a1, a2 });
212:                            return m.createUnionClass(null, l);
213:                        }
214:
215:                        public boolean test(OntResource r) {
216:                            return r instanceof  OntClass
217:                                    && r instanceof  UnionClass;
218:                        }
219:                    },
220:                    new CreateTestCase("DAML create anon intersection class",
221:                            ProfileRegistry.DAML_LANG, null) {
222:                        public OntResource doCreate(OntModel m) {
223:                            OntClass A = m.createClass(NS + "A");
224:                            Individual a0 = m.createIndividual(A);
225:                            Individual a1 = m.createIndividual(A);
226:                            Individual a2 = m.createIndividual(A);
227:                            RDFList l = m.createList(new OntResource[] { a0,
228:                                    a1, a2 });
229:                            return m.createIntersectionClass(null, l);
230:                        }
231:
232:                        public boolean test(OntResource r) {
233:                            return r instanceof  OntClass
234:                                    && r instanceof  IntersectionClass;
235:                        }
236:                    },
237:
238:                    new CreateTestCase("OWL create individual",
239:                            ProfileRegistry.OWL_LANG, NS + "a") {
240:                        public OntResource doCreate(OntModel m) {
241:                            OntClass c = m.createClass(NS + "C");
242:                            return m.createIndividual(NS + "a", c);
243:                        }
244:
245:                        public boolean test(OntResource r) {
246:                            return r instanceof  Individual;
247:                        }
248:                    },
249:                    new CreateTestCase("OWL create anon individual",
250:                            ProfileRegistry.OWL_LANG, null) {
251:                        public OntResource doCreate(OntModel m) {
252:                            OntClass c = m.createClass(NS + "C");
253:                            return m.createIndividual(c);
254:                        }
255:
256:                        public boolean test(OntResource r) {
257:                            return r instanceof  Individual;
258:                        }
259:                    },
260:                    new CreateTestCase("DAML create individual",
261:                            ProfileRegistry.DAML_LANG, NS + "a") {
262:                        public OntResource doCreate(OntModel m) {
263:                            OntClass c = m.createClass(NS + "C");
264:                            return m.createIndividual(NS + "a", c);
265:                        }
266:
267:                        public boolean test(OntResource r) {
268:                            return r instanceof  Individual;
269:                        }
270:                    },
271:                    new CreateTestCase("DAML create anon individual",
272:                            ProfileRegistry.DAML_LANG, null) {
273:                        public OntResource doCreate(OntModel m) {
274:                            OntClass c = m.createClass(NS + "C");
275:                            return m.createIndividual(c);
276:                        }
277:
278:                        public boolean test(OntResource r) {
279:                            return r instanceof  Individual;
280:                        }
281:                    },
282:
283:                    // OWL property types
284:                    new CreateTestCase("OWL create object property",
285:                            ProfileRegistry.OWL_LANG, NS + "p") {
286:                        public OntResource doCreate(OntModel m) {
287:                            return m.createObjectProperty(NS + "p");
288:                        }
289:
290:                        public boolean test(OntResource r) {
291:                            return r instanceof  ObjectProperty;
292:                        }
293:                    },
294:                    new CreateTestCase("OWL create object property non-F",
295:                            ProfileRegistry.OWL_LANG, NS + "p") {
296:                        public OntResource doCreate(OntModel m) {
297:                            return m.createObjectProperty(NS + "p", false);
298:                        }
299:
300:                        public boolean test(OntResource r) {
301:                            return r instanceof  ObjectProperty
302:                                    && !r.canAs(FunctionalProperty.class);
303:                        }
304:                    },
305:                    new CreateTestCase("OWL create object property F",
306:                            ProfileRegistry.OWL_LANG, NS + "p") {
307:                        public OntResource doCreate(OntModel m) {
308:                            return m.createObjectProperty(NS + "p", true);
309:                        }
310:
311:                        public boolean test(OntResource r) {
312:                            return r instanceof  ObjectProperty
313:                                    && r.canAs(FunctionalProperty.class);
314:                        }
315:                    },
316:
317:                    new CreateTestCase("OWL create transitive property",
318:                            ProfileRegistry.OWL_LANG, NS + "p") {
319:                        public OntResource doCreate(OntModel m) {
320:                            return m.createTransitiveProperty(NS + "p");
321:                        }
322:
323:                        public boolean test(OntResource r) {
324:                            return r instanceof  ObjectProperty
325:                                    && r instanceof  TransitiveProperty;
326:                        }
327:                    },
328:                    new CreateTestCase("OWL create transitive property non-F",
329:                            ProfileRegistry.OWL_LANG, NS + "p") {
330:                        public OntResource doCreate(OntModel m) {
331:                            return m.createTransitiveProperty(NS + "p", false);
332:                        }
333:
334:                        public boolean test(OntResource r) {
335:                            return r instanceof  ObjectProperty
336:                                    && r instanceof  TransitiveProperty
337:                                    && !r.canAs(FunctionalProperty.class);
338:                        }
339:                    },
340:                    new CreateTestCase("OWL create transitive property F",
341:                            ProfileRegistry.OWL_LANG, NS + "p") {
342:                        public OntResource doCreate(OntModel m) {
343:                            return m.createTransitiveProperty(NS + "p", true);
344:                        }
345:
346:                        public boolean test(OntResource r) {
347:                            return r instanceof  ObjectProperty
348:                                    && r instanceof  TransitiveProperty
349:                                    && r.canAs(FunctionalProperty.class);
350:                        }
351:                    },
352:                    new CreateTestCase("OWL create symmetric property",
353:                            ProfileRegistry.OWL_LANG, NS + "p") {
354:                        public OntResource doCreate(OntModel m) {
355:                            return m.createSymmetricProperty(NS + "p");
356:                        }
357:
358:                        public boolean test(OntResource r) {
359:                            return r instanceof  ObjectProperty
360:                                    && r instanceof  SymmetricProperty;
361:                        }
362:                    },
363:                    new CreateTestCase("OWL create symmetric property non-F",
364:                            ProfileRegistry.OWL_LANG, NS + "p") {
365:                        public OntResource doCreate(OntModel m) {
366:                            return m.createSymmetricProperty(NS + "p", false);
367:                        }
368:
369:                        public boolean test(OntResource r) {
370:                            return r instanceof  ObjectProperty
371:                                    && r instanceof  SymmetricProperty
372:                                    && !r.canAs(FunctionalProperty.class);
373:                        }
374:                    },
375:                    new CreateTestCase("OWL create symmetric property F",
376:                            ProfileRegistry.OWL_LANG, NS + "p") {
377:                        public OntResource doCreate(OntModel m) {
378:                            return m.createSymmetricProperty(NS + "p", true);
379:                        }
380:
381:                        public boolean test(OntResource r) {
382:                            return r instanceof  ObjectProperty
383:                                    && r instanceof  SymmetricProperty
384:                                    && r.canAs(FunctionalProperty.class);
385:                        }
386:                    },
387:                    new CreateTestCase(
388:                            "OWL create inverse functional property",
389:                            ProfileRegistry.OWL_LANG, NS + "p") {
390:                        public OntResource doCreate(OntModel m) {
391:                            return m.createInverseFunctionalProperty(NS + "p");
392:                        }
393:
394:                        public boolean test(OntResource r) {
395:                            return r instanceof  ObjectProperty
396:                                    && r instanceof  InverseFunctionalProperty;
397:                        }
398:                    },
399:                    new CreateTestCase(
400:                            "OWL create inverse functional property non-F",
401:                            ProfileRegistry.OWL_LANG, NS + "p") {
402:                        public OntResource doCreate(OntModel m) {
403:                            return m.createInverseFunctionalProperty(NS + "p",
404:                                    false);
405:                        }
406:
407:                        public boolean test(OntResource r) {
408:                            return r instanceof  ObjectProperty
409:                                    && r instanceof  InverseFunctionalProperty
410:                                    && !r.canAs(FunctionalProperty.class);
411:                        }
412:                    },
413:                    new CreateTestCase(
414:                            "OWL create inverse functional property F",
415:                            ProfileRegistry.OWL_LANG, NS + "p") {
416:                        public OntResource doCreate(OntModel m) {
417:                            return m.createInverseFunctionalProperty(NS + "p",
418:                                    true);
419:                        }
420:
421:                        public boolean test(OntResource r) {
422:                            return r instanceof  ObjectProperty
423:                                    && r instanceof  InverseFunctionalProperty
424:                                    && r.canAs(FunctionalProperty.class);
425:                        }
426:                    },
427:
428:                    new CreateTestCase("OWL create datatype property",
429:                            ProfileRegistry.OWL_LANG, NS + "p") {
430:                        public OntResource doCreate(OntModel m) {
431:                            return m.createDatatypeProperty(NS + "p");
432:                        }
433:
434:                        public boolean test(OntResource r) {
435:                            return r instanceof  DatatypeProperty;
436:                        }
437:                    },
438:                    new CreateTestCase("OWL create datatype property non-F",
439:                            ProfileRegistry.OWL_LANG, NS + "p") {
440:                        public OntResource doCreate(OntModel m) {
441:                            return m.createDatatypeProperty(NS + "p", false);
442:                        }
443:
444:                        public boolean test(OntResource r) {
445:                            return r instanceof  DatatypeProperty
446:                                    && !r.canAs(FunctionalProperty.class);
447:                        }
448:                    },
449:                    new CreateTestCase("OWL create datatype property F",
450:                            ProfileRegistry.OWL_LANG, NS + "p") {
451:                        public OntResource doCreate(OntModel m) {
452:                            return m.createDatatypeProperty(NS + "p", true);
453:                        }
454:
455:                        public boolean test(OntResource r) {
456:                            return r instanceof  DatatypeProperty
457:                                    && r.canAs(FunctionalProperty.class);
458:                        }
459:                    },
460:
461:                    new CreateTestCase("OWL create annotation property",
462:                            ProfileRegistry.OWL_LANG, NS + "p") {
463:                        public OntResource doCreate(OntModel m) {
464:                            return m.createAnnotationProperty(NS + "p");
465:                        }
466:
467:                        public boolean test(OntResource r) {
468:                            return r instanceof  AnnotationProperty;
469:                        }
470:                    },
471:
472:                    // DAML property types
473:                    new CreateTestCase("DAML create object property",
474:                            ProfileRegistry.DAML_LANG, NS + "p") {
475:                        public OntResource doCreate(OntModel m) {
476:                            return m.createObjectProperty(NS + "p");
477:                        }
478:
479:                        public boolean test(OntResource r) {
480:                            return r instanceof  ObjectProperty;
481:                        }
482:                    },
483:                    new CreateTestCase("DAML create object property non-F",
484:                            ProfileRegistry.DAML_LANG, NS + "p") {
485:                        public OntResource doCreate(OntModel m) {
486:                            return m.createObjectProperty(NS + "p", false);
487:                        }
488:
489:                        public boolean test(OntResource r) {
490:                            return r instanceof  ObjectProperty
491:                                    && !r.canAs(FunctionalProperty.class);
492:                        }
493:                    },
494:                    new CreateTestCase("DAML create object property F",
495:                            ProfileRegistry.DAML_LANG, NS + "p") {
496:                        public OntResource doCreate(OntModel m) {
497:                            return m.createObjectProperty(NS + "p", true);
498:                        }
499:
500:                        public boolean test(OntResource r) {
501:                            return r instanceof  ObjectProperty
502:                                    && r.canAs(FunctionalProperty.class);
503:                        }
504:                    },
505:
506:                    new CreateTestCase("DAML create transitive property",
507:                            ProfileRegistry.DAML_LANG, NS + "p") {
508:                        public OntResource doCreate(OntModel m) {
509:                            return m.createTransitiveProperty(NS + "p");
510:                        }
511:
512:                        public boolean test(OntResource r) {
513:                            return r instanceof  ObjectProperty
514:                                    && r instanceof  TransitiveProperty;
515:                        }
516:                    },
517:                    new CreateTestCase("DAML create transitive property non-F",
518:                            ProfileRegistry.DAML_LANG, NS + "p") {
519:                        public OntResource doCreate(OntModel m) {
520:                            return m.createTransitiveProperty(NS + "p", false);
521:                        }
522:
523:                        public boolean test(OntResource r) {
524:                            return r instanceof  ObjectProperty
525:                                    && r instanceof  TransitiveProperty
526:                                    && !r.canAs(FunctionalProperty.class);
527:                        }
528:                    },
529:                    new CreateTestCase("DAML create transitive property F",
530:                            ProfileRegistry.DAML_LANG, NS + "p") {
531:                        public OntResource doCreate(OntModel m) {
532:                            return m.createTransitiveProperty(NS + "p", true);
533:                        }
534:
535:                        public boolean test(OntResource r) {
536:                            return r instanceof  ObjectProperty
537:                                    && r instanceof  TransitiveProperty
538:                                    && r.canAs(FunctionalProperty.class);
539:                        }
540:                    },
541:                    new CreateTestCase(
542:                            "DAML create inverse functional property",
543:                            ProfileRegistry.DAML_LANG, NS + "p") {
544:                        public OntResource doCreate(OntModel m) {
545:                            return m.createInverseFunctionalProperty(NS + "p");
546:                        }
547:
548:                        public boolean test(OntResource r) {
549:                            return r instanceof  ObjectProperty
550:                                    && r instanceof  InverseFunctionalProperty;
551:                        }
552:                    },
553:                    new CreateTestCase(
554:                            "DAML create inverse functional property non-F",
555:                            ProfileRegistry.DAML_LANG, NS + "p") {
556:                        public OntResource doCreate(OntModel m) {
557:                            return m.createInverseFunctionalProperty(NS + "p",
558:                                    false);
559:                        }
560:
561:                        public boolean test(OntResource r) {
562:                            return r instanceof  ObjectProperty
563:                                    && r instanceof  InverseFunctionalProperty
564:                                    && !r.canAs(FunctionalProperty.class);
565:                        }
566:                    },
567:                    new CreateTestCase(
568:                            "DAML create inverse functional property F",
569:                            ProfileRegistry.DAML_LANG, NS + "p") {
570:                        public OntResource doCreate(OntModel m) {
571:                            return m.createInverseFunctionalProperty(NS + "p",
572:                                    true);
573:                        }
574:
575:                        public boolean test(OntResource r) {
576:                            return r instanceof  ObjectProperty
577:                                    && r instanceof  InverseFunctionalProperty
578:                                    && r.canAs(FunctionalProperty.class);
579:                        }
580:                    },
581:
582:                    new CreateTestCase("DAML create datatype property",
583:                            ProfileRegistry.DAML_LANG, NS + "p") {
584:                        public OntResource doCreate(OntModel m) {
585:                            return m.createDatatypeProperty(NS + "p");
586:                        }
587:
588:                        public boolean test(OntResource r) {
589:                            return r instanceof  DatatypeProperty;
590:                        }
591:                    },
592:                    new CreateTestCase("DAML create datatype property non-F",
593:                            ProfileRegistry.DAML_LANG, NS + "p") {
594:                        public OntResource doCreate(OntModel m) {
595:                            return m.createDatatypeProperty(NS + "p", false);
596:                        }
597:
598:                        public boolean test(OntResource r) {
599:                            return r instanceof  DatatypeProperty
600:                                    && !r.canAs(FunctionalProperty.class);
601:                        }
602:                    },
603:                    new CreateTestCase("DAML create datatype property F",
604:                            ProfileRegistry.DAML_LANG, NS + "p") {
605:                        public OntResource doCreate(OntModel m) {
606:                            return m.createDatatypeProperty(NS + "p", true);
607:                        }
608:
609:                        public boolean test(OntResource r) {
610:                            return r instanceof  DatatypeProperty
611:                                    && r.canAs(FunctionalProperty.class);
612:                        }
613:                    },
614:
615:                    new CreateTestCase("OWL create allDifferent",
616:                            ProfileRegistry.OWL_LANG, null) {
617:                        public OntResource doCreate(OntModel m) {
618:                            return m.createAllDifferent();
619:                        }
620:
621:                        public boolean test(OntResource r) {
622:                            return r instanceof  AllDifferent;
623:                        }
624:                    },
625:
626:                    // Restrictions
627:
628:                    new CreateTestCase("OWL create restriction",
629:                            ProfileRegistry.OWL_LANG, NS + "C") {
630:                        public OntResource doCreate(OntModel m) {
631:                            return m.createRestriction(NS + "C", null);
632:                        }
633:
634:                        public boolean test(OntResource r) {
635:                            return r instanceof  Restriction;
636:                        }
637:                    },
638:                    new CreateTestCase("OWL create anon restriction",
639:                            ProfileRegistry.OWL_LANG, null) {
640:                        public OntResource doCreate(OntModel m) {
641:                            return m.createRestriction(null);
642:                        }
643:
644:                        public boolean test(OntResource r) {
645:                            return r instanceof  Restriction;
646:                        }
647:                    },
648:
649:                    new CreateTestCase("OWL create has value restriction",
650:                            ProfileRegistry.OWL_LANG, null) {
651:                        public OntResource doCreate(OntModel m) {
652:                            Property p = m.createObjectProperty(NS + "p");
653:                            Resource x = m.createResource(NS + "x");
654:                            return m.createHasValueRestriction(null, p, x);
655:                        }
656:
657:                        public boolean test(OntResource r) {
658:                            return r instanceof  HasValueRestriction;
659:                        }
660:                    },
661:                    new CreateTestCase(
662:                            "OWL create has value restriction (literal)",
663:                            ProfileRegistry.OWL_LANG, null) {
664:                        public OntResource doCreate(OntModel m) {
665:                            Property p = m.createDatatypeProperty(NS + "p");
666:                            Literal x = m.createTypedLiteral(new Integer(42));
667:                            return m.createHasValueRestriction(null, p, x);
668:                        }
669:
670:                        public boolean test(OntResource r) {
671:                            return r instanceof  HasValueRestriction;
672:                        }
673:                    },
674:                    new CreateTestCase(
675:                            "OWL create all values from restriction",
676:                            ProfileRegistry.OWL_LANG, null) {
677:                        public OntResource doCreate(OntModel m) {
678:                            Property p = m.createObjectProperty(NS + "p");
679:                            OntClass c = m.createClass(NS + "C");
680:                            return m.createAllValuesFromRestriction(null, p, c);
681:                        }
682:
683:                        public boolean test(OntResource r) {
684:                            return r instanceof  AllValuesFromRestriction;
685:                        }
686:                    },
687:                    new CreateTestCase(
688:                            "OWL create some values from restriction",
689:                            ProfileRegistry.OWL_LANG, null) {
690:                        public OntResource doCreate(OntModel m) {
691:                            Property p = m.createObjectProperty(NS + "p");
692:                            OntClass c = m.createClass(NS + "C");
693:                            return m
694:                                    .createSomeValuesFromRestriction(null, p, c);
695:                        }
696:
697:                        public boolean test(OntResource r) {
698:                            return r instanceof  SomeValuesFromRestriction;
699:                        }
700:                    },
701:                    new CreateTestCase("OWL create cardinality restriction",
702:                            ProfileRegistry.OWL_LANG, null) {
703:                        public OntResource doCreate(OntModel m) {
704:                            Property p = m.createObjectProperty(NS + "p");
705:                            return m.createCardinalityRestriction(null, p, 17);
706:                        }
707:
708:                        public boolean test(OntResource r) {
709:                            return r instanceof  CardinalityRestriction;
710:                        }
711:                    },
712:                    new CreateTestCase(
713:                            "OWL create min cardinality restriction",
714:                            ProfileRegistry.OWL_LANG, null) {
715:                        public OntResource doCreate(OntModel m) {
716:                            Property p = m.createObjectProperty(NS + "p");
717:                            return m
718:                                    .createMinCardinalityRestriction(null, p, 1);
719:                        }
720:
721:                        public boolean test(OntResource r) {
722:                            return r instanceof  MinCardinalityRestriction;
723:                        }
724:                    },
725:                    new CreateTestCase(
726:                            "OWL create max cardinality restriction",
727:                            ProfileRegistry.OWL_LANG, null) {
728:                        public OntResource doCreate(OntModel m) {
729:                            Property p = m.createObjectProperty(NS + "p");
730:                            return m
731:                                    .createMaxCardinalityRestriction(null, p, 4);
732:                        }
733:
734:                        public boolean test(OntResource r) {
735:                            return r instanceof  MaxCardinalityRestriction;
736:                        }
737:                    },
738:
739:                    new CreateTestCase("DAML create restriction",
740:                            ProfileRegistry.DAML_LANG, NS + "C") {
741:                        public OntResource doCreate(OntModel m) {
742:                            return m.createRestriction(NS + "C", null);
743:                        }
744:
745:                        public boolean test(OntResource r) {
746:                            return r instanceof  Restriction;
747:                        }
748:                    },
749:                    new CreateTestCase("DAML create anon restriction",
750:                            ProfileRegistry.DAML_LANG, null) {
751:                        public OntResource doCreate(OntModel m) {
752:                            return m.createRestriction(null);
753:                        }
754:
755:                        public boolean test(OntResource r) {
756:                            return r instanceof  Restriction;
757:                        }
758:                    },
759:
760:                    new CreateTestCase("DAML create has value restriction",
761:                            ProfileRegistry.DAML_LANG, null) {
762:                        public OntResource doCreate(OntModel m) {
763:                            Property p = m.createObjectProperty(NS + "p");
764:                            Resource x = m.createResource(NS + "x");
765:                            return m.createHasValueRestriction(null, p, x);
766:                        }
767:
768:                        public boolean test(OntResource r) {
769:                            return r instanceof  HasValueRestriction;
770:                        }
771:                    },
772:                    new CreateTestCase(
773:                            "DAML create has value restriction (literal)",
774:                            ProfileRegistry.DAML_LANG, null) {
775:                        public OntResource doCreate(OntModel m) {
776:                            Property p = m.createDatatypeProperty(NS + "p");
777:                            Literal x = m.createTypedLiteral(new Integer(42));
778:                            return m.createHasValueRestriction(null, p, x);
779:                        }
780:
781:                        public boolean test(OntResource r) {
782:                            return r instanceof  HasValueRestriction;
783:                        }
784:                    },
785:                    new CreateTestCase(
786:                            "DAML create all values from restriction",
787:                            ProfileRegistry.DAML_LANG, null) {
788:                        public OntResource doCreate(OntModel m) {
789:                            Property p = m.createObjectProperty(NS + "p");
790:                            OntClass c = m.createClass(NS + "C");
791:                            return m.createAllValuesFromRestriction(null, p, c);
792:                        }
793:
794:                        public boolean test(OntResource r) {
795:                            return r instanceof  AllValuesFromRestriction;
796:                        }
797:                    },
798:                    new CreateTestCase(
799:                            "DAML create some values from restriction",
800:                            ProfileRegistry.DAML_LANG, null) {
801:                        public OntResource doCreate(OntModel m) {
802:                            Property p = m.createObjectProperty(NS + "p");
803:                            OntClass c = m.createClass(NS + "C");
804:                            return m
805:                                    .createSomeValuesFromRestriction(null, p, c);
806:                        }
807:
808:                        public boolean test(OntResource r) {
809:                            return r instanceof  SomeValuesFromRestriction;
810:                        }
811:                    },
812:                    new CreateTestCase("DAML create cardinality restriction",
813:                            ProfileRegistry.DAML_LANG, null) {
814:                        public OntResource doCreate(OntModel m) {
815:                            Property p = m.createObjectProperty(NS + "p");
816:                            return m.createCardinalityRestriction(null, p, 17);
817:                        }
818:
819:                        public boolean test(OntResource r) {
820:                            return r instanceof  CardinalityRestriction;
821:                        }
822:                    },
823:                    new CreateTestCase(
824:                            "DAML create min cardinality restriction",
825:                            ProfileRegistry.DAML_LANG, null) {
826:                        public OntResource doCreate(OntModel m) {
827:                            Property p = m.createObjectProperty(NS + "p");
828:                            return m
829:                                    .createMinCardinalityRestriction(null, p, 1);
830:                        }
831:
832:                        public boolean test(OntResource r) {
833:                            return r instanceof  MinCardinalityRestriction;
834:                        }
835:                    },
836:                    new CreateTestCase(
837:                            "DAML create max cardinality restriction",
838:                            ProfileRegistry.DAML_LANG, null) {
839:                        public OntResource doCreate(OntModel m) {
840:                            Property p = m.createObjectProperty(NS + "p");
841:                            return m
842:                                    .createMaxCardinalityRestriction(null, p, 4);
843:                        }
844:
845:                        public boolean test(OntResource r) {
846:                            return r instanceof  MaxCardinalityRestriction;
847:                        }
848:                    },
849:
850:            };
851:
852:            // Instance variables
853:            //////////////////////////////////
854:
855:            // Constructors
856:            //////////////////////////////////
857:
858:            public TestCreate(String name) {
859:                super (name);
860:            }
861:
862:            // External signature methods
863:            //////////////////////////////////
864:
865:            protected String getTestName() {
866:                return "TestCreate";
867:            }
868:
869:            public static TestSuite suite() {
870:                TestSuite s = new TestSuite("TestCreate");
871:
872:                for (int i = 0; i < testCases.length; i++) {
873:                    s.addTest(testCases[i]);
874:                }
875:
876:                return s;
877:            }
878:
879:            // Internal implementation methods
880:            //////////////////////////////////
881:
882:            //==============================================================================
883:            // Inner class definitions
884:            //==============================================================================
885:
886:            protected static class CreateTestCase extends TestCase {
887:                protected String m_lang;
888:                protected String m_uri;
889:
890:                public CreateTestCase(String name, String lang, String uri) {
891:                    super (name);
892:                    m_lang = lang;
893:                    m_uri = uri;
894:                }
895:
896:                public void runTest() {
897:                    OntModel m = ModelFactory.createOntologyModel(m_lang);
898:
899:                    // do the creation step
900:                    OntResource r = doCreate(m);
901:                    assertNotNull("Result of creation step should not be null",
902:                            r);
903:
904:                    if (m_uri == null) {
905:                        assertTrue("Created resource should be anonymous", r
906:                                .isAnon());
907:                    } else {
908:                        assertEquals("Created resource has wrong uri", m_uri, r
909:                                .getURI());
910:                    }
911:
912:                    assertTrue("Result test failed", test(r));
913:                }
914:
915:                public void setUp() {
916:                    // ensure the ont doc manager is in a consistent state
917:                    OntDocumentManager.getInstance().reset(true);
918:                }
919:
920:                /* get the resource */
921:                public OntResource doCreate(OntModel m) {
922:                    // to be overridden in sub-classes
923:                    return null;
924:                }
925:
926:                /* test the Java type of the result, and other tests */
927:                public boolean test(OntResource r) {
928:                    return true;
929:                }
930:
931:            }
932:        }
933:
934:        /*
935:         (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
936:         All rights reserved.
937:
938:         Redistribution and use in source and binary forms, with or without
939:         modification, are permitted provided that the following conditions
940:         are met:
941:
942:         1. Redistributions of source code must retain the above copyright
943:         notice, this list of conditions and the following disclaimer.
944:
945:         2. Redistributions in binary form must reproduce the above copyright
946:         notice, this list of conditions and the following disclaimer in the
947:         documentation and/or other materials provided with the distribution.
948:
949:         3. The name of the author may not be used to endorse or promote products
950:         derived from this software without specific prior written permission.
951:
952:         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
953:         IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
954:         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
955:         IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
956:         INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
957:         NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
958:         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
959:         THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
960:         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
961:         THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
962:         */
w__w_w__._j_av___a2_s__.___c__om | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.