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


001:        package org.ontoware.rdf2go;
002:
003:        import static org.junit.Assert.fail;
004:
005:        import java.io.IOException;
006:        import java.io.InputStream;
007:        import java.util.Properties;
008:
009:        import junit.framework.Assert;
010:
011:        import org.junit.Test;
012:        import org.ontoware.rdf2go.exception.ModelRuntimeException;
013:        import org.ontoware.rdf2go.impl.AbstractModelFactory;
014:        import org.ontoware.rdf2go.model.Model;
015:        import org.ontoware.rdf2go.model.ModelSet;
016:        import org.ontoware.rdf2go.model.node.URI;
017:        import org.ontoware.rdf2go.testdata.TestData;
018:
019:        /**
020:         * make some basic functionality tests with the model implementation
021:         * 
022:         * assure the implementation is found by the factory,
023:         * open and close the model, insert some elements, etc.
024:         */
025:        public class GenericTest {
026:
027:            @Test
028:            public void testFindImplementation() throws ModelRuntimeException,
029:                    IOException {
030:
031:                //test basic model functionalities
032:                //grab the model factory
033:                //let it create a model
034:                //check if the model is closed by default
035:                //and truly open if it was opened
036:                ModelFactory modelFactory = RDF2Go.getModelFactory();
037:                Assert.assertNotNull(modelFactory);
038:                Model model = modelFactory.createModel();
039:                Assert.assertNotNull(model);
040:                Assert.assertFalse(model.isOpen());
041:                model.open();
042:                Assert.assertTrue(model.isOpen());
043:
044:                // use the model a bit
045:                //load foaf test data
046:                //make sure the file is loaded
047:                //assure the model form above has no entries
048:                //put the foaf file into the model and make sure the model now
049:                //has elements
050:                //finally close the model and find out if it truly is closed
051:                InputStream foafStream = TestData.getFoafAsStream();
052:                Assert.assertNotNull(foafStream);
053:                Assert.assertEquals(0, model.size());
054:                model.readFrom(foafStream);
055:                Assert.assertTrue(model.size() > 0);
056:                model.close();
057:                Assert.assertFalse(model.isOpen());
058:            }
059:
060:            //the classes return null on purpose
061:            //they are only mock implementations for testing purposes
062:
063:            private static class RDF2GoTestAdapter extends AbstractModelFactory {
064:
065:                public Model createModel(Properties p)
066:                        throws ModelRuntimeException {
067:                    return null;
068:                }
069:
070:                public ModelSet createModelSet(Properties p)
071:                        throws ModelRuntimeException {
072:                    return null;
073:                }
074:
075:                public Model createModel(URI contextURI)
076:                        throws ModelRuntimeException {
077:                    return null;
078:                }
079:            }
080:
081:            private static class RDF2GoTestAdapterTwo extends
082:                    AbstractModelFactory {
083:
084:                public Model createModel(Properties p)
085:                        throws ModelRuntimeException {
086:                    return null;
087:                }
088:
089:                public ModelSet createModelSet(Properties p)
090:                        throws ModelRuntimeException {
091:                    return null;
092:                }
093:
094:                public Model createModel(URI contextURI)
095:                        throws ModelRuntimeException {
096:                    return null;
097:                }
098:            }
099:
100:            /**
101:             * Testing the RDF2Go default class
102:             * 
103:             * assures that the registration of different implementations of the
104:             * rdf2go framework are made correctly
105:             *
106:             * create two inner classes that implement the missing parts
107:             * form the abstract factory
108:             * 
109:             * register those implementation with the RDF2Go framework
110:             * 
111:             * @author sauermann
112:             */
113:            @Test
114:            public void testRDF2GoFactory() {
115:                // this is protected by design
116:                RDF2Go.modelFactory = null;
117:
118:                // register the same twice is allowed
119:                ModelFactory adapterOne = new RDF2GoTestAdapter();
120:                RDF2Go.register(adapterOne);
121:                RDF2Go.register(adapterOne);
122:
123:                // twice is only allowed with the same class but not with a different
124:                // one
125:                adapterOne = new RDF2GoTestAdapter();
126:                RDF2Go.register(adapterOne);
127:
128:                ModelFactory adapterTwo = new RDF2GoTestAdapterTwo();
129:
130:                try {
131:                    RDF2Go.register(adapterTwo);
132:                    fail("cannot register two different RDF2Go classes");
133:                } catch (RuntimeException e) {
134:                    // ok
135:                } finally {
136:                    RDF2Go.modelFactory = null;
137:                }
138:
139:            }
140:
141:            /**
142:             * call this test from other code to check if the resource can be found from
143:             * within a packaged jar
144:             */
145:            @Test
146:            public void testTestData() {
147:                InputStream in = TestData.getFoafAsStream();
148:                Assert.assertNotNull(in);
149:                try {
150:                    Assert.assertTrue(in.read() != -1);
151:                } catch (IOException e) {
152:                    Assert.fail();
153:                }
154:            }
155:
156:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.