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


001:        /*
002:         * (c) Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003:         * [See end of file]
004:         */
005:
006:        package com.hp.hpl.jena.n3.turtle.test;
007:
008:        import junit.framework.*;
009:        import java.io.*;
010:
011:        import com.hp.hpl.jena.n3.turtle.TurtleEventNull;
012:        import com.hp.hpl.jena.n3.turtle.parser.TurtleParser;
013:        import com.hp.hpl.jena.util.junit.TestUtils;
014:
015:        /**
016:         * @author		Andy Seaborne
017:         * @version 	$Id: TurtleInternalTests.java,v 1.7 2008/01/02 12:08:06 andy_seaborne Exp $
018:         */
019:        public class TurtleInternalTests extends TestSuite {
020:            static public TestSuite suite() {
021:                return new TurtleInternalTests();
022:            }
023:
024:            static public final String QUOTE3 = "\"\"\"";
025:            static public boolean VERBOSE = false;
026:
027:            public TurtleInternalTests() {
028:                super ("Turtle Parser Syntactic tests");
029:
030:                // ---- Debug testing
031:                //addTest(new Test("<thing> b:px.b:py [] . ")) ;
032:                // if ( true ) return ;
033:                // ---- Debug testing
034:
035:                // Make sure basic things, at least, parse.
036:
037:                // URIs, qnames, statements, prefixes
038:
039:                // End of statement (and whitespace)
040:                addTest(new Test("a:subj a:prop a:d ."));
041:                addTest(new Test("a:subj a:prop a:d . "));
042:                addTest(new Test("a:subj a:prop a:d."));
043:                addTest(new Test("a:subj a:prop a:d. "));
044:
045:                addTest(new Test("rdf: rdf:type :_."));
046:                addTest(new Test("@prefix start: <somewhere>."));
047:                addTest(new Test(
048:                        "<http://here/subj> <http://here/prep> <http://here/obj>."));
049:
050:                // Whitespace, comments
051:                addTest(new Test("a:subj\ta:prop\ta:d.\t"));
052:                addTest(new Test("       a:subj\ta:prop\ta:d.     "));
053:                addTest(new Test("a:subj a:prop a:d.  "));
054:                addTest(new Test(""));
055:                addTest(new Test(" #Comment"));
056:                addTest(new Test("a:subj a:prop a:d.  # Comment"));
057:                addTest(new Test("a:subj a:prop a:d.# Comment"));
058:
059:                // Literal: strings
060:                addTest(new Test("a:subj a:prop 'string1'."));
061:                addTest(new Test("a:subj a:prop \"string2\"."));
062:                addTest(new Test("a:subj a:prop '''string3'''."));
063:                addTest(new Test("a:subj a:prop " + QUOTE3 + "string3" + QUOTE3
064:                        + "."));
065:
066:                // Literals: datatypes
067:                addTest(new Test("a:subj a:prop 'string1'^^x:dt."));
068:                addTest(new Test("a:subj a:prop 'string1'^^<uriref>."));
069:
070:                // Literals: numbers.
071:                addTest(new Test("a: :p 2. ."));
072:                addTest(new Test("a: :p +2. ."));
073:                addTest(new Test("a: :p -2 ."));
074:                addTest(new Test("a: :p 2e6."));
075:                addTest(new Test("a: :p 2e-6."));
076:                addTest(new Test("a: :p -2e-6."));
077:                addTest(new Test("a: :p 2.0e-6."));
078:                addTest(new Test("a: :p 2.0 ."));
079:
080:                //		// The "unusual" cases
081:                //		addTest(new Test("a:subj 'prop'^^<uriref> 'string'.")) ;
082:                //		addTest(new Test("a:subj a:prop 'string1'^^'stringDT'.")) ;
083:                //
084:                //		addTest(new Test("a:subj a:prop1 ?x ^^ x:dt.")) ;
085:                //		addTest(new Test("a:subj a:prop2 ?x ^^ ?x.")) ;
086:
087:                // Quotes in string
088:                addTest(new Test("a:subj a:prop \"\\'string2\\'\"."));
089:                addTest(new Test("a:subj a:prop \"\\\"string2\\\"\"."));
090:                addTest(new Test("a:subj a:prop '\\'string1\\'\'."));
091:                addTest(new Test("a:subj a:prop '\\\"string1\\\"\'."));
092:
093:                addTest(new Test("a:q21 a:prop " + QUOTE3 + "start\"finish"
094:                        + QUOTE3 + "."));
095:                addTest(new Test("a:q22 a:prop " + QUOTE3 + "start\"\"finish"
096:                        + QUOTE3 + "."));
097:                addTest(new Test("a:q2e3 a:prop " + QUOTE3
098:                        + "start\\\"\\\"\\\"finish" + QUOTE3 + "."));
099:                addTest(new Test("a:q13 a:prop " + QUOTE3 + "start'''finish"
100:                        + QUOTE3 + "."));
101:
102:                addTest(new Test("a:q11 a:prop '''start'finish'''."));
103:                addTest(new Test("a:q12 a:prop '''start''finish'''."));
104:                addTest(new Test("a:q12 a:prop '''start\\'\\'\\'finish'''."));
105:                addTest(new Test("a:q23 a:prop '''start\"\"\"finish'''."));
106:
107:                // Keywords and syntactic sugar
108:                //		addTest(new Test("this a:prop x:y .")) ;
109:                //		addTest(new Test("a:subj  a   x:y .")) ;
110:                //		addTest(new Test("a:subj  =   x:y .")) ;
111:                //		addTest(new Test("a:subj  =>  x:y .")) ;
112:                //		addTest(new Test("a:subj  <=  x:y .")) ;
113:                //		// <=> is not legal : it would mean "implies and is implied by" 
114:                //        // addTest(new Test("a:subj  <=> x:y .")) ;
115:                //		addTest(new Test("a:subj  >- x:y -> 'value' .")) ;
116:                //		addTest(new Test("a:subj  >- x:y -> 'value1', 'value2' .")) ;
117:
118:                // Not keywords
119:                addTest(new Test("a:subj <a>  x:y ."));
120:                addTest(new Test("<this>  a   x:y ."));
121:                addTest(new Test("@prefix has: <uri>."));
122:
123:                addTest(new Test("<>   a:prop  x:y ."));
124:                addTest(new Test("<#>  a:prop  x:y ."));
125:
126:                // Object lists
127:                addTest(new Test("a:subj a:prop a:d, a:e."));
128:                addTest(new Test("a:subj a:prop a:d, '123'."));
129:                addTest(new Test("a:subj a:prop '123', a:e."));
130:                //addTest(new Test("a:subj a:prop '123', .")) ;            // Null object list        
131:                //addTest(new Test("a:subj a:prop '123', '456', .")) ;     // Null object list        
132:
133:                // Property lists
134:                addTest(new Test("a:subj a:p1 a:v1 ;  a:p2 a:v2 ."));
135:                addTest(new Test(
136:                        "a:subj a:p1 a:v1, a:v2 ;  a:p2 a:v2 ; a:p3 'v4' ,'v5' ."));
137:                addTest(new Test("a:subj a:p1 a:v1; .")); // Null property list
138:                addTest(new Test("a:subj a:p1 a:v1; a:p2 a:v2; .")); // Null property list
139:
140:                // anon nodes
141:                addTest(new Test("[a:prop a:val]."));
142:                addTest(new Test("[] a:prop a:val."));
143:                addTest(new Test("[] a:prop []."));
144:
145:                // formulae
146:                // The final dot (statement terminator of outer statement) is necessary
147:                // Inside formulae, it is not.
148:                //        addTest(new Test("{:x :y :z} => {:x :y :z}.")) ;
149:                //        addTest(new Test("{:x :y :z} => {:x :y :z . }.")) ;
150:                //        addTest(new Test("{:x :y :z. } => {:x :y :z}.")) ;
151:
152:                // Variables
153:                //		addTest(new Test("?who ?knows ?what .")) ;
154:                //		addTest(new Test("{?who ?knows ?what} => {'somesort' 'of' 'logic'}." )) ;
155:
156:                // Formulae do not need the trailing '.'
157:                //		addTest(new Test("{ this a \"string2\". } => { this a 'string1'} .")) ;
158:
159:                // And they can have directives in.
160:                //		addTest(new Test("{ @prefix : <a> } => { this a 'string1'} .")) ;
161:                //		addTest(new Test("{ @prefix : <a> . a:x <b> 'c'} => { this a 'string1'} .")) ;
162:
163:                // RDF collections
164:                //addTest(new Test("() .")) ;
165:                addTest(new Test("<here> <list> ()."));
166:                addTest(new Test(" ( a:i1 a:i2 a:i3 ) a rdf:List."));
167:
168:                // Paths
169:                //		addTest(new Test(":x!:y <prop> [].")) ;
170:                //		addTest(new Test(":x!:y!:z <prop> [].")) ;
171:                //		addTest(new Test(":x^:y <prop> [].")) ;
172:                //		addTest(new Test(":x^:y^:z <prop> [].")) ;
173:                //		addTest(new Test("[] <prop> :x!:y^:z.")) ;
174:                //		addTest(new Test("[] :x^:y!:z [].")) ;
175:
176:                // Paths - using . (dot)
177:                //        addTest(new Test(":x.:y <prop> [].")) ;
178:                //        addTest(new Test(":x.:y.:z <prop> [].")) ;
179:                //        addTest(new Test("[] <prop> :a.:c.")) ;
180:                //        addTest(new Test("<thing>.:y  <prop> [].")) ;
181:                //        addTest(new Test("x:x.<thing>.:y  <prop> [].")) ;
182:                //        addTest(new Test("<thing>.:y^:z  <prop> [].")) ;
183:                //        addTest(new Test(":y.<thing>.:z  <prop> [].")) ;
184:                //        addTest(new Test("<thing> :px.:py.:pz [] . ")) ;
185:                //        addTest(new Test("<thing> :px!:py!:pz [] . ")) ;
186:
187:                // Paths and formulae
188:                //        addTest(new Test("{ :a.:b.:c . }.")) ;
189:                //        addTest(new Test("{ :a.:b.<c>.}.")) ;
190:
191:                // Named things
192:                //		addTest(new Test("_:anon :- [a:p a:v] .")) ;
193:                //		addTest(new Test("<uri> :- [a:p [ a:p a:v] ] .")) ;		
194:                //		// Named list: Not supported by cwm (as of 2001, 2002, 2003/09) but needed for printing shared 
195:                //		addTest(new Test("_:anon :- (\"1\") .")) ;
196:                //		// Named formulae: Not supported by cwm (as of 2001, 2002, 2003/09)
197:                //		addTest(new Test("_:anon :- { ?a ?b ?c } .")) ;
198:
199:                // Datatypes
200:                addTest(new Test("a:subj a:prop '123'^^xsd:integer ."));
201:                addTest(new Test("a:subj a:prop '123'^^<uri> ."));
202:                addTest(new Test(
203:                        "a:subj a:prop '<tag>text</tag>'^^rdf:XMLLiteral ."));
204:
205:                // Numbers
206:                addTest(new Test("a:subj a:prop 123 ."));
207:                // addTest(new Test("a:subj a:prop 123.")) ; Illegal N3
208:                addTest(new Test("a:subj a:prop 123.1 ."));
209:                addTest(new Test("a:subj a:prop -123.1 ."));
210:                addTest(new Test("a:subj a:prop 123.1e3 ."));
211:                addTest(new Test("a:subj a:prop 123.1e-3 ."));
212:                addTest(new Test("a:subj a:prop 123.1E3 ."));
213:                addTest(new Test("a:subj a:prop 123.1E-3 ."));
214:
215:                // Language tags
216:                addTest(new Test("a:subj a:prop 'text'@en ."));
217:                // Illegal in N-Triples
218:                //addTest(new Test("a:subj a:prop 'text'^^a:lang@en .")) ;
219:                //addTest(new Test("a:subj a:prop 'text'@en^^a:lang .")) ; // Can't have both
220:
221:                // XML Literal
222:                addTest(new Test(
223:                        "a:subj a:prop '<tag>text</tag>'^^rdf:XMLLiteral .")); // Can't have both
224:                //        addTest(new Test("a:subj a:prop '<tag>text</tag>'^^rdf:XMLLiteral@fr .")) ;
225:
226:                //addTest(new Test("a:subj a:prop ?x^^xsd:integer .")) ; // No varibales
227:                //addTest(new Test("a:subj a:prop '123'^^?x .")) ;
228:                //addTest(new Test("a:subj a:prop ?x^^?y .")) ;
229:
230:                // Unicode 00E9 is e-acute
231:                // Unicode 03B1 is alpha
232:                addTest(new Test("a:subj a:prop '\u00E9'."));
233:                addTest(new Test("a:subj a:prop '\u003B1'."));
234:
235:                addTest(new Test("\u00E9:subj a:prop '\u00E9'."));
236:                addTest(new Test("a:subj-\u00E9 a:prop '\u00E9'."));
237:
238:                addTest(new Test("\u03B1:subj a:prop '\u03B1'."));
239:                addTest(new Test("a:subj-\u03B1 a:prop '\u03B1'."));
240:            }
241:
242:            static class Test extends TestCase {
243:                String testString;
244:
245:                Test(String s) {
246:                    super (TestUtils.safeName(s));
247:                    testString = s;
248:                }
249:
250:                protected void runTest() throws Throwable {
251:                    TurtleParser parser = new TurtleParser(new StringReader(
252:                            testString));
253:                    parser.setEventHandler(new TurtleEventNull());
254:                    parser.getPrefixMapping()
255:                            .setNsPrefix("a", "http://host/a#");
256:                    parser.getPrefixMapping()
257:                            .setNsPrefix("x", "http://host/a#");
258:                    // Unicode 00E9 is e-acute
259:                    // Unicode 03B1 is alpha
260:                    parser.getPrefixMapping().setNsPrefix("\u00E9",
261:                            "http://host/e-acute/");
262:                    parser.getPrefixMapping().setNsPrefix("\u03B1",
263:                            "http://host/alpha/");
264:                    parser.getPrefixMapping().setNsPrefix("", "http://host/");
265:                    parser.getPrefixMapping().setNsPrefix("rdf",
266:                            "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
267:                    parser.getPrefixMapping().setNsPrefix("xsd",
268:                            "http://www.w3.org/2001/XMLSchema#");
269:                    parser.setBaseURI("http://base/");
270:                    parser.parse();
271:                }
272:            }
273:        }
274:
275:        /*
276:         *  (c) Copyright 2006, 2007, 2008 Hewlett-Packard Development Company, LP
277:         *  All rights reserved.
278:         *
279:         * Redistribution and use in source and binary forms, with or without
280:         * modification, are permitted provided that the following conditions
281:         * are met:
282:         * 1. Redistributions of source code must retain the above copyright
283:         *    notice, this list of conditions and the following disclaimer.
284:         * 2. Redistributions in binary form must reproduce the above copyright
285:         *    notice, this list of conditions and the following disclaimer in the
286:         *    documentation and/or other materials provided with the distribution.
287:         * 3. The name of the author may not be used to endorse or promote products
288:         *    derived from this software without specific prior written permission.
289:         *
290:         * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
291:         * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
292:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
293:         * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
294:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
295:         * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
296:         * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
297:         * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
298:         * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
299:         * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
300:         */
w_ww__.j_a___v__a_2s._c___om__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.