Source Code Cross Referenced for TestProperty.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            26-Mar-2003
009:         * Filename           $RCSfile: TestProperty.java,v $
010:         * Revision           $Revision: 1.16 $
011:         * Release status     $State: Exp $
012:         *
013:         * Last modified on   $Date: 2008/01/02 12:08:41 $
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 junit.framework.TestSuite;
023:
024:        import com.hp.hpl.jena.ontology.*;
025:        import com.hp.hpl.jena.rdf.model.Property;
026:        import com.hp.hpl.jena.vocabulary.RDF;
027:
028:        /**
029:         * <p>
030:         * Unit test cases for the Ontology class
031:         * </p>
032:         *
033:         * @author Ian Dickinson, HP Labs
034:         *         (<a  href="mailto:Ian.Dickinson@hp.com" >email</a>)
035:         * @version CVS $Id: TestProperty.java,v 1.16 2008/01/02 12:08:41 andy_seaborne Exp $
036:         */
037:        public class TestProperty extends OntTestBase {
038:            // Constants
039:            //////////////////////////////////
040:
041:            // Static variables
042:            //////////////////////////////////
043:
044:            // Instance variables
045:            //////////////////////////////////
046:
047:            // Constructors
048:            //////////////////////////////////
049:
050:            static public TestSuite suite() {
051:                return new TestProperty("TestProperty");
052:            }
053:
054:            public TestProperty(String name) {
055:                super (name);
056:            }
057:
058:            // External signature methods
059:            //////////////////////////////////
060:
061:            public OntTestCase[] getTests() {
062:                return new OntTestCase[] {
063:                        new OntTestCase("OntProperty.super-property", true,
064:                                true, true, true) {
065:                            public void ontTest(OntModel m) throws Exception {
066:                                Profile prof = m.getProfile();
067:                                OntProperty p = m.createOntProperty(NS + "p");
068:                                OntProperty q = m.createOntProperty(NS + "q");
069:                                OntProperty r = m.createOntProperty(NS + "r");
070:
071:                                p.addSuperProperty(q);
072:                                assertEquals("Cardinality should be 1", 1, p
073:                                        .getCardinality(prof.SUB_PROPERTY_OF()));
074:                                assertEquals("p have super-prop q", q, p
075:                                        .getSuperProperty());
076:
077:                                p.addSuperProperty(r);
078:                                assertEquals("Cardinality should be 2", 2, p
079:                                        .getCardinality(prof.SUB_PROPERTY_OF()));
080:                                iteratorTest(p.listSuperProperties(),
081:                                        new Object[] { q, r });
082:
083:                                p.setSuperProperty(r);
084:                                assertEquals("Cardinality should be 1", 1, p
085:                                        .getCardinality(prof.SUB_PROPERTY_OF()));
086:                                assertEquals("p shuold have super-prop r", r, p
087:                                        .getSuperProperty());
088:
089:                                p.removeSuperProperty(q);
090:                                assertEquals("Cardinality should be 1", 1, p
091:                                        .getCardinality(prof.SUB_PROPERTY_OF()));
092:                                p.removeSuperProperty(r);
093:                                assertEquals("Cardinality should be 0", 0, p
094:                                        .getCardinality(prof.SUB_PROPERTY_OF()));
095:                            }
096:                        },
097:                        new OntTestCase("OntProperty.sub-property", true, true,
098:                                true, true) {
099:                            public void ontTest(OntModel m) throws Exception {
100:                                Profile prof = m.getProfile();
101:                                OntProperty p = m.createOntProperty(NS + "p");
102:                                OntProperty q = m.createOntProperty(NS + "q");
103:                                OntProperty r = m.createOntProperty(NS + "r");
104:
105:                                p.addSubProperty(q);
106:                                assertEquals("Cardinality should be 1", 1, q
107:                                        .getCardinality(prof.SUB_PROPERTY_OF()));
108:                                assertEquals("p have sub-prop q", q, p
109:                                        .getSubProperty());
110:
111:                                p.addSubProperty(r);
112:                                assertEquals("Cardinality should be 2", 2, q
113:                                        .getCardinality(prof.SUB_PROPERTY_OF())
114:                                        + r.getCardinality(prof
115:                                                .SUB_PROPERTY_OF()));
116:                                iteratorTest(p.listSubProperties(),
117:                                        new Object[] { q, r });
118:                                iteratorTest(q.listSuperProperties(),
119:                                        new Object[] { p });
120:                                iteratorTest(r.listSuperProperties(),
121:                                        new Object[] { p });
122:
123:                                p.setSubProperty(r);
124:                                assertEquals("Cardinality should be 1", 1, q
125:                                        .getCardinality(prof.SUB_PROPERTY_OF())
126:                                        + r.getCardinality(prof
127:                                                .SUB_PROPERTY_OF()));
128:                                assertEquals("p should have sub-prop r", r, p
129:                                        .getSubProperty());
130:
131:                                p.removeSubProperty(q);
132:                                assertTrue("Should have sub-prop r", p
133:                                        .hasSubProperty(r, false));
134:                                p.removeSubProperty(r);
135:                                assertTrue("Should not have sub-prop r", !p
136:                                        .hasSubProperty(r, false));
137:                            }
138:                        },
139:                        new OntTestCase("OntProperty.domain", true, true, true,
140:                                true) {
141:                            public void ontTest(OntModel m) throws Exception {
142:                                Profile prof = m.getProfile();
143:                                OntProperty p = m.createOntProperty(NS + "p");
144:                                OntResource a = (OntResource) m.getResource(
145:                                        NS + "a").as(OntResource.class);
146:                                OntResource b = (OntResource) m.getResource(
147:                                        NS + "b").as(OntResource.class);
148:
149:                                p.addDomain(a);
150:                                assertEquals("Cardinality should be 1", 1, p
151:                                        .getCardinality(prof.DOMAIN()));
152:                                assertEquals("p have domain a", a, p
153:                                        .getDomain());
154:
155:                                p.addDomain(b);
156:                                assertEquals("Cardinality should be 2", 2, p
157:                                        .getCardinality(prof.DOMAIN()));
158:                                iteratorTest(p.listDomain(), new Object[] { a,
159:                                        b });
160:
161:                                p.setDomain(b);
162:                                assertEquals("Cardinality should be 1", 1, p
163:                                        .getCardinality(prof.DOMAIN()));
164:                                assertEquals("p should have domain b", b, p
165:                                        .getDomain());
166:
167:                                p.removeDomain(a);
168:                                assertEquals("Cardinality should be 1", 1, p
169:                                        .getCardinality(prof.DOMAIN()));
170:                                p.removeDomain(b);
171:                                assertEquals("Cardinality should be 0", 0, p
172:                                        .getCardinality(prof.DOMAIN()));
173:                            }
174:                        },
175:                        new OntTestCase("OntProperty.range", true, true, true,
176:                                true) {
177:                            public void ontTest(OntModel m) throws Exception {
178:                                Profile prof = m.getProfile();
179:                                OntProperty p = m.createOntProperty(NS + "p");
180:                                OntResource a = (OntResource) m.getResource(
181:                                        NS + "a").as(OntResource.class);
182:                                OntResource b = (OntResource) m.getResource(
183:                                        NS + "b").as(OntResource.class);
184:
185:                                p.addRange(a);
186:                                assertEquals("Cardinality should be 1", 1, p
187:                                        .getCardinality(prof.RANGE()));
188:                                assertEquals("p have range a", a, p.getRange());
189:
190:                                p.addRange(b);
191:                                assertEquals("Cardinality should be 2", 2, p
192:                                        .getCardinality(prof.RANGE()));
193:                                iteratorTest(p.listRange(),
194:                                        new Object[] { a, b });
195:
196:                                p.setRange(b);
197:                                assertEquals("Cardinality should be 1", 1, p
198:                                        .getCardinality(prof.RANGE()));
199:                                assertEquals("p should have range b", b, p
200:                                        .getRange());
201:
202:                                p.removeRange(a);
203:                                assertEquals("Cardinality should be 1", 1, p
204:                                        .getCardinality(prof.RANGE()));
205:                                p.removeRange(b);
206:                                assertEquals("Cardinality should be 0", 0, p
207:                                        .getCardinality(prof.RANGE()));
208:                            }
209:                        },
210:                        new OntTestCase("OntProperty.equivalentProperty", true,
211:                                true, true, false) {
212:                            public void ontTest(OntModel m) throws Exception {
213:                                Profile prof = m.getProfile();
214:                                OntProperty p = m
215:                                        .createObjectProperty(NS + "p");
216:                                OntProperty q = m
217:                                        .createObjectProperty(NS + "q");
218:                                OntProperty r = m
219:                                        .createObjectProperty(NS + "r");
220:
221:                                p.addEquivalentProperty(q);
222:                                assertEquals("Cardinality should be 1", 1, p
223:                                        .getCardinality(prof
224:                                                .EQUIVALENT_PROPERTY()));
225:                                assertEquals("p have equivalentProperty q", q,
226:                                        p.getEquivalentProperty());
227:
228:                                p.addEquivalentProperty(r);
229:                                assertEquals("Cardinality should be 2", 2, p
230:                                        .getCardinality(prof
231:                                                .EQUIVALENT_PROPERTY()));
232:                                iteratorTest(p.listEquivalentProperties(),
233:                                        new Object[] { q, r });
234:
235:                                p.setEquivalentProperty(r);
236:                                assertEquals("Cardinality should be 1", 1, p
237:                                        .getCardinality(prof
238:                                                .EQUIVALENT_PROPERTY()));
239:                                assertEquals(
240:                                        "p should have equivalentProperty r",
241:                                        r, p.getEquivalentProperty());
242:
243:                                p.removeEquivalentProperty(q);
244:                                assertEquals("Cardinality should be 1", 1, p
245:                                        .getCardinality(prof
246:                                                .EQUIVALENT_PROPERTY()));
247:                                p.removeEquivalentProperty(r);
248:                                assertEquals("Cardinality should be 0", 0, p
249:                                        .getCardinality(prof
250:                                                .EQUIVALENT_PROPERTY()));
251:                            }
252:                        },
253:                        new OntTestCase("OntProperty.inverseOf", true, true,
254:                                true, false) {
255:                            public void ontTest(OntModel m) throws Exception {
256:                                Profile prof = m.getProfile();
257:                                OntProperty p = m
258:                                        .createObjectProperty(NS + "p");
259:                                OntProperty q = m
260:                                        .createObjectProperty(NS + "q");
261:                                OntProperty r = m
262:                                        .createObjectProperty(NS + "r");
263:
264:                                p.addInverseOf(q);
265:                                assertEquals("Cardinality should be 1", 1, p
266:                                        .getCardinality(prof.INVERSE_OF()));
267:                                assertEquals("p should have inverse q", q, p
268:                                        .getInverseOf());
269:
270:                                p.addInverseOf(r);
271:                                assertEquals("Cardinality should be 2", 2, p
272:                                        .getCardinality(prof.INVERSE_OF()));
273:                                iteratorTest(p.listInverseOf(), new Object[] {
274:                                        q, r });
275:
276:                                p.setInverseOf(r);
277:                                assertEquals("Cardinality should be 1", 1, p
278:                                        .getCardinality(prof.INVERSE_OF()));
279:                                assertEquals("p should have inverse r", r, p
280:                                        .getInverseOf());
281:
282:                                p.removeInverseProperty(q);
283:                                assertEquals("Cardinality should be 1", 1, p
284:                                        .getCardinality(prof.INVERSE_OF()));
285:                                p.removeInverseProperty(r);
286:                                assertEquals("Cardinality should be 0", 0, p
287:                                        .getCardinality(prof.INVERSE_OF()));
288:                            }
289:                        },
290:                        new OntTestCase("OntProperty.subproperty.fromFile",
291:                                true, true, true, true) {
292:                            public void ontTest(OntModel m) throws Exception {
293:                                String lang = m_owlLang ? "owl"
294:                                        : (m_damlLang ? "daml" : "rdfs");
295:                                String fileName = "file:testing/ontology/"
296:                                        + lang + "/Property/test.rdf";
297:                                m.read(fileName);
298:
299:                                OntProperty p = (OntProperty) m.getProperty(NS,
300:                                        "p").as(OntProperty.class);
301:                                OntProperty q = (OntProperty) m.getProperty(NS,
302:                                        "q").as(OntProperty.class);
303:
304:                                iteratorTest(p.listSuperProperties(),
305:                                        new Object[] { q });
306:                                iteratorTest(q.listSubProperties(),
307:                                        new Object[] { p });
308:                            }
309:                        },
310:                        new OntTestCase("OntProperty.domain.fromFile", true,
311:                                true, true, true) {
312:                            public void ontTest(OntModel m) throws Exception {
313:                                String lang = m_owlLang ? "owl"
314:                                        : (m_damlLang ? "daml" : "rdfs");
315:                                String fileName = "file:testing/ontology/"
316:                                        + lang + "/Property/test.rdf";
317:                                m.read(fileName);
318:
319:                                OntProperty p = (OntProperty) m.getProperty(NS,
320:                                        "p").as(OntProperty.class);
321:                                OntClass A = (OntClass) m.getResource(
322:                                        NS + "ClassA").as(OntClass.class);
323:
324:                                assertTrue("p should have domain A", p
325:                                        .hasDomain(A));
326:                            }
327:                        },
328:                        new OntTestCase("OntProperty.range.fromFile", true,
329:                                true, true, true) {
330:                            public void ontTest(OntModel m) throws Exception {
331:                                String lang = m_owlLang ? "owl"
332:                                        : (m_damlLang ? "daml" : "rdfs");
333:                                String fileName = "file:testing/ontology/"
334:                                        + lang + "/Property/test.rdf";
335:                                m.read(fileName);
336:
337:                                OntProperty p = (OntProperty) m.getProperty(NS,
338:                                        "p").as(OntProperty.class);
339:                                OntClass B = (OntClass) m.getResource(
340:                                        NS + "ClassB").as(OntClass.class);
341:
342:                                assertTrue("p should have domain B", p
343:                                        .hasRange(B));
344:                            }
345:                        },
346:                        new OntTestCase(
347:                                "OntProperty.equivalentProeprty.fromFile",
348:                                true, true, true, false) {
349:                            public void ontTest(OntModel m) throws Exception {
350:                                String lang = m_owlLang ? "owl"
351:                                        : (m_damlLang ? "daml" : "rdfs");
352:                                String fileName = "file:testing/ontology/"
353:                                        + lang + "/Property/test.rdf";
354:                                m.read(fileName);
355:
356:                                OntProperty p = (OntProperty) m.getProperty(NS,
357:                                        "p").as(OntProperty.class);
358:                                OntProperty r = (OntProperty) m.getProperty(NS,
359:                                        "r").as(OntProperty.class);
360:
361:                                assertTrue("p should have equiv prop r", p
362:                                        .hasEquivalentProperty(r));
363:                            }
364:                        },
365:                        new OntTestCase(
366:                                "OntProperty.inversePropertyOf.fromFile", true,
367:                                true, true, false) {
368:                            public void ontTest(OntModel m) throws Exception {
369:                                String lang = m_owlLang ? "owl"
370:                                        : (m_damlLang ? "daml" : "rdfs");
371:                                String fileName = "file:testing/ontology/"
372:                                        + lang + "/Property/test.rdf";
373:                                m.read(fileName);
374:
375:                                OntProperty p = (OntProperty) m.getProperty(NS,
376:                                        "p").as(OntProperty.class);
377:                                OntProperty s = (OntProperty) m.getProperty(NS,
378:                                        "s").as(OntProperty.class);
379:
380:                                assertTrue("p should have inv prop s", p
381:                                        .isInverseOf(s));
382:                            }
383:                        },
384:
385:                        // type tests
386:                        new OntTestCase("OntProperty.isFunctionalProperty dt",
387:                                true, true, true, false) {
388:                            public void ontTest(OntModel m) throws Exception {
389:                                OntProperty p = m.createDatatypeProperty(NS
390:                                        + "p", true);
391:
392:                                assertTrue("isFunctionalProperty not correct",
393:                                        p.isFunctionalProperty());
394:                                assertTrue("isDatatypeProperty not correct", p
395:                                        .isDatatypeProperty());
396:                                assertTrue("isObjectProperty not correct", !p
397:                                        .isObjectProperty());
398:                                assertTrue("isTransitiveProperty not correct",
399:                                        !p.isTransitiveProperty());
400:                                assertTrue(
401:                                        "isInverseFunctionalProperty not correct",
402:                                        !p.isInverseFunctionalProperty());
403:                                if (m_owlLang) {
404:                                    assertTrue(
405:                                            "isSymmetricProperty not correct",
406:                                            !p.isSymmetricProperty());
407:                                }
408:                            }
409:                        },
410:                        new OntTestCase(
411:                                "OntProperty.isFunctionalProperty object",
412:                                true, true, true, false) {
413:                            public void ontTest(OntModel m) throws Exception {
414:                                OntProperty p = m.createObjectProperty(
415:                                        NS + "p", true);
416:
417:                                assertTrue("isFunctionalProperty not correct",
418:                                        p.isFunctionalProperty());
419:                                assertTrue("isDatatypeProperty not correct", !p
420:                                        .isDatatypeProperty());
421:                                assertTrue("isObjectProperty not correct", p
422:                                        .isObjectProperty());
423:                                assertTrue("isTransitiveProperty not correct",
424:                                        !p.isTransitiveProperty());
425:                                assertTrue(
426:                                        "isInverseFunctionalProperty not correct",
427:                                        !p.isInverseFunctionalProperty());
428:                                if (m_owlLang) {
429:                                    assertTrue(
430:                                            "isSymmetricProperty not correct",
431:                                            !p.isSymmetricProperty());
432:                                }
433:                            }
434:                        },
435:                        new OntTestCase("OntProperty.isDatatypeProperty", true,
436:                                true, true, false) {
437:                            public void ontTest(OntModel m) throws Exception {
438:                                OntProperty p = m.createDatatypeProperty(NS
439:                                        + "p", false);
440:
441:                                assertTrue("isFunctionalProperty not correct",
442:                                        !p.isFunctionalProperty());
443:                                assertTrue("isDatatypeProperty not correct", p
444:                                        .isDatatypeProperty());
445:                                assertTrue("isObjectProperty not correct", !p
446:                                        .isObjectProperty());
447:                                assertTrue("isTransitiveProperty not correct",
448:                                        !p.isTransitiveProperty());
449:                                assertTrue(
450:                                        "isInverseFunctionalProperty not correct",
451:                                        !p.isInverseFunctionalProperty());
452:                                if (m_owlLang) {
453:                                    assertTrue(
454:                                            "isSymmetricProperty not correct",
455:                                            !p.isSymmetricProperty());
456:                                }
457:                            }
458:                        },
459:                        new OntTestCase("OntProperty.isObjectProperty", true,
460:                                true, true, false) {
461:                            public void ontTest(OntModel m) throws Exception {
462:                                OntProperty p = m.createObjectProperty(
463:                                        NS + "p", false);
464:
465:                                assertTrue("isFunctionalProperty not correct",
466:                                        !p.isFunctionalProperty());
467:                                assertTrue("isDatatypeProperty not correct", !p
468:                                        .isDatatypeProperty());
469:                                assertTrue("isObjectProperty not correct", p
470:                                        .isObjectProperty());
471:                                assertTrue("isTransitiveProperty not correct",
472:                                        !p.isTransitiveProperty());
473:                                assertTrue(
474:                                        "isInverseFunctionalProperty not correct",
475:                                        !p.isInverseFunctionalProperty());
476:                                if (m_owlLang) {
477:                                    assertTrue(
478:                                            "isSymmetricProperty not correct",
479:                                            !p.isSymmetricProperty());
480:                                }
481:                            }
482:                        },
483:                        new OntTestCase("OntProperty.isTransitiveProperty",
484:                                true, true, true, false) {
485:                            public void ontTest(OntModel m) throws Exception {
486:                                OntProperty p = m.createTransitiveProperty(NS
487:                                        + "p");
488:
489:                                assertTrue("isFunctionalProperty not correct",
490:                                        !p.isFunctionalProperty());
491:                                assertTrue("isDatatypeProperty not correct", !p
492:                                        .isDatatypeProperty());
493:                                assertTrue("isObjectProperty not correct", !p
494:                                        .isObjectProperty()); // this should be true by entailment, but we have reasoning switched off
495:                                assertTrue("isTransitiveProperty not correct",
496:                                        p.isTransitiveProperty());
497:                                assertTrue(
498:                                        "isInverseFunctionalProperty not correct",
499:                                        !p.isInverseFunctionalProperty());
500:                                if (m_owlLang) {
501:                                    assertTrue(
502:                                            "isSymmetricProperty not correct",
503:                                            !p.isSymmetricProperty());
504:                                }
505:                            }
506:                        },
507:                        new OntTestCase(
508:                                "OntProperty.isInverseFunctionalProperty",
509:                                true, true, true, false) {
510:                            public void ontTest(OntModel m) throws Exception {
511:                                OntProperty p = m
512:                                        .createInverseFunctionalProperty(NS
513:                                                + "p");
514:
515:                                assertTrue("isFunctionalProperty not correct",
516:                                        !p.isFunctionalProperty());
517:                                assertTrue("isDatatypeProperty not correct", !p
518:                                        .isDatatypeProperty());
519:                                assertTrue("isObjectProperty not correct", !p
520:                                        .isObjectProperty()); // this should be true by entailment, but we have reasoning switched off
521:                                assertTrue("isTransitiveProperty not correct",
522:                                        !p.isTransitiveProperty());
523:                                assertTrue(
524:                                        "isInverseFunctionalProperty not correct",
525:                                        p.isInverseFunctionalProperty());
526:                                if (m_owlLang) {
527:                                    assertTrue(
528:                                            "isSymmetricProperty not correct",
529:                                            !p.isSymmetricProperty());
530:                                }
531:                            }
532:                        },
533:                        new OntTestCase("OntProperty.isSymmetricProperty",
534:                                true, true, false, false) {
535:                            public void ontTest(OntModel m) throws Exception {
536:                                OntProperty p = m.createSymmetricProperty(NS
537:                                        + "p");
538:
539:                                assertTrue("isFunctionalProperty not correct",
540:                                        !p.isFunctionalProperty());
541:                                assertTrue("isDatatypeProperty not correct", !p
542:                                        .isDatatypeProperty());
543:                                assertTrue("isObjectProperty not correct", !p
544:                                        .isObjectProperty()); // this should be true by entailment, but we have reasoning switched off
545:                                assertTrue("isTransitiveProperty not correct",
546:                                        !p.isTransitiveProperty());
547:                                assertTrue(
548:                                        "isInverseFunctionalProperty not correct",
549:                                        !p.isInverseFunctionalProperty());
550:                                if (m_owlLang) {
551:                                    assertTrue(
552:                                            "isSymmetricProperty not correct",
553:                                            p.isSymmetricProperty());
554:                                }
555:                            }
556:                        },
557:                        new OntTestCase(
558:                                "OntProperty.convertToFunctionalProperty",
559:                                true, true, true, false) {
560:                            public void ontTest(OntModel m) throws Exception {
561:                                Property pSimple = m.createProperty(NS, "p");
562:                                pSimple.addProperty(RDF.type, RDF.Property);
563:                                OntProperty p = (OntProperty) pSimple
564:                                        .as(OntProperty.class);
565:
566:                                assertTrue("isFunctionalProperty not correct",
567:                                        !p.isFunctionalProperty());
568:                                assertTrue("isDatatypeProperty not correct", !p
569:                                        .isDatatypeProperty());
570:                                assertTrue("isObjectProperty not correct", !p
571:                                        .isObjectProperty());
572:                                assertTrue("isTransitiveProperty not correct",
573:                                        !p.isTransitiveProperty());
574:                                assertTrue(
575:                                        "isInverseFunctionalProperty not correct",
576:                                        !p.isInverseFunctionalProperty());
577:                                if (m_owlLang) {
578:                                    assertTrue(
579:                                            "isSymmetricProperty not correct",
580:                                            !p.isSymmetricProperty());
581:                                }
582:
583:                                p = p.convertToFunctionalProperty();
584:
585:                                assertTrue("isFunctionalProperty not correct",
586:                                        p.isFunctionalProperty());
587:                                assertTrue("isDatatypeProperty not correct", !p
588:                                        .isDatatypeProperty());
589:                                assertTrue("isObjectProperty not correct", !p
590:                                        .isObjectProperty());
591:                                assertTrue("isTransitiveProperty not correct",
592:                                        !p.isTransitiveProperty());
593:                                assertTrue(
594:                                        "isInverseFunctionalProperty not correct",
595:                                        !p.isInverseFunctionalProperty());
596:                                if (m_owlLang) {
597:                                    assertTrue(
598:                                            "isSymmetricProperty not correct",
599:                                            !p.isSymmetricProperty());
600:                                }
601:                            }
602:                        },
603:                        new OntTestCase(
604:                                "OntProperty.convertToDatatypeProperty", true,
605:                                true, true, false) {
606:                            public void ontTest(OntModel m) throws Exception {
607:                                Property pSimple = m.createProperty(NS, "p");
608:                                pSimple.addProperty(RDF.type, RDF.Property);
609:                                OntProperty p = (OntProperty) pSimple
610:                                        .as(OntProperty.class);
611:
612:                                assertTrue("isFunctionalProperty not correct",
613:                                        !p.isFunctionalProperty());
614:                                assertTrue("isDatatypeProperty not correct", !p
615:                                        .isDatatypeProperty());
616:                                assertTrue("isObjectProperty not correct", !p
617:                                        .isObjectProperty());
618:                                assertTrue("isTransitiveProperty not correct",
619:                                        !p.isTransitiveProperty());
620:                                assertTrue(
621:                                        "isInverseFunctionalProperty not correct",
622:                                        !p.isInverseFunctionalProperty());
623:                                if (m_owlLang) {
624:                                    assertTrue(
625:                                            "isSymmetricProperty not correct",
626:                                            !p.isSymmetricProperty());
627:                                }
628:
629:                                p = p.convertToDatatypeProperty();
630:
631:                                assertTrue("isFunctionalProperty not correct",
632:                                        !p.isFunctionalProperty());
633:                                assertTrue("isDatatypeProperty not correct", p
634:                                        .isDatatypeProperty());
635:                                assertTrue("isObjectProperty not correct", !p
636:                                        .isObjectProperty());
637:                                assertTrue("isTransitiveProperty not correct",
638:                                        !p.isTransitiveProperty());
639:                                assertTrue(
640:                                        "isInverseFunctionalProperty not correct",
641:                                        !p.isInverseFunctionalProperty());
642:                                if (m_owlLang) {
643:                                    assertTrue(
644:                                            "isSymmetricProperty not correct",
645:                                            !p.isSymmetricProperty());
646:                                }
647:                            }
648:                        },
649:                        new OntTestCase("OntProperty.convertToObjectProperty",
650:                                true, true, true, false) {
651:                            public void ontTest(OntModel m) throws Exception {
652:                                Property pSimple = m.createProperty(NS, "p");
653:                                pSimple.addProperty(RDF.type, RDF.Property);
654:                                OntProperty p = (OntProperty) pSimple
655:                                        .as(OntProperty.class);
656:
657:                                assertTrue("isFunctionalProperty not correct",
658:                                        !p.isFunctionalProperty());
659:                                assertTrue("isDatatypeProperty not correct", !p
660:                                        .isDatatypeProperty());
661:                                assertTrue("isObjectProperty not correct", !p
662:                                        .isObjectProperty());
663:                                assertTrue("isTransitiveProperty not correct",
664:                                        !p.isTransitiveProperty());
665:                                assertTrue(
666:                                        "isInverseFunctionalProperty not correct",
667:                                        !p.isInverseFunctionalProperty());
668:                                if (m_owlLang) {
669:                                    assertTrue(
670:                                            "isSymmetricProperty not correct",
671:                                            !p.isSymmetricProperty());
672:                                }
673:
674:                                p = p.convertToObjectProperty();
675:
676:                                assertTrue("isFunctionalProperty not correct",
677:                                        !p.isFunctionalProperty());
678:                                assertTrue("isDatatypeProperty not correct", !p
679:                                        .isDatatypeProperty());
680:                                assertTrue("isObjectProperty not correct", p
681:                                        .isObjectProperty());
682:                                assertTrue("isTransitiveProperty not correct",
683:                                        !p.isTransitiveProperty());
684:                                assertTrue(
685:                                        "isInverseFunctionalProperty not correct",
686:                                        !p.isInverseFunctionalProperty());
687:                                if (m_owlLang) {
688:                                    assertTrue(
689:                                            "isSymmetricProperty not correct",
690:                                            !p.isSymmetricProperty());
691:                                }
692:                            }
693:                        },
694:                        new OntTestCase(
695:                                "OntProperty.convertToTransitiveProperty",
696:                                true, true, true, false) {
697:                            public void ontTest(OntModel m) throws Exception {
698:                                Property pSimple = m.createProperty(NS, "p");
699:                                pSimple.addProperty(RDF.type, RDF.Property);
700:                                OntProperty p = (OntProperty) pSimple
701:                                        .as(OntProperty.class);
702:
703:                                assertTrue("isFunctionalProperty not correct",
704:                                        !p.isFunctionalProperty());
705:                                assertTrue("isDatatypeProperty not correct", !p
706:                                        .isDatatypeProperty());
707:                                assertTrue("isObjectProperty not correct", !p
708:                                        .isObjectProperty());
709:                                assertTrue("isTransitiveProperty not correct",
710:                                        !p.isTransitiveProperty());
711:                                assertTrue(
712:                                        "isInverseFunctionalProperty not correct",
713:                                        !p.isInverseFunctionalProperty());
714:                                if (m_owlLang) {
715:                                    assertTrue(
716:                                            "isSymmetricProperty not correct",
717:                                            !p.isSymmetricProperty());
718:                                }
719:
720:                                p = p.convertToTransitiveProperty();
721:
722:                                assertTrue("isFunctionalProperty not correct",
723:                                        !p.isFunctionalProperty());
724:                                assertTrue("isDatatypeProperty not correct", !p
725:                                        .isDatatypeProperty());
726:                                assertTrue("isObjectProperty not correct", !p
727:                                        .isObjectProperty());
728:                                assertTrue("isTransitiveProperty not correct",
729:                                        p.isTransitiveProperty());
730:                                assertTrue(
731:                                        "isInverseFunctionalProperty not correct",
732:                                        !p.isInverseFunctionalProperty());
733:                                if (m_owlLang) {
734:                                    assertTrue(
735:                                            "isSymmetricProperty not correct",
736:                                            !p.isSymmetricProperty());
737:                                }
738:                            }
739:                        },
740:                        new OntTestCase(
741:                                "OntProperty.convertToInverseFunctionalProperty",
742:                                true, true, true, false) {
743:                            public void ontTest(OntModel m) throws Exception {
744:                                Property pSimple = m.createProperty(NS, "p");
745:                                pSimple.addProperty(RDF.type, RDF.Property);
746:                                OntProperty p = (OntProperty) pSimple
747:                                        .as(OntProperty.class);
748:
749:                                assertTrue("isFunctionalProperty not correct",
750:                                        !p.isFunctionalProperty());
751:                                assertTrue("isDatatypeProperty not correct", !p
752:                                        .isDatatypeProperty());
753:                                assertTrue("isObjectProperty not correct", !p
754:                                        .isObjectProperty());
755:                                assertTrue("isTransitiveProperty not correct",
756:                                        !p.isTransitiveProperty());
757:                                assertTrue(
758:                                        "isInverseFunctionalProperty not correct",
759:                                        !p.isInverseFunctionalProperty());
760:                                if (m_owlLang) {
761:                                    assertTrue(
762:                                            "isSymmetricProperty not correct",
763:                                            !p.isSymmetricProperty());
764:                                }
765:
766:                                p = p.convertToInverseFunctionalProperty();
767:
768:                                assertTrue("isFunctionalProperty not correct",
769:                                        !p.isFunctionalProperty());
770:                                assertTrue("isDatatypeProperty not correct", !p
771:                                        .isDatatypeProperty());
772:                                assertTrue("isObjectProperty not correct", !p
773:                                        .isObjectProperty());
774:                                assertTrue("isTransitiveProperty not correct",
775:                                        !p.isTransitiveProperty());
776:                                assertTrue(
777:                                        "isInverseFunctionalProperty not correct",
778:                                        p.isInverseFunctionalProperty());
779:                                if (m_owlLang) {
780:                                    assertTrue(
781:                                            "isSymmetricProperty not correct",
782:                                            !p.isSymmetricProperty());
783:                                }
784:                            }
785:                        },
786:                        new OntTestCase(
787:                                "OntProperty.convertToSymmetricProperty", true,
788:                                true, false, false) {
789:                            public void ontTest(OntModel m) throws Exception {
790:                                Property pSimple = m.createProperty(NS, "p");
791:                                pSimple.addProperty(RDF.type, RDF.Property);
792:                                OntProperty p = (OntProperty) pSimple
793:                                        .as(OntProperty.class);
794:
795:                                assertTrue("isFunctionalProperty not correct",
796:                                        !p.isFunctionalProperty());
797:                                assertTrue("isDatatypeProperty not correct", !p
798:                                        .isDatatypeProperty());
799:                                assertTrue("isObjectProperty not correct", !p
800:                                        .isObjectProperty());
801:                                assertTrue("isTransitiveProperty not correct",
802:                                        !p.isTransitiveProperty());
803:                                assertTrue(
804:                                        "isInverseFunctionalProperty not correct",
805:                                        !p.isInverseFunctionalProperty());
806:                                if (m_owlLang) {
807:                                    assertTrue(
808:                                            "isSymmetricProperty not correct",
809:                                            !p.isSymmetricProperty());
810:                                }
811:
812:                                p = p.convertToSymmetricProperty();
813:
814:                                assertTrue("isFunctionalProperty not correct",
815:                                        !p.isFunctionalProperty());
816:                                assertTrue("isDatatypeProperty not correct", !p
817:                                        .isDatatypeProperty());
818:                                assertTrue("isObjectProperty not correct", !p
819:                                        .isObjectProperty());
820:                                assertTrue("isTransitiveProperty not correct",
821:                                        !p.isTransitiveProperty());
822:                                assertTrue(
823:                                        "isInverseFunctionalProperty not correct",
824:                                        !p.isInverseFunctionalProperty());
825:                                if (m_owlLang) {
826:                                    assertTrue(
827:                                            "isSymmetricProperty not correct",
828:                                            p.isSymmetricProperty());
829:                                }
830:                            }
831:                        },
832:                        new OntTestCase("OntProperty.inverse", true, true,
833:                                true, false) {
834:                            public void ontTest(OntModel m) throws Exception {
835:                                ObjectProperty p = m.createObjectProperty(NS
836:                                        + "p");
837:                                ObjectProperty q = m.createObjectProperty(NS
838:                                        + "q");
839:                                ObjectProperty r = m.createObjectProperty(NS
840:                                        + "r");
841:
842:                                assertFalse("No inverse of p", p.hasInverse());
843:
844:                                q.addInverseOf(p);
845:                                assertTrue("Inverse of p", p.hasInverse());
846:                                assertEquals("inverse of p ", q, p.getInverse());
847:
848:                                r.addInverseOf(p);
849:                                iteratorTest(p.listInverse(), new Object[] { q,
850:                                        r });
851:                            }
852:                        },
853:                        new OntTestCase(
854:                                "OntProperty.listReferringRestrictions", true,
855:                                true, true, false) {
856:                            protected void ontTest(OntModel m) throws Exception {
857:                                ObjectProperty p = m.createObjectProperty(NS
858:                                        + "p");
859:                                ObjectProperty q = m.createObjectProperty(NS
860:                                        + "q");
861:                                Restriction r0 = m
862:                                        .createCardinalityRestriction(null, p,
863:                                                2);
864:                                Restriction r1 = m
865:                                        .createCardinalityRestriction(null, p,
866:                                                3);
867:                                Restriction r2 = m
868:                                        .createCardinalityRestriction(null, q,
869:                                                2);
870:                                Restriction r3 = m
871:                                        .createCardinalityRestriction(null, q,
872:                                                3);
873:
874:                                assertTrue(iteratorContains(p
875:                                        .listReferringRestrictions(), r0));
876:                                assertTrue(iteratorContains(p
877:                                        .listReferringRestrictions(), r1));
878:                                assertFalse(iteratorContains(p
879:                                        .listReferringRestrictions(), r2));
880:                                assertFalse(iteratorContains(p
881:                                        .listReferringRestrictions(), r3));
882:
883:                                assertTrue(p.listReferringRestrictions().next() instanceof  Restriction);
884:                            }
885:                        } };
886:            }
887:
888:            // Internal implementation methods
889:            //////////////////////////////////
890:
891:            //==============================================================================
892:            // Inner class definitions
893:            //==============================================================================
894:
895:        }
896:
897:        /*
898:         (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
899:         All rights reserved.
900:
901:         Redistribution and use in source and binary forms, with or without
902:         modification, are permitted provided that the following conditions
903:         are met:
904:
905:         1. Redistributions of source code must retain the above copyright
906:         notice, this list of conditions and the following disclaimer.
907:
908:         2. Redistributions in binary form must reproduce the above copyright
909:         notice, this list of conditions and the following disclaimer in the
910:         documentation and/or other materials provided with the distribution.
911:
912:         3. The name of the author may not be used to endorse or promote products
913:         derived from this software without specific prior written permission.
914:
915:         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
916:         IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
917:         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
918:         IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
919:         INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
920:         NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
921:         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
922:         THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
923:         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
924:         THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
925:         */
w__w___w___.j___av__a2__s_.co_m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.