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


001:        /*
002:         (c) Copyright 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP, all rights reserved.
003:         [See end of file]
004:         $Id: TestFileUtils.java,v 1.13 2008/01/02 12:08:35 andy_seaborne Exp $
005:         */
006:
007:        package com.hp.hpl.jena.util.test;
008:
009:        import com.hp.hpl.jena.util.FileUtils;
010:
011:        import junit.framework.*;
012:
013:        /**
014:         * TestFileUtils
015:         * 
016:         * @author kers
017:         */
018:        public class TestFileUtils extends TestCase {
019:            public TestFileUtils(String name) {
020:                super (name);
021:            }
022:
023:            public static TestSuite suite() {
024:                return new TestSuite(TestFileUtils.class);
025:            }
026:
027:            public void testLangXML() {
028:                assertEquals("RDF/XML", FileUtils.langXML);
029:            }
030:
031:            public void testLangXMLAbbrev() {
032:                assertEquals("RDF/XML-ABBREV", FileUtils.langXMLAbbrev);
033:            }
034:
035:            public void testLangNTriple() {
036:                assertEquals("N-TRIPLE", FileUtils.langNTriple);
037:            }
038:
039:            public void testLangN3() {
040:                assertEquals("N3", FileUtils.langN3);
041:            }
042:
043:            public void testLangTurtle() {
044:                assertEquals("TURTLE", FileUtils.langTurtle);
045:            }
046:
047:            public void testGuessLangLowerCase() {
048:                assertEquals(FileUtils.langN3, FileUtils.guessLang("simple.n3"));
049:                assertEquals(FileUtils.langN3, FileUtils
050:                        .guessLang("hello.there.n3"));
051:                assertEquals(FileUtils.langTurtle, FileUtils
052:                        .guessLang("simple.ttl"));
053:                assertEquals(FileUtils.langTurtle, FileUtils
054:                        .guessLang("hello.there.ttl"));
055:                assertEquals(FileUtils.langNTriple, FileUtils
056:                        .guessLang("simple.nt"));
057:                assertEquals(FileUtils.langNTriple, FileUtils
058:                        .guessLang("whats.up.nt"));
059:                assertEquals(FileUtils.langXML, FileUtils
060:                        .guessLang("poggle.rdf"));
061:                assertEquals(FileUtils.langXML, FileUtils.guessLang("wise.owl"));
062:                assertEquals(FileUtils.langXML, FileUtils.guessLang("dotless"));
063:            }
064:
065:            public void testGuessLangMixedCase() {
066:                assertEquals(FileUtils.langN3, FileUtils.guessLang("simple.N3"));
067:                assertEquals(FileUtils.langN3, FileUtils
068:                        .guessLang("hello.there.N3"));
069:                assertEquals(FileUtils.langTurtle, FileUtils
070:                        .guessLang("simple.TTL"));
071:                assertEquals(FileUtils.langTurtle, FileUtils
072:                        .guessLang("hello.there.TTL"));
073:                assertEquals(FileUtils.langNTriple, FileUtils
074:                        .guessLang("simple.NT"));
075:                assertEquals(FileUtils.langNTriple, FileUtils
076:                        .guessLang("whats.up.Nt"));
077:                assertEquals(FileUtils.langXML, FileUtils
078:                        .guessLang("poggle.rDf"));
079:                assertEquals(FileUtils.langXML, FileUtils.guessLang("wise.OwL"));
080:                assertEquals(FileUtils.langXML, FileUtils.guessLang("dotless"));
081:            }
082:
083:            public void testGuessLangFallback() {
084:                assertEquals("spoo", FileUtils.guessLang("noSuffix", "spoo"));
085:                assertEquals("pots", FileUtils.guessLang("suffix.unknown",
086:                        "pots"));
087:                assertEquals(FileUtils.langXML, FileUtils.guessLang("rdf.rdf",
088:                        "spoo"));
089:                assertEquals(FileUtils.langXML, FileUtils.guessLang("rdf.owl",
090:                        "spoo"));
091:            }
092:
093:            public void testMisplacedDots() {
094:                assertEquals("spoo", FileUtils.guessLang("stuff.left/right",
095:                        "spoo"));
096:                assertEquals("spoo", FileUtils.guessLang("stuff.left\\right",
097:                        "spoo"));
098:            }
099:
100:            public void testFilename1() {
101:                isFilename("foo");
102:            }
103:
104:            public void testFilename2() {
105:                isFilename("foo/bar");
106:            }
107:
108:            public void testFilename3() {
109:                isFilename("foo\\bar");
110:            }
111:
112:            public void testFilename4() {
113:                isFilename("\\bar");
114:            }
115:
116:            public void testFilename5() {
117:                isFilename("foo/bar");
118:            }
119:
120:            public void testFilename6() {
121:                isFilename("c:foo");
122:            }
123:
124:            public void testFilename7() {
125:                isFilename("c:\\foo");
126:            }
127:
128:            public void testFilename8() {
129:                isFilename("c:\\foo\\bar");
130:            }
131:
132:            public void testFilename9() {
133:                isFilename("file::foo");
134:            }
135:
136:            public void testFilename10() {
137:                isNotFilename("http://www.hp.com/");
138:            }
139:
140:            public void testFilename11() {
141:                isNotFilename("urn:tag:stuff");
142:            }
143:
144:            public void testTranslateFilename1() {
145:                checkToFilename("file:Dir/File", "Dir/File");
146:            }
147:
148:            public void testTranslateFilename2() {
149:                checkToFilename("c:\\Dir\\File", "c:\\Dir\\File");
150:            }
151:
152:            public void testTranslateFilename3() {
153:                checkToFilename("unknown:File", null);
154:            }
155:
156:            public void testTranslateFilename4() {
157:                checkToFilename("file:Dir/File With Space",
158:                        "Dir/File With Space");
159:            }
160:
161:            public void testTranslateFilename5() {
162:                checkToFilename("file:Dir/File%20With Enc%21",
163:                        "Dir/File With Enc!");
164:            }
165:
166:            public void testTranslateFilename6() {
167:                checkToFilename("file:///dir/file", "/dir/file");
168:            }
169:
170:            public void testTranslateFilename7() {
171:                checkToFilename("file:///c:/dir/file", "/c:/dir/file");
172:            }
173:
174:            public void testTranslateFilename8() {
175:                checkToFilename("file:file", "file");
176:            }
177:
178:            public void testTranslateFilename9() {
179:                checkToFilename("file://file", "//file");
180:            }
181:
182:            // Don't tranlate:
183:            public void testTranslateFilename10() {
184:                checkToFilename("Dir/File%20With Enc%21",
185:                        "Dir/File%20With Enc%21");
186:            }
187:
188:            public void testTranslateFilename11() {
189:                checkToFilename("Dir/File+With+Plus", "Dir/File+With+Plus");
190:            }
191:
192:            public void testTranslateFilename12() {
193:                checkToFilename("file:Dir/File+With+Plus", "Dir/File+With+Plus");
194:            }
195:
196:            void isFilename(String fn) {
197:                assertTrue("Should be a file name : " + fn, FileUtils
198:                        .isFile(fn));
199:            }
200:
201:            void isNotFilename(String fn) {
202:                assertFalse("Shouldn't be a  file name: " + fn, FileUtils
203:                        .isFile(fn));
204:            }
205:
206:            void checkToFilename(String url, String fn) {
207:                String t = FileUtils.toFilename(url);
208:                assertEquals("Wrong: " + t + " != " + fn, t, fn);
209:            }
210:
211:            public void testToURL1() {
212:                checkToURL("A%H", "%25");
213:            }
214:
215:            public void testToURL2() {
216:                checkToURL("A#H", "%23");
217:            }
218:
219:            public void testToURL3() {
220:                checkToURL("A?H", "%3F");
221:            }
222:
223:            public void testToURL4() {
224:                checkToURL("A H", "%20");
225:            }
226:
227:            public void testToURL5() {
228:                checkToURL("ü", "ü");
229:            }
230:
231:            private void checkToURL(String fn, String match) {
232:                String r = FileUtils.toURL(fn);
233:                if (!r.matches("^.*/[^/]*" + match + "[^/]*$"))
234:                    fail("Converted \"" + fn + "\" to <" + r
235:                            + "> which did not match /" + match + "/");
236:                if (!r.startsWith("file:///"))
237:                    fail("Converted \"" + fn + "\" to <" + r
238:                            + "> which does not start file:///");
239:                if (r.startsWith("file:////"))
240:                    fail("Converted \"" + fn + "\" to <" + r
241:                            + "> which has too many initial /");
242:
243:            }
244:        }
245:
246:        /*
247:         * (c) Copyright 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
248:         * All rights reserved.
249:         * 
250:         * Redistribution and use in source and binary forms, with or without
251:         * modification, are permitted provided that the following conditions are met:
252:         * 
253:         * 1. Redistributions of source code must retain the above copyright notice,
254:         * this list of conditions and the following disclaimer.
255:         * 
256:         * 2. Redistributions in binary form must reproduce the above copyright notice,
257:         * this list of conditions and the following disclaimer in the documentation
258:         * and/or other materials provided with the distribution.
259:         * 
260:         * 3. The name of the author may not be used to endorse or promote products
261:         * derived from this software without specific prior written permission.
262:         * 
263:         * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
264:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265:         * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
266:         * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
267:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
268:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
269:         * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
270:         * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
271:         * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
272:         * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
273:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.