Source Code Cross Referenced for TestData.java in  » Search-Engine » semweb4j » org » ontoware » rdf2go » testdata » 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 » Search Engine » semweb4j » org.ontoware.rdf2go.testdata 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * LICENSE INFORMATION
003:         * Copyright 2005-2007 by FZI (http://www.fzi.de).
004:         * Licensed under a BSD license (http://www.opensource.org/licenses/bsd-license.php)
005:         * <OWNER> = Max Völkel
006:         * <ORGANIZATION> = FZI Forschungszentrum Informatik Karlsruhe, Karlsruhe, Germany
007:         * <YEAR> = 2007
008:         * 
009:         * Project information at http://semweb4j.org/rdf2go
010:         */
011:        package org.ontoware.rdf2go.testdata;
012:
013:        import java.io.IOException;
014:        import java.io.InputStream;
015:
016:        import org.ontoware.rdf2go.ModelFactory;
017:        import org.ontoware.rdf2go.exception.ModelRuntimeException;
018:        import org.ontoware.rdf2go.model.Model;
019:
020:        /**
021:         * Class that loads test-data models for JUnit tests.
022:         * 
023:         * @author sauermann
024:         */
025:        public class TestData {
026:
027:            /**
028:             * triples in foaf
029:             */
030:            public static final long FOAFSIZE = 536;
031:
032:            /**
033:             * triples in ical
034:             */
035:            public static final long ICALSIZE = 1317;
036:
037:            private static Model foafBuffered = null;
038:
039:            private static Model icalBuffered = null;
040:
041:            /**
042:             * loads foaf once, and then returns the model again and again. Use this if
043:             * you need the same model over and over in JUnit tests.
044:             * 
045:             * @param factory
046:             *            the factory to use to create the model
047:             * @return the loaded model
048:             */
049:            public static Model loadFoafBuffered(ModelFactory factory)
050:                    throws IOException, ModelRuntimeException {
051:                if (factory == null)
052:                    throw new IllegalArgumentException(
053:                            "Factory may not be null");
054:                if (foafBuffered == null) {
055:                    foafBuffered = loadFoaf(factory);
056:                }
057:                return foafBuffered;
058:            }
059:
060:            /**
061:             * load the foaf vocabulary from resource-stream.
062:             * 
063:             * The consumer must close the model!
064:             * 
065:             * @param factory
066:             *            factory to create model
067:             * @return a loaded model
068:             * @throws ModelRuntimeException
069:             * @throws IOException
070:             */
071:            public static Model loadFoaf(ModelFactory factory)
072:                    throws IOException, ModelRuntimeException {
073:                Model result = factory.createModel();
074:                result.open();
075:                InputStream in = getFoafAsStream();
076:                try {
077:                    result.readFrom(in);
078:                } finally {
079:                    in.close();
080:                }
081:                return result;
082:            }
083:
084:            /**
085:             * 
086:             * @return as RDF/XML
087:             */
088:            public static InputStream getFoafAsStream() {
089:
090:                ClassLoader cl = Thread.currentThread().getContextClassLoader();
091:                InputStream in = cl
092:                        .getResourceAsStream("org/ontoware/rdf2go/testdata/foaf.xml");
093:                return in;
094:            }
095:
096:            /**
097:             * loads ICAL once, and then returns the model again and again. Use this if
098:             * you need the same model over and over in JUnit tests.
099:             * 
100:             * @param factory
101:             *            the factory to use to create the model
102:             * @return the loaded model
103:             */
104:            public static Model loadICALBuffered(ModelFactory factory)
105:                    throws IOException, ModelRuntimeException {
106:                if (icalBuffered == null) {
107:                    icalBuffered = loadICAL(factory);
108:                }
109:                return icalBuffered;
110:            }
111:
112:            /**
113:             * load the icaltzd vocabulary from resource-stream
114:             * 
115:             * @param factory
116:             *            factory to create model
117:             * @return a loaded model
118:             * @throws ModelRuntimeException
119:             * @throws IOException
120:             */
121:            public static Model loadICAL(ModelFactory factory)
122:                    throws IOException, ModelRuntimeException {
123:                Model result = factory.createModel();
124:                result.open();
125:                InputStream in = getICALAsStream();
126:                try {
127:                    result.readFrom(in);
128:                } finally {
129:                    in.close();
130:                }
131:                return result;
132:            }
133:
134:            /**
135:             * 
136:             * @return icaltzd.rdfs as an InputStream
137:             */
138:            public static InputStream getICALAsStream() {
139:                ClassLoader cl = Thread.currentThread().getContextClassLoader();
140:                InputStream in = cl
141:                        .getResourceAsStream("org/ontoware/rdf2go/testdata/icaltzd.rdfs");
142:                return in;
143:            }
144:
145:            /**
146:             * A simple self-check for OSGi-debugging
147:             * 
148:             * @param args
149:             */
150:            public static void main(String[] args) {
151:                if (getFoafAsStream() == null)
152:                    throw new RuntimeException(
153:                            "Could not load FOAF from internally packaged file");
154:
155:                //else
156:                System.out.println("FOAF found.");
157:            }
158:
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.