Source Code Cross Referenced for AbstractRDFTestCase.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 Dietrich</a>
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */
018:
019:        package test.org.mandarax.rdf;
020:
021:        import org.mandarax.kernel.ConstantTerm;
022:        import org.mandarax.kernel.Fact;
023:        import org.mandarax.kernel.LogicFactory;
024:        import org.mandarax.kernel.Predicate;
025:        import org.mandarax.kernel.Term;
026:        import org.mandarax.rdf.RDFPredicateRegistry;
027:
028:        import com.hp.hpl.jena.rdf.model.Literal;
029:        import com.hp.hpl.jena.rdf.model.Model;
030:        import com.hp.hpl.jena.rdf.model.ModelFactory;
031:        import com.hp.hpl.jena.rdf.model.RDFNode;
032:        import com.hp.hpl.jena.rdf.model.Resource;
033:
034:        import junit.framework.TestCase;
035:
036:        /**
037:         * Abstract super class for RDF test cases.
038:         * Contains various utility methods.
039:         * @author <A HREF="mailto:paschke@in.tum.de">Adrian Paschke</A> <A HREF="mailto:j.b.dietrich@massey.ac.nz">Jens Dietrich</A> 
040:         * @version 1.1 <01 August 2004>
041:         * @since 0.1
042:         */
043:
044:        public abstract class AbstractRDFTestCase extends TestCase {
045:
046:            public static final String TEST_DATA_ROOT = "/test/org/mandarax/rdf/testdata/";
047:            // name spaces used in test data
048:            public static final String RDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
049:            public static final String PSTCN = "http://burningbird.net/postcon/elements/1.0/";
050:
051:            public static LogicFactory lfactory = LogicFactory
052:                    .getDefaultFactory();
053:
054:            // Jena model - used as factory for resources and literals
055:            protected static Model jenaModel = ModelFactory
056:                    .createDefaultModel();
057:
058:            /**
059:             * Compare objects.
060:             * @param object1 the expected object
061:             * @param object2 the expected subject
062:             * @param isLiteral indicates whether a literal (and not a resource is expected.
063:             * @return a boolean (the result of comparing the objects)
064:             */
065:            protected boolean compareObjects(Object object1, Object object2,
066:                    boolean b) {
067:                // TODO improve 
068:                return object1 != null && object1.equals(object2);
069:            }
070:
071:            /**
072:             * Compare subjects.
073:             * @param subject1 the expected subject
074:             * @param subject2 the computed subject
075:             * @return a boolean (the result of comparing the objects)
076:             */
077:            protected boolean compareSubjects(Object subject1, Object subject2) {
078:                // TODO improve 
079:                return subject1 != null && subject1.equals(subject2);
080:            }
081:
082:            /**
083:             * Compare predicates.
084:             * @param predicate1 the expected predicate
085:             * @param predicate2 the imported predicate
086:             * @return a boolean (the result of comparing the objects)
087:             */
088:            protected boolean comparePredicates(Predicate predicate1,
089:                    Predicate predicate2) {
090:                // TODO improve
091:                return predicate1 != null && predicate1.equals(predicate2);
092:            }
093:
094:            /**
095:             * Factory methods for predicates.
096:             * @param ns the name space
097:             * @param name the predicate name
098:             * @return a predicate
099:             */
100:            protected static Predicate p(String ns, String name) {
101:                return RDFPredicateRegistry.findOrCreatePredicate(ns, name,
102:                        false);
103:            }
104:
105:            /**
106:             * Factory methods for subjects.
107:             * @param uri the subject uri
108:             * @return a subject
109:             */
110:            protected static Object sub(String uri) {
111:                return jenaModel.createResource(uri);
112:            }
113:
114:            /**
115:             * Factory methods for objects.
116:             * @param uri the object uri
117:             * @return an object
118:             */
119:            protected static Object obj(String uri) {
120:                return jenaModel.createResource(uri);
121:            }
122:
123:            /**
124:             * Factory methods for literals.
125:             * @param value the literal
126:             * @return an object
127:             */
128:            protected static Object lit(String value) {
129:                return jenaModel.createLiteral(value);
130:            }
131:
132:            /**
133:             * Create a fact associating a resource with an object.
134:             * @param predicateNS the name space of the predicate
135:             * @param predicateLN the local name of the predicate
136:             * @param subURI the uri of the subject
137:             * @param objURI the uri of the object
138:             */
139:            protected static Fact buildFactWithObject(String predicateNS,
140:                    String predicateLN, String subURI, String objURI) {
141:                Predicate p = p(predicateNS, predicateLN);
142:                Resource subject = jenaModel.createResource(subURI);
143:                Resource object = jenaModel.createResource(objURI);
144:                ConstantTerm subjectTerm = lfactory.createConstantTerm(subject,
145:                        Resource.class);
146:                ConstantTerm objectTerm = lfactory.createConstantTerm(object,
147:                        RDFNode.class);
148:                return lfactory.createFact(p, new Term[] { subjectTerm,
149:                        objectTerm });
150:            }
151:
152:            /**
153:             * Create a fact associating a resource with a literal.
154:             * @param predicateNS the name space of the predicate
155:             * @param predicateLN the local name of the predicate
156:             * @param subURI the uri of the subject
157:             * @param value the literal value
158:             */
159:            protected static Fact buildFactWithLiteral(String predicateNS,
160:                    String predicateLN, String subURI, String value) {
161:                Predicate p = p(predicateNS, predicateLN);
162:                Resource subject = jenaModel.createResource(subURI);
163:                Literal object = jenaModel.createLiteral(value);
164:                ConstantTerm subjectTerm = lfactory.createConstantTerm(subject,
165:                        Resource.class);
166:                ConstantTerm objectTerm = lfactory.createConstantTerm(object,
167:                        RDFNode.class);
168:                return lfactory.createFact(p, new Term[] { subjectTerm,
169:                        objectTerm });
170:            }
171:
172:            /**
173:             * Log a string.
174:             * @param msg a string
175:             */
176:            protected static void log(String msg) {
177:                // TODO logging
178:                System.out.println(msg);
179:            }
180:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.