Source Code Cross Referenced for TestIndividual.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            23-May-2003
009:         * Filename           $RCSfile: TestIndividual.java,v $
010:         * Revision           $Revision: 1.11 $
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 java.util.Iterator;
023:
024:        import junit.framework.TestSuite;
025:
026:        import com.hp.hpl.jena.ontology.*;
027:
028:        /**
029:         * <p>
030:         * Unit tests for ontology individuals
031:         * </p>
032:         *
033:         * @author Ian Dickinson, HP Labs
034:         *         (<a  href="mailto:Ian.Dickinson@hp.com" >email</a>)
035:         * @version CVS $Id: TestIndividual.java,v 1.11 2008/01/02 12:08:41 andy_seaborne Exp $
036:         */
037:        public class TestIndividual 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 TestIndividual("TestIndividual");
052:            }
053:
054:            public TestIndividual(String name) {
055:                super (name);
056:            }
057:
058:            // External signature methods
059:            //////////////////////////////////
060:
061:            public OntTestCase[] getTests() {
062:                return new OntTestCase[] {
063:                        new OntTestCase("Individual.sameAs", true, false, true,
064:                                false) {
065:                            /** Note: 6/Nov/2003 - updated to use sameAs not sameIndividualAs, following changes to OWL spec */
066:                            public void ontTest(OntModel m) throws Exception {
067:                                Profile prof = m.getProfile();
068:                                OntClass A = m.createClass(NS + "A");
069:                                Individual x = m.createIndividual(A);
070:                                Individual y = m.createIndividual(A);
071:                                Individual z = m.createIndividual(A);
072:
073:                                x.addSameAs(y);
074:                                assertEquals("Cardinality should be 1", 1, x
075:                                        .getCardinality(prof.SAME_AS()));
076:                                assertEquals("x should be the same as y", y, x
077:                                        .getSameAs());
078:                                assertTrue("x should be the same as y", x
079:                                        .isSameAs(y));
080:
081:                                x.addSameAs(z);
082:                                assertEquals("Cardinality should be 2", 2, x
083:                                        .getCardinality(prof.SAME_AS()));
084:                                iteratorTest(x.listSameAs(), new Object[] { z,
085:                                        y });
086:
087:                                x.setSameAs(z);
088:                                assertEquals("Cardinality should be 1", 1, x
089:                                        .getCardinality(prof.SAME_AS()));
090:                                assertEquals("x should be same indiv. as z", z,
091:                                        x.getSameAs());
092:
093:                                x.removeSameAs(y);
094:                                assertEquals("Cardinality should be 1", 1, x
095:                                        .getCardinality(prof.SAME_AS()));
096:                                x.removeSameAs(z);
097:                                assertEquals("Cardinality should be 0", 0, x
098:                                        .getCardinality(prof.SAME_AS()));
099:                            }
100:                        },
101:
102:                        new OntTestCase("Individual.hasOntClass", true, true,
103:                                true, true) {
104:                            protected void ontTest(OntModel m) throws Exception {
105:                                OntClass A = m.createClass(NS + "A");
106:                                OntClass B = m.createClass(NS + "B");
107:                                Individual x = m.createIndividual(A);
108:
109:                                assertTrue(x.hasOntClass(A));
110:                                assertFalse(x.hasOntClass(B));
111:                            }
112:                        },
113:
114:                        new OntTestCase("Individual.hasOntClass direct", true,
115:                                true, true, true) {
116:                            protected void ontTest(OntModel m) throws Exception {
117:                                OntClass A = m.createClass(NS + "A");
118:                                OntClass B = m.createClass(NS + "B");
119:                                A.addSubClass(B);
120:
121:                                Individual x = m.createIndividual(A);
122:                                x.addRDFType(B);
123:
124:                                assertTrue(x.hasOntClass(A, false));
125:                                assertTrue(x.hasOntClass(B, false));
126:
127:                                assertTrue(x.hasOntClass(A, false));
128:                                assertTrue(x.hasOntClass(B, true));
129:
130:                            }
131:                        },
132:
133:                        new OntTestCase("Individual.hasOntClass string", true,
134:                                true, true, true) {
135:                            protected void ontTest(OntModel m) throws Exception {
136:                                OntClass A = m.createClass(NS + "A");
137:
138:                                Individual x = m.createIndividual(A);
139:
140:                                assertTrue(x.hasOntClass(NS + "A"));
141:                            }
142:                        },
143:
144:                        new OntTestCase("Individual.getOntClass", true, true,
145:                                true, true) {
146:                            protected void ontTest(OntModel m) throws Exception {
147:                                OntClass A = m.createClass(NS + "A");
148:                                Individual x = m.createIndividual(A);
149:
150:                                assertEquals(A, x.getOntClass());
151:                            }
152:                        },
153:
154:                        new OntTestCase("Individual.getOntClass direct", true,
155:                                true, true, true) {
156:                            protected void ontTest(OntModel m) throws Exception {
157:                                OntClass A = m.createClass(NS + "A");
158:                                OntClass B = m.createClass(NS + "B");
159:                                A.addSubClass(B);
160:
161:                                Individual x = m.createIndividual(A);
162:                                x.addRDFType(B);
163:
164:                                // should never get A since it's not a direct class
165:                                assertEquals(B, x.getOntClass(true));
166:                            }
167:                        },
168:
169:                        new OntTestCase("Individual.listOntClasses", true,
170:                                true, true, true) {
171:                            protected void ontTest(OntModel m) throws Exception {
172:                                OntClass A = m.createClass(NS + "A");
173:                                OntClass B = m.createClass(NS + "B");
174:                                A.addSubClass(B);
175:
176:                                Individual x = m.createIndividual(A);
177:                                x.addRDFType(B);
178:
179:                                iteratorTest(x.listOntClasses(false),
180:                                        new Object[] { A, B });
181:
182:                                // now check the return types
183:                                for (Iterator i = x.listOntClasses(false); i
184:                                        .hasNext();) {
185:                                    assertTrue(i.next() instanceof  OntClass);
186:                                }
187:                            }
188:                        },
189:
190:                        new OntTestCase("Individual.listOntClasses direct",
191:                                true, true, true, true) {
192:                            protected void ontTest(OntModel m) throws Exception {
193:                                OntClass A = m.createClass(NS + "A");
194:                                OntClass B = m.createClass(NS + "B");
195:                                A.addSubClass(B);
196:
197:                                Individual x = m.createIndividual(A);
198:                                x.addRDFType(B);
199:
200:                                iteratorTest(x.listOntClasses(true),
201:                                        new Object[] { B });
202:
203:                                // now check the return types
204:                                for (Iterator i = x.listOntClasses(true); i
205:                                        .hasNext();) {
206:                                    assertTrue(i.next() instanceof  OntClass);
207:                                }
208:                            }
209:                        },
210:
211:                        new OntTestCase("Individual.addOntClass", true, true,
212:                                true, true) {
213:                            protected void ontTest(OntModel m) throws Exception {
214:                                OntClass A = m.createClass(NS + "A");
215:                                OntClass B = m.createClass(NS + "B");
216:                                A.addSubClass(B);
217:
218:                                Individual x = m.createIndividual(A);
219:
220:                                iteratorTest(x.listOntClasses(false),
221:                                        new Object[] { A });
222:
223:                                // add a class
224:                                x.addOntClass(B);
225:
226:                                // test again
227:                                iteratorTest(x.listOntClasses(false),
228:                                        new Object[] { A, B });
229:                                for (Iterator i = x.listOntClasses(false); i
230:                                        .hasNext();) {
231:                                    assertTrue(i.next() instanceof  OntClass);
232:                                }
233:                            }
234:                        },
235:
236:                        new OntTestCase("Individual.setOntClass", true, true,
237:                                true, true) {
238:                            protected void ontTest(OntModel m) throws Exception {
239:                                OntClass A = m.createClass(NS + "A");
240:                                OntClass B = m.createClass(NS + "B");
241:                                A.addSubClass(B);
242:
243:                                Individual x = m.createIndividual(A);
244:
245:                                iteratorTest(x.listOntClasses(false),
246:                                        new Object[] { A });
247:
248:                                // replace the class
249:                                x.setOntClass(B);
250:
251:                                // test again
252:                                iteratorTest(x.listOntClasses(false),
253:                                        new Object[] { B });
254:                                for (Iterator i = x.listOntClasses(false); i
255:                                        .hasNext();) {
256:                                    assertTrue(i.next() instanceof  OntClass);
257:                                }
258:                            }
259:                        },
260:
261:                        new OntTestCase("Individual.removeOntClass", true,
262:                                true, true, true) {
263:                            protected void ontTest(OntModel m) throws Exception {
264:                                OntClass A = m.createClass(NS + "A");
265:                                OntClass B = m.createClass(NS + "B");
266:
267:                                Individual x = m.createIndividual(A);
268:                                x.addOntClass(B);
269:
270:                                iteratorTest(x.listOntClasses(false),
271:                                        new Object[] { A, B });
272:
273:                                x.removeOntClass(A);
274:                                iteratorTest(x.listOntClasses(false),
275:                                        new Object[] { B });
276:
277:                                x.removeOntClass(A);
278:                                iteratorTest(x.listOntClasses(false),
279:                                        new Object[] { B });
280:
281:                                x.removeOntClass(B);
282:                                iteratorTest(x.listOntClasses(false),
283:                                        new Object[] {});
284:                            }
285:                        }, };
286:            }
287:
288:            // Internal implementation methods
289:            //////////////////////////////////
290:
291:            //==============================================================================
292:            // Inner class definitions
293:            //==============================================================================
294:
295:        }
296:
297:        /*
298:         (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
299:         All rights reserved.
300:
301:         Redistribution and use in source and binary forms, with or without
302:         modification, are permitted provided that the following conditions
303:         are met:
304:
305:         1. Redistributions of source code must retain the above copyright
306:         notice, this list of conditions and the following disclaimer.
307:
308:         2. Redistributions in binary form must reproduce the above copyright
309:         notice, this list of conditions and the following disclaimer in the
310:         documentation and/or other materials provided with the distribution.
311:
312:         3. The name of the author may not be used to endorse or promote products
313:         derived from this software without specific prior written permission.
314:
315:         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
316:         IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
317:         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
318:         IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
319:         INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
320:         NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
321:         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
322:         THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
323:         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
324:         THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
325:         */
www_.j_a_va_2___s._c__o__m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.