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


001:        /*
002:         	(c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003:         	All rights reserved - see end of file.
004:         	$Id: TestOntModelSpecAssembler.java,v 1.10 2008/01/31 12:30:51 chris-dollin Exp $
005:         */
006:
007:        package com.hp.hpl.jena.assembler.test;
008:
009:        import java.lang.reflect.Field;
010:
011:        import com.hp.hpl.jena.assembler.*;
012:        import com.hp.hpl.jena.assembler.assemblers.*;
013:        import com.hp.hpl.jena.assembler.exceptions.ReasonerClashException;
014:        import com.hp.hpl.jena.ontology.*;
015:        import com.hp.hpl.jena.rdf.model.*;
016:        import com.hp.hpl.jena.reasoner.*;
017:        import com.hp.hpl.jena.reasoner.rulesys.*;
018:        import com.hp.hpl.jena.shared.CannotCreateException;
019:
020:        import junit.framework.*;
021:
022:        public class TestOntModelSpecAssembler extends AssemblerTestBase {
023:            public TestOntModelSpecAssembler(String name) {
024:                super (name);
025:            }
026:
027:            protected Class getAssemblerClass() {
028:                return OntModelSpecAssembler.class;
029:            }
030:
031:            public void testOntModelSpecAssemblerType() {
032:                testDemandsMinimalType(new OntModelSpecAssembler(),
033:                        JA.OntModelSpec);
034:            }
035:
036:            public static TestSuite suite() {
037:                TestSuite result = new TestSuite();
038:                result.addTestSuite(TestOntModelSpecAssembler.class);
039:                addParameterisedTests(result);
040:                return result;
041:            }
042:
043:            protected static void addParameterisedTests(TestSuite result) {
044:                Field[] fields = OntModelSpec.class.getFields();
045:                for (int i = 0; i < fields.length; i += 1) {
046:                    Field f = fields[i];
047:                    String name = f.getName();
048:                    if (f.getType() == OntModelSpec.class)
049:                        try {
050:                            result.addTest(createTest((OntModelSpec) f
051:                                    .get(null), name));
052:                        } catch (Exception e) {
053:                            System.err
054:                                    .println("WARNING: failed to create test for OntModelSpec "
055:                                            + name);
056:                        }
057:                }
058:            }
059:
060:            protected void testBuiltinSpec(OntModelSpec ontModelSpec,
061:                    String specName) {
062:                testBuiltinSpecAsRootName(ontModelSpec, specName);
063:                testBuiltinSpecAsLikeTarget(ontModelSpec, specName);
064:            }
065:
066:            private void testBuiltinSpecAsLikeTarget(OntModelSpec ontModelSpec,
067:                    String specName) {
068:                Resource rr = resourceInModel("_x rdf:type ja:OntModelSpec; _x ja:likeBuiltinSpec <OM>"
069:                        .replaceAll("<OM>", JA.getURI() + specName));
070:                assertEquals(ontModelSpec, new OntModelSpecAssembler().open(rr));
071:            }
072:
073:            private void testBuiltinSpecAsRootName(OntModelSpec ontModelSpec,
074:                    String specName) {
075:                Resource root = resourceInModel(JA.getURI() + specName
076:                        + " rdf:type ja:OntModelSpec");
077:                assertEquals(ontModelSpec, new OntModelSpecAssembler()
078:                        .open(root));
079:            }
080:
081:            protected static Test createTest(final OntModelSpec spec,
082:                    final String name) {
083:                return new TestOntModelSpecAssembler(name) {
084:                    public void runBare() {
085:                        testBuiltinSpec(spec, name);
086:                    }
087:                };
088:            }
089:
090:            public void testOntModelSpecVocabulary() {
091:                assertDomain(JA.OntModelSpec, JA.ontLanguage);
092:                assertDomain(JA.OntModelSpec, JA.documentManager);
093:                assertDomain(JA.OntModelSpec, JA.likeBuiltinSpec);
094:            }
095:
096:            public void testCreateFreshDocumentManager() {
097:                Assembler a = new OntModelSpecAssembler();
098:                Resource root = resourceInModel("x rdf:type ja:OntModelSpec; x ja:documentManager y");
099:                OntDocumentManager dm = new OntDocumentManager();
100:                NamedObjectAssembler mock = new NamedObjectAssembler(
101:                        resource("y"), dm);
102:                OntModelSpec om = (OntModelSpec) a.open(mock, root);
103:                assertSame(dm, om.getDocumentManager());
104:            }
105:
106:            public void testUseSpecifiedReasoner() {
107:                Assembler a = new OntModelSpecAssembler();
108:                Resource root = resourceInModel("x rdf:type ja:OntModelSpec; x ja:reasonerFactory R");
109:                ReasonerFactory rf = new FakeReasonerFactory();
110:                NamedObjectAssembler mock = new NamedObjectAssembler(
111:                        resource("R"), rf);
112:                OntModelSpec om = (OntModelSpec) a.open(mock, root);
113:                assertSame(rf, om.getReasonerFactory());
114:            }
115:
116:            public void testUseSpecifiedImpliedReasoner() {
117:                testUsedSpecifiedImpliedReasoner(OWLFBRuleReasonerFactory.URI);
118:                testUsedSpecifiedImpliedReasoner(RDFSRuleReasonerFactory.URI);
119:            }
120:
121:            private void testUsedSpecifiedImpliedReasoner(String R) {
122:                ReasonerFactory rf = ReasonerFactoryAssembler
123:                        .getReasonerFactoryByURL(resource("x"), resource(R));
124:                Assembler a = new OntModelSpecAssembler();
125:                Resource root = resourceInModel("x rdf:type ja:OntModelSpec; x ja:reasonerURL "
126:                        + R);
127:                Assembler mock = new FixedObjectAssembler(
128:                        "(should not be this string)");
129:                OntModelSpec om = (OntModelSpec) a.open(mock, root);
130:                assertSame(rf, om.getReasonerFactory());
131:            }
132:
133:            public void testDetectsClashingImpliedAndExplicitReasoners() {
134:                Assembler a = new OntModelSpecAssembler();
135:                Resource root = resourceInModel("x rdf:type ja:OntModelSpec; x ja:reasonerURL R; x ja:reasonerFactory F");
136:                Assembler mock = new FixedObjectAssembler(
137:                        "(should not be this string)");
138:                try {
139:                    a.open(mock, root);
140:                    fail("should detect reasoner clash");
141:                } catch (ReasonerClashException e) {
142:                    pass();
143:                }
144:            }
145:
146:            public void testUseSpecifiedLanguage() {
147:                testSpecifiedLanguage(ProfileRegistry.DAML_LANG);
148:                testSpecifiedLanguage(ProfileRegistry.OWL_DL_LANG);
149:                testSpecifiedLanguage(ProfileRegistry.OWL_LANG);
150:                testSpecifiedLanguage(ProfileRegistry.OWL_LITE_LANG);
151:                testSpecifiedLanguage(ProfileRegistry.RDFS_LANG);
152:            }
153:
154:            private void testSpecifiedLanguage(String lang) {
155:                Assembler a = new OntModelSpecAssembler();
156:                Resource root = resourceInModel("x rdf:type ja:OntModelSpec; x ja:ontLanguage "
157:                        + lang);
158:                OntModelSpec om = (OntModelSpec) a.open(root);
159:                assertEquals(lang, om.getLanguage());
160:            }
161:
162:            public void testSpecifiedModelGetter() {
163:                Assembler a = new OntModelSpecAssembler();
164:                ModelGetter getter = new ModelGetter() {
165:                    public Model getModel(String URL) {
166:                        return null;
167:                    }
168:
169:                    public Model getModel(String URL, ModelReader loadIfAbsent) {
170:                        throw new CannotCreateException(URL);
171:                    }
172:                };
173:                NamedObjectAssembler mock = new NamedObjectAssembler(
174:                        resource("source"), getter);
175:                Resource root = resourceInModel("x rdf:type ja:OntModelSpec; x ja:importSource source");
176:                OntModelSpec om = (OntModelSpec) a.open(mock, root);
177:                assertSame(getter, om.getImportModelGetter());
178:            }
179:
180:            private static final class FakeReasonerFactory implements 
181:                    ReasonerFactory {
182:                public Reasoner create(Resource configuration) {
183:                    return null;
184:                }
185:
186:                public Model getCapabilities() {
187:                    return null;
188:                }
189:
190:                public String getURI() {
191:                    return null;
192:                }
193:            }
194:        }
195:
196:        /*
197:         * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
198:         * All rights reserved.
199:         *
200:         * Redistribution and use in source and binary forms, with or without
201:         * modification, are permitted provided that the following conditions
202:         * are met:
203:         * 1. Redistributions of source code must retain the above copyright
204:         *    notice, this list of conditions and the following disclaimer.
205:         * 2. Redistributions in binary form must reproduce the above copyright
206:         *    notice, this list of conditions and the following disclaimer in the
207:         *    documentation and/or other materials provided with the distribution.
208:         * 3. The name of the author may not be used to endorse or promote products
209:         *    derived from this software without specific prior written permission.
210:         *
211:         * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
212:         * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
213:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
214:         * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
215:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
216:         * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
217:         * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
218:         * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
219:         * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
220:         * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
221:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.