Source Code Cross Referenced for RDFClauseSetIEIntegrationTestCase.java in  » Rule-Engine » Mandarax » test » org » mandarax » rdf » 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 » Rule Engine » Mandarax » test.org.mandarax.rdf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 1999-2004 <a href="mailto:mandarax@jbdietrich.com">Jens
003:         * Dietrich </a>
004:         * 
005:         * This library is free software; you can redistribute it and/or modify it under
006:         * the terms of the GNU Lesser General Public License as published by the Free
007:         * Software Foundation; either version 2 of the License, or (at your option) any
008:         * later version.
009:         * 
010:         * This library is distributed in the hope that it will be useful, but WITHOUT
011:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
012:         * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
013:         * details.
014:         * 
015:         * You should have received a copy of the GNU Lesser General Public License
016:         * along with this library; if not, write to the Free Software Foundation, Inc.,
017:         * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018:         */
019:        package test.org.mandarax.rdf;
020:
021:        import java.net.URL;
022:        import org.mandarax.kernel.*;
023:        import org.mandarax.rdf.RDFClauseSet;
024:        import org.mandarax.rdf.RDFUtils;
025:        import org.mandarax.reference.AdvancedKnowledgeBase;
026:        import org.mandarax.reference.ResolutionInferenceEngine2;
027:        import com.hp.hpl.jena.rdf.model.RDFNode;
028:        import com.hp.hpl.jena.rdf.model.Resource;
029:
030:        /**
031:         * Test case to test the interaction with IE. This tests in particular the <code>clauses(Clause,Object)</code> method
032:         * which is called by the IE when knowledge is requested to proof a certain goal.
033:         * @author <A HREF="mailto:j.b.dietrich@massey.ac.nz">Jens Dietrich </A> <A HREF="mailto:paschke@in.tum.de">Adrian Paschke</A>
034:         * @version 1.1 <01 August 2004>
035:         * @since 0.1
036:         */
037:        public class RDFClauseSetIEIntegrationTestCase extends
038:                AbstractRDFTestCase {
039:            /**
040:             * Generic test. Add clause set, and query IE with this kb.
041:             * @param predicateNS a predicate name space
042:             * @param predicateLN a predicate local name
043:             * @param expectedSubject the expected subject (a resource)
044:             * @param expectedObject the expected object (a resource or literal)
045:             * @throws an exception (indicating that the test case has failed)
046:             */
047:            private void test(String predicateNS, String predicateLN,
048:                    Object expectedSubject, Object expectedObject)
049:                    throws Exception {
050:                KnowledgeBase kb = new AdvancedKnowledgeBase();
051:                InferenceEngine ie = new ResolutionInferenceEngine2();
052:                // add knowledge
053:                URL url = this .getClass().getResource(
054:                        TEST_DATA_ROOT + "chap0302.rdf");
055:                RDFClauseSet clauseSet = new RDFClauseSet(url);
056:                // this line is ok for testing, but should not be used for 
057:                // with large amounts real world 
058:                clauseSet.setPredicates(RDFUtils.findPredicates(url));
059:                kb.add(clauseSet);
060:                // build query
061:                Predicate p = p(predicateNS, predicateLN);
062:                Query query = lfactory.createQuery(lfactory.createFact(p,
063:                        new Term[] {
064:                                lfactory.createVariableTerm("subject",
065:                                        Resource.class),
066:                                lfactory.createVariableTerm("object",
067:                                        RDFNode.class) }), "query");
068:                // issue query and compare results
069:                ResultSet rs = ie.query(query, kb, InferenceEngine.ALL,
070:                        InferenceEngine.BUBBLE_EXCEPTIONS);
071:
072:                if (!rs.next())
073:                    assertTrue(
074:                            "No result found when one result was expected, predicate: "
075:                                    + p, false);
076:                Object foundSubject = rs.getResult(Resource.class, "subject");
077:                Object foundObject = rs.getResult(RDFNode.class, "object");
078:                if (rs.next())
079:                    assertTrue(
080:                            "More than one result found when one result was expected, predicate: "
081:                                    + p, false);
082:                assertTrue(expectedSubject.equals(foundSubject)
083:                        && expectedObject.equals(foundObject));
084:
085:            }
086:
087:            /**
088:             * Test 1.
089:             * @throws an exception (indicating that the test case has failed)
090:             */
091:            public void test1() throws Exception {
092:                test(PSTCN, "author",
093:                        sub("http://burningbird.net/articles/monster3.htm"),
094:                        lit("Shelley Powers"));
095:            }
096:
097:            /**
098:             * Test 2.
099:             * @throws an exception (indicating that the test case has failed)
100:             */
101:            public void test2() throws Exception {
102:                test(PSTCN, "title",
103:                        sub("http://burningbird.net/articles/monster3.htm"),
104:                        lit("Architeuthis Dux"));
105:            }
106:
107:            /**
108:             * Test 3.
109:             * @throws an exception (indicating that the test case has failed)
110:             */
111:            public void test3() throws Exception {
112:                test(PSTCN, "series",
113:                        sub("http://burningbird.net/articles/monster3.htm"),
114:                        obj("http://burningbird.net/articles/monsters.htm"));
115:            }
116:
117:            /**
118:             * Test 4.
119:             * @throws an exception (indicating that the test case has failed)
120:             */
121:            public void test4() throws Exception {
122:                test(PSTCN, "contains",
123:                        sub("http://burningbird.net/articles/monster3.htm"),
124:                        lit("Physical description of giant squids"));
125:            }
126:
127:            /**
128:             * Test 5.
129:             * @throws an exception (indicating that the test case has failed)
130:             */
131:            public void test5() throws Exception {
132:                test(PSTCN, "alsoContains",
133:                        sub("http://burningbird.net/articles/monster3.htm"),
134:                        lit("Tale of the Legendary Kraken"));
135:            }
136:
137:            /**
138:             * Test 6.
139:             * @throws an exception (indicating that the test case has failed)
140:             */
141:            public void test6() throws Exception {
142:                test(PSTCN, "seriesTitle",
143:                        sub("http://burningbird.net/articles/monsters.htm"),
144:                        lit("A Tale of Two Monsters"));
145:            }
146:
147:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.