Source Code Cross Referenced for TestTrail.java in  » RSS-RDF » Jena-2.5.5 » com » hp » hpl » jena » reasoner » rulesys » impl » oldCode » 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.reasoner.rulesys.impl.oldCode 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /******************************************************************
002:         * File:        TestTrail.java
003:         * Created by:  Dave Reynolds
004:         * Created on:  20-May-2003
005:         * 
006:         * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
007:         * [See end of file]
008:         * $Id: TestTrail.java,v 1.7 2008/01/02 12:09:44 andy_seaborne Exp $
009:         *****************************************************************/package com.hp.hpl.jena.reasoner.rulesys.impl.oldCode;
010:
011:        import com.hp.hpl.jena.graph.*;
012:        import com.hp.hpl.jena.reasoner.*;
013:        import com.hp.hpl.jena.reasoner.rulesys.*;
014:
015:        import junit.framework.TestCase;
016:        import junit.framework.TestSuite;
017:
018:        /**
019:         *  Test harness for the prototype binding trail implementation.
020:         * 
021:         * @author <a href="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
022:         * @version $Revision: 1.7 $ on $Date: 2008/01/02 12:09:44 $
023:         */
024:        public class TestTrail extends TestCase {
025:
026:            Node a = Node.createURI("a");
027:            Node b = Node.createURI("b");
028:            Node c = Node.createURI("c");
029:            Node p = Node.createURI("p");
030:            Node q = Node.createURI("q");
031:
032:            /**
033:             * Boilerplate for junit
034:             */
035:            public TestTrail(String name) {
036:                super (name);
037:            }
038:
039:            /**
040:             * Boilerplate for junit.
041:             * This is its own test suite
042:             */
043:            public static TestSuite suite() {
044:                return new TestSuite(TestTrail.class);
045:            }
046:
047:            /**
048:             * Test unification support.
049:             */
050:            public void testUnify() {
051:                Node_RuleVariable X = new Node_RuleVariable("x", 0);
052:                Node_RuleVariable Y = new Node_RuleVariable("y", 1);
053:                Node_RuleVariable Z = new Node_RuleVariable("z", 2);
054:
055:                Trail trail = new Trail();
056:                assertTrue(trail.unify(new TriplePattern(X, p, Y),
057:                        new TriplePattern(a, p, b)));
058:                assertEquals(X.deref(), a);
059:                assertEquals(Y.deref(), b);
060:                assertTrue(Z.isUnbound());
061:                trail.unwindAndClear();
062:                assertTrue(X.isUnbound());
063:                assertTrue(Y.isUnbound());
064:
065:                assertTrue(trail.unify(new TriplePattern(X, p, X),
066:                        new TriplePattern(Z, p, a)));
067:                assertEquals(X.deref(), a);
068:                assertEquals(Z.deref(), a);
069:                trail.unwindAndClear();
070:
071:                TriplePattern gf = new TriplePattern(X, p, Functor
072:                        .makeFunctorNode("f", new Node[] { X, b }));
073:                TriplePattern hf1 = new TriplePattern(Y, p, Functor
074:                        .makeFunctorNode("f", new Node[] { Z, b }));
075:                TriplePattern hf2 = new TriplePattern(Y, p, Functor
076:                        .makeFunctorNode("f", new Node[] { a, Y }));
077:                TriplePattern hf3 = new TriplePattern(Y, p, Functor
078:                        .makeFunctorNode("f", new Node[] { b, Y }));
079:                assertTrue(trail.unify(gf, hf1));
080:                assertEquals(X.deref(), Y.deref());
081:                assertEquals(X.deref(), Z.deref());
082:                trail.unwindAndClear();
083:
084:                assertTrue(!trail.unify(gf, hf2));
085:                assertTrue(X.isUnbound());
086:                assertTrue(Y.isUnbound());
087:                assertTrue(Z.isUnbound());
088:                trail.unwindAndClear();
089:
090:                assertTrue(trail.unify(gf, hf3));
091:                assertEquals(X.deref(), b);
092:                assertEquals(Y.deref(), b);
093:                trail.unwindAndClear();
094:
095:            }
096:
097:            /**
098:             * Check a few triple pattern invariants. These are not directly
099:             * part of the trail system but the trail machinery depends on them.
100:             */
101:            public void testMatching() {
102:                Node_RuleVariable X = new Node_RuleVariable("x", 0);
103:                Node_RuleVariable Y = new Node_RuleVariable("y", 1);
104:                Node_RuleVariable Z = new Node_RuleVariable("z", 2);
105:                Node_RuleVariable X1 = new Node_RuleVariable("x1", 0);
106:                Node_RuleVariable Y1 = new Node_RuleVariable("y1", 1);
107:                Node_RuleVariable Z1 = new Node_RuleVariable("z1", 2);
108:
109:                assertTrue(X.sameValueAs(Y));
110:                TriplePattern f1 = new TriplePattern(X, p, Functor
111:                        .makeFunctorNode("f", new Node[] { X, b }));
112:                TriplePattern f2 = new TriplePattern(Y, p, Functor
113:                        .makeFunctorNode("f", new Node[] { Z, b }));
114:                TriplePattern f3 = new TriplePattern(Y1, p, Functor
115:                        .makeFunctorNode("f", new Node[] { Y1, b }));
116:                TriplePattern f4 = new TriplePattern(X1, p, Functor
117:                        .makeFunctorNode("f", new Node[] { Z1, b }));
118:                assertEquals(f1, f2);
119:                assertEquals(f1.hashCode(), f2.hashCode());
120:                assertTrue(f1.variantOf(f3));
121:                assertTrue(f2.variantOf(f4));
122:                assertTrue(!f1.variantOf(f2));
123:                assertTrue(!f3.variantOf(f4));
124:            }
125:
126:        }
127:
128:        /*
129:         (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
130:         All rights reserved.
131:
132:         Redistribution and use in source and binary forms, with or without
133:         modification, are permitted provided that the following conditions
134:         are met:
135:
136:         1. Redistributions of source code must retain the above copyright
137:         notice, this list of conditions and the following disclaimer.
138:
139:         2. Redistributions in binary form must reproduce the above copyright
140:         notice, this list of conditions and the following disclaimer in the
141:         documentation and/or other materials provided with the distribution.
142:
143:         3. The name of the author may not be used to endorse or promote products
144:         derived from this software without specific prior written permission.
145:
146:         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
147:         IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
148:         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
149:         IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
150:         INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
151:         NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
152:         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
153:         THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
154:         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
155:         THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
156:         */
w__w_w_.___j___a__v_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.