Source Code Cross Referenced for FilenameUtilsTestCase.java in  » Library » apache-common-IO » org » apache » commons » io » 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 » Library » apache common IO » org.apache.commons.io 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Licensed to the Apache Software Foundation (ASF) under one or more
0003:         * contributor license agreements.  See the NOTICE file distributed with
0004:         * this work for additional information regarding copyright ownership.
0005:         * The ASF licenses this file to You under the Apache License, Version 2.0
0006:         * (the "License"); you may not use this file except in compliance with
0007:         * the License.  You may obtain a copy of the License at
0008:         * 
0009:         *      http://www.apache.org/licenses/LICENSE-2.0
0010:         * 
0011:         * Unless required by applicable law or agreed to in writing, software
0012:         * distributed under the License is distributed on an "AS IS" BASIS,
0013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014:         * See the License for the specific language governing permissions and
0015:         * limitations under the License.
0016:         */
0017:        package org.apache.commons.io;
0018:
0019:        import java.io.File;
0020:        import java.io.IOException;
0021:        import java.util.ArrayList;
0022:        import java.util.Arrays;
0023:        import java.util.Collection;
0024:
0025:        import junit.framework.Test;
0026:        import junit.framework.TestSuite;
0027:        import junit.textui.TestRunner;
0028:
0029:        import org.apache.commons.io.testtools.FileBasedTestCase;
0030:
0031:        /**
0032:         * This is used to test FilenameUtils for correctness.
0033:         *
0034:         * @author Peter Donald
0035:         * @author Matthew Hawthorne
0036:         * @author Martin Cooper
0037:         * @version $Id: FilenameUtilsTestCase.java 437567 2006-08-28 06:39:07Z bayard $
0038:         * @see FilenameUtils
0039:         */
0040:        public class FilenameUtilsTestCase extends FileBasedTestCase {
0041:
0042:            private static final String SEP = "" + File.separatorChar;
0043:            private static final boolean WINDOWS = (File.separatorChar == '\\');
0044:
0045:            private File testFile1;
0046:            private File testFile2;
0047:
0048:            private static int testFile1Size;
0049:            private static int testFile2Size;
0050:
0051:            public static void main(String[] args) {
0052:                TestRunner.run(suite());
0053:            }
0054:
0055:            public static Test suite() {
0056:                return new TestSuite(FilenameUtilsTestCase.class);
0057:            }
0058:
0059:            public FilenameUtilsTestCase(String name) throws IOException {
0060:                super (name);
0061:
0062:                testFile1 = new File(getTestDirectory(), "file1-test.txt");
0063:                testFile2 = new File(getTestDirectory(), "file1a-test.txt");
0064:
0065:                testFile1Size = (int) testFile1.length();
0066:                testFile2Size = (int) testFile2.length();
0067:            }
0068:
0069:            /** @see junit.framework.TestCase#setUp() */
0070:            protected void setUp() throws Exception {
0071:                getTestDirectory().mkdirs();
0072:                createFile(testFile1, testFile1Size);
0073:                createFile(testFile2, testFile2Size);
0074:                FileUtils.deleteDirectory(getTestDirectory());
0075:                getTestDirectory().mkdirs();
0076:                createFile(testFile1, testFile1Size);
0077:                createFile(testFile2, testFile2Size);
0078:            }
0079:
0080:            /** @see junit.framework.TestCase#tearDown() */
0081:            protected void tearDown() throws Exception {
0082:                FileUtils.deleteDirectory(getTestDirectory());
0083:            }
0084:
0085:            //-----------------------------------------------------------------------
0086:            public void testNormalize() throws Exception {
0087:                assertEquals(null, FilenameUtils.normalize(null));
0088:                assertEquals(null, FilenameUtils.normalize(":"));
0089:                assertEquals(null, FilenameUtils.normalize("1:\\a\\b\\c.txt"));
0090:                assertEquals(null, FilenameUtils.normalize("1:"));
0091:                assertEquals(null, FilenameUtils.normalize("1:a"));
0092:                assertEquals(null, FilenameUtils.normalize("\\\\\\a\\b\\c.txt"));
0093:                assertEquals(null, FilenameUtils.normalize("\\\\a"));
0094:
0095:                assertEquals("a" + SEP + "b" + SEP + "c.txt", FilenameUtils
0096:                        .normalize("a\\b/c.txt"));
0097:                assertEquals("" + SEP + "a" + SEP + "b" + SEP + "c.txt",
0098:                        FilenameUtils.normalize("\\a\\b/c.txt"));
0099:                assertEquals("C:" + SEP + "a" + SEP + "b" + SEP + "c.txt",
0100:                        FilenameUtils.normalize("C:\\a\\b/c.txt"));
0101:                assertEquals("" + SEP + "" + SEP + "server" + SEP + "a" + SEP
0102:                        + "b" + SEP + "c.txt", FilenameUtils
0103:                        .normalize("\\\\server\\a\\b/c.txt"));
0104:                assertEquals("~" + SEP + "a" + SEP + "b" + SEP + "c.txt",
0105:                        FilenameUtils.normalize("~\\a\\b/c.txt"));
0106:                assertEquals("~user" + SEP + "a" + SEP + "b" + SEP + "c.txt",
0107:                        FilenameUtils.normalize("~user\\a\\b/c.txt"));
0108:
0109:                assertEquals("a" + SEP + "c", FilenameUtils
0110:                        .normalize("a/b/../c"));
0111:                assertEquals("c", FilenameUtils.normalize("a/b/../../c"));
0112:                assertEquals("c" + SEP, FilenameUtils.normalize("a/b/../../c/"));
0113:                assertEquals(null, FilenameUtils.normalize("a/b/../../../c"));
0114:                assertEquals("a" + SEP, FilenameUtils.normalize("a/b/.."));
0115:                assertEquals("a" + SEP, FilenameUtils.normalize("a/b/../"));
0116:                assertEquals("", FilenameUtils.normalize("a/b/../.."));
0117:                assertEquals("", FilenameUtils.normalize("a/b/../../"));
0118:                assertEquals(null, FilenameUtils.normalize("a/b/../../.."));
0119:                assertEquals("a" + SEP + "d", FilenameUtils
0120:                        .normalize("a/b/../c/../d"));
0121:                assertEquals("a" + SEP + "d" + SEP, FilenameUtils
0122:                        .normalize("a/b/../c/../d/"));
0123:                assertEquals("a" + SEP + "b" + SEP + "d", FilenameUtils
0124:                        .normalize("a/b//d"));
0125:                assertEquals("a" + SEP + "b" + SEP, FilenameUtils
0126:                        .normalize("a/b/././."));
0127:                assertEquals("a" + SEP + "b" + SEP, FilenameUtils
0128:                        .normalize("a/b/./././"));
0129:                assertEquals("a" + SEP, FilenameUtils.normalize("./a/"));
0130:                assertEquals("a", FilenameUtils.normalize("./a"));
0131:                assertEquals("", FilenameUtils.normalize("./"));
0132:                assertEquals("", FilenameUtils.normalize("."));
0133:                assertEquals(null, FilenameUtils.normalize("../a"));
0134:                assertEquals(null, FilenameUtils.normalize(".."));
0135:                assertEquals("", FilenameUtils.normalize(""));
0136:
0137:                assertEquals(SEP + "a", FilenameUtils.normalize("/a"));
0138:                assertEquals(SEP + "a" + SEP, FilenameUtils.normalize("/a/"));
0139:                assertEquals(SEP + "a" + SEP + "c", FilenameUtils
0140:                        .normalize("/a/b/../c"));
0141:                assertEquals(SEP + "c", FilenameUtils.normalize("/a/b/../../c"));
0142:                assertEquals(null, FilenameUtils.normalize("/a/b/../../../c"));
0143:                assertEquals(SEP + "a" + SEP, FilenameUtils
0144:                        .normalize("/a/b/.."));
0145:                assertEquals(SEP + "", FilenameUtils.normalize("/a/b/../.."));
0146:                assertEquals(null, FilenameUtils.normalize("/a/b/../../.."));
0147:                assertEquals(SEP + "a" + SEP + "d", FilenameUtils
0148:                        .normalize("/a/b/../c/../d"));
0149:                assertEquals(SEP + "a" + SEP + "b" + SEP + "d", FilenameUtils
0150:                        .normalize("/a/b//d"));
0151:                assertEquals(SEP + "a" + SEP + "b" + SEP, FilenameUtils
0152:                        .normalize("/a/b/././."));
0153:                assertEquals(SEP + "a", FilenameUtils.normalize("/./a"));
0154:                assertEquals(SEP + "", FilenameUtils.normalize("/./"));
0155:                assertEquals(SEP + "", FilenameUtils.normalize("/."));
0156:                assertEquals(null, FilenameUtils.normalize("/../a"));
0157:                assertEquals(null, FilenameUtils.normalize("/.."));
0158:                assertEquals(SEP + "", FilenameUtils.normalize("/"));
0159:
0160:                assertEquals("~" + SEP + "a", FilenameUtils.normalize("~/a"));
0161:                assertEquals("~" + SEP + "a" + SEP, FilenameUtils
0162:                        .normalize("~/a/"));
0163:                assertEquals("~" + SEP + "a" + SEP + "c", FilenameUtils
0164:                        .normalize("~/a/b/../c"));
0165:                assertEquals("~" + SEP + "c", FilenameUtils
0166:                        .normalize("~/a/b/../../c"));
0167:                assertEquals(null, FilenameUtils.normalize("~/a/b/../../../c"));
0168:                assertEquals("~" + SEP + "a" + SEP, FilenameUtils
0169:                        .normalize("~/a/b/.."));
0170:                assertEquals("~" + SEP + "", FilenameUtils
0171:                        .normalize("~/a/b/../.."));
0172:                assertEquals(null, FilenameUtils.normalize("~/a/b/../../.."));
0173:                assertEquals("~" + SEP + "a" + SEP + "d", FilenameUtils
0174:                        .normalize("~/a/b/../c/../d"));
0175:                assertEquals("~" + SEP + "a" + SEP + "b" + SEP + "d",
0176:                        FilenameUtils.normalize("~/a/b//d"));
0177:                assertEquals("~" + SEP + "a" + SEP + "b" + SEP, FilenameUtils
0178:                        .normalize("~/a/b/././."));
0179:                assertEquals("~" + SEP + "a", FilenameUtils.normalize("~/./a"));
0180:                assertEquals("~" + SEP, FilenameUtils.normalize("~/./"));
0181:                assertEquals("~" + SEP, FilenameUtils.normalize("~/."));
0182:                assertEquals(null, FilenameUtils.normalize("~/../a"));
0183:                assertEquals(null, FilenameUtils.normalize("~/.."));
0184:                assertEquals("~" + SEP, FilenameUtils.normalize("~/"));
0185:                assertEquals("~" + SEP, FilenameUtils.normalize("~"));
0186:
0187:                assertEquals("~user" + SEP + "a", FilenameUtils
0188:                        .normalize("~user/a"));
0189:                assertEquals("~user" + SEP + "a" + SEP, FilenameUtils
0190:                        .normalize("~user/a/"));
0191:                assertEquals("~user" + SEP + "a" + SEP + "c", FilenameUtils
0192:                        .normalize("~user/a/b/../c"));
0193:                assertEquals("~user" + SEP + "c", FilenameUtils
0194:                        .normalize("~user/a/b/../../c"));
0195:                assertEquals(null, FilenameUtils
0196:                        .normalize("~user/a/b/../../../c"));
0197:                assertEquals("~user" + SEP + "a" + SEP, FilenameUtils
0198:                        .normalize("~user/a/b/.."));
0199:                assertEquals("~user" + SEP + "", FilenameUtils
0200:                        .normalize("~user/a/b/../.."));
0201:                assertEquals(null, FilenameUtils
0202:                        .normalize("~user/a/b/../../.."));
0203:                assertEquals("~user" + SEP + "a" + SEP + "d", FilenameUtils
0204:                        .normalize("~user/a/b/../c/../d"));
0205:                assertEquals("~user" + SEP + "a" + SEP + "b" + SEP + "d",
0206:                        FilenameUtils.normalize("~user/a/b//d"));
0207:                assertEquals("~user" + SEP + "a" + SEP + "b" + SEP,
0208:                        FilenameUtils.normalize("~user/a/b/././."));
0209:                assertEquals("~user" + SEP + "a", FilenameUtils
0210:                        .normalize("~user/./a"));
0211:                assertEquals("~user" + SEP + "", FilenameUtils
0212:                        .normalize("~user/./"));
0213:                assertEquals("~user" + SEP + "", FilenameUtils
0214:                        .normalize("~user/."));
0215:                assertEquals(null, FilenameUtils.normalize("~user/../a"));
0216:                assertEquals(null, FilenameUtils.normalize("~user/.."));
0217:                assertEquals("~user" + SEP, FilenameUtils.normalize("~user/"));
0218:                assertEquals("~user" + SEP, FilenameUtils.normalize("~user"));
0219:
0220:                assertEquals("C:" + SEP + "a", FilenameUtils.normalize("C:/a"));
0221:                assertEquals("C:" + SEP + "a" + SEP, FilenameUtils
0222:                        .normalize("C:/a/"));
0223:                assertEquals("C:" + SEP + "a" + SEP + "c", FilenameUtils
0224:                        .normalize("C:/a/b/../c"));
0225:                assertEquals("C:" + SEP + "c", FilenameUtils
0226:                        .normalize("C:/a/b/../../c"));
0227:                assertEquals(null, FilenameUtils.normalize("C:/a/b/../../../c"));
0228:                assertEquals("C:" + SEP + "a" + SEP, FilenameUtils
0229:                        .normalize("C:/a/b/.."));
0230:                assertEquals("C:" + SEP + "", FilenameUtils
0231:                        .normalize("C:/a/b/../.."));
0232:                assertEquals(null, FilenameUtils.normalize("C:/a/b/../../.."));
0233:                assertEquals("C:" + SEP + "a" + SEP + "d", FilenameUtils
0234:                        .normalize("C:/a/b/../c/../d"));
0235:                assertEquals("C:" + SEP + "a" + SEP + "b" + SEP + "d",
0236:                        FilenameUtils.normalize("C:/a/b//d"));
0237:                assertEquals("C:" + SEP + "a" + SEP + "b" + SEP, FilenameUtils
0238:                        .normalize("C:/a/b/././."));
0239:                assertEquals("C:" + SEP + "a", FilenameUtils
0240:                        .normalize("C:/./a"));
0241:                assertEquals("C:" + SEP + "", FilenameUtils.normalize("C:/./"));
0242:                assertEquals("C:" + SEP + "", FilenameUtils.normalize("C:/."));
0243:                assertEquals(null, FilenameUtils.normalize("C:/../a"));
0244:                assertEquals(null, FilenameUtils.normalize("C:/.."));
0245:                assertEquals("C:" + SEP + "", FilenameUtils.normalize("C:/"));
0246:
0247:                assertEquals("C:" + "a", FilenameUtils.normalize("C:a"));
0248:                assertEquals("C:" + "a" + SEP, FilenameUtils.normalize("C:a/"));
0249:                assertEquals("C:" + "a" + SEP + "c", FilenameUtils
0250:                        .normalize("C:a/b/../c"));
0251:                assertEquals("C:" + "c", FilenameUtils
0252:                        .normalize("C:a/b/../../c"));
0253:                assertEquals(null, FilenameUtils.normalize("C:a/b/../../../c"));
0254:                assertEquals("C:" + "a" + SEP, FilenameUtils
0255:                        .normalize("C:a/b/.."));
0256:                assertEquals("C:" + "", FilenameUtils.normalize("C:a/b/../.."));
0257:                assertEquals(null, FilenameUtils.normalize("C:a/b/../../.."));
0258:                assertEquals("C:" + "a" + SEP + "d", FilenameUtils
0259:                        .normalize("C:a/b/../c/../d"));
0260:                assertEquals("C:" + "a" + SEP + "b" + SEP + "d", FilenameUtils
0261:                        .normalize("C:a/b//d"));
0262:                assertEquals("C:" + "a" + SEP + "b" + SEP, FilenameUtils
0263:                        .normalize("C:a/b/././."));
0264:                assertEquals("C:" + "a", FilenameUtils.normalize("C:./a"));
0265:                assertEquals("C:" + "", FilenameUtils.normalize("C:./"));
0266:                assertEquals("C:" + "", FilenameUtils.normalize("C:."));
0267:                assertEquals(null, FilenameUtils.normalize("C:../a"));
0268:                assertEquals(null, FilenameUtils.normalize("C:.."));
0269:                assertEquals("C:" + "", FilenameUtils.normalize("C:"));
0270:
0271:                assertEquals(SEP + SEP + "server" + SEP + "a", FilenameUtils
0272:                        .normalize("//server/a"));
0273:                assertEquals(SEP + SEP + "server" + SEP + "a" + SEP,
0274:                        FilenameUtils.normalize("//server/a/"));
0275:                assertEquals(SEP + SEP + "server" + SEP + "a" + SEP + "c",
0276:                        FilenameUtils.normalize("//server/a/b/../c"));
0277:                assertEquals(SEP + SEP + "server" + SEP + "c", FilenameUtils
0278:                        .normalize("//server/a/b/../../c"));
0279:                assertEquals(null, FilenameUtils
0280:                        .normalize("//server/a/b/../../../c"));
0281:                assertEquals(SEP + SEP + "server" + SEP + "a" + SEP,
0282:                        FilenameUtils.normalize("//server/a/b/.."));
0283:                assertEquals(SEP + SEP + "server" + SEP + "", FilenameUtils
0284:                        .normalize("//server/a/b/../.."));
0285:                assertEquals(null, FilenameUtils
0286:                        .normalize("//server/a/b/../../.."));
0287:                assertEquals(SEP + SEP + "server" + SEP + "a" + SEP + "d",
0288:                        FilenameUtils.normalize("//server/a/b/../c/../d"));
0289:                assertEquals(SEP + SEP + "server" + SEP + "a" + SEP + "b" + SEP
0290:                        + "d", FilenameUtils.normalize("//server/a/b//d"));
0291:                assertEquals(
0292:                        SEP + SEP + "server" + SEP + "a" + SEP + "b" + SEP,
0293:                        FilenameUtils.normalize("//server/a/b/././."));
0294:                assertEquals(SEP + SEP + "server" + SEP + "a", FilenameUtils
0295:                        .normalize("//server/./a"));
0296:                assertEquals(SEP + SEP + "server" + SEP + "", FilenameUtils
0297:                        .normalize("//server/./"));
0298:                assertEquals(SEP + SEP + "server" + SEP + "", FilenameUtils
0299:                        .normalize("//server/."));
0300:                assertEquals(null, FilenameUtils.normalize("//server/../a"));
0301:                assertEquals(null, FilenameUtils.normalize("//server/.."));
0302:                assertEquals(SEP + SEP + "server" + SEP + "", FilenameUtils
0303:                        .normalize("//server/"));
0304:            }
0305:
0306:            //-----------------------------------------------------------------------
0307:            public void testNormalizeNoEndSeparator() throws Exception {
0308:                assertEquals(null, FilenameUtils.normalizeNoEndSeparator(null));
0309:                assertEquals(null, FilenameUtils.normalizeNoEndSeparator(":"));
0310:                assertEquals(null, FilenameUtils
0311:                        .normalizeNoEndSeparator("1:\\a\\b\\c.txt"));
0312:                assertEquals(null, FilenameUtils.normalizeNoEndSeparator("1:"));
0313:                assertEquals(null, FilenameUtils.normalizeNoEndSeparator("1:a"));
0314:                assertEquals(null, FilenameUtils
0315:                        .normalizeNoEndSeparator("\\\\\\a\\b\\c.txt"));
0316:                assertEquals(null, FilenameUtils
0317:                        .normalizeNoEndSeparator("\\\\a"));
0318:
0319:                assertEquals("a" + SEP + "b" + SEP + "c.txt", FilenameUtils
0320:                        .normalizeNoEndSeparator("a\\b/c.txt"));
0321:                assertEquals("" + SEP + "a" + SEP + "b" + SEP + "c.txt",
0322:                        FilenameUtils.normalizeNoEndSeparator("\\a\\b/c.txt"));
0323:                assertEquals("C:" + SEP + "a" + SEP + "b" + SEP + "c.txt",
0324:                        FilenameUtils.normalizeNoEndSeparator("C:\\a\\b/c.txt"));
0325:                assertEquals("" + SEP + "" + SEP + "server" + SEP + "a" + SEP
0326:                        + "b" + SEP + "c.txt", FilenameUtils
0327:                        .normalizeNoEndSeparator("\\\\server\\a\\b/c.txt"));
0328:                assertEquals("~" + SEP + "a" + SEP + "b" + SEP + "c.txt",
0329:                        FilenameUtils.normalizeNoEndSeparator("~\\a\\b/c.txt"));
0330:                assertEquals("~user" + SEP + "a" + SEP + "b" + SEP + "c.txt",
0331:                        FilenameUtils
0332:                                .normalizeNoEndSeparator("~user\\a\\b/c.txt"));
0333:
0334:                assertEquals("a" + SEP + "c", FilenameUtils
0335:                        .normalizeNoEndSeparator("a/b/../c"));
0336:                assertEquals("c", FilenameUtils
0337:                        .normalizeNoEndSeparator("a/b/../../c"));
0338:                assertEquals("c", FilenameUtils
0339:                        .normalizeNoEndSeparator("a/b/../../c/"));
0340:                assertEquals(null, FilenameUtils
0341:                        .normalizeNoEndSeparator("a/b/../../../c"));
0342:                assertEquals("a", FilenameUtils
0343:                        .normalizeNoEndSeparator("a/b/.."));
0344:                assertEquals("a", FilenameUtils
0345:                        .normalizeNoEndSeparator("a/b/../"));
0346:                assertEquals("", FilenameUtils
0347:                        .normalizeNoEndSeparator("a/b/../.."));
0348:                assertEquals("", FilenameUtils
0349:                        .normalizeNoEndSeparator("a/b/../../"));
0350:                assertEquals(null, FilenameUtils
0351:                        .normalizeNoEndSeparator("a/b/../../.."));
0352:                assertEquals("a" + SEP + "d", FilenameUtils
0353:                        .normalizeNoEndSeparator("a/b/../c/../d"));
0354:                assertEquals("a" + SEP + "d", FilenameUtils
0355:                        .normalizeNoEndSeparator("a/b/../c/../d/"));
0356:                assertEquals("a" + SEP + "b" + SEP + "d", FilenameUtils
0357:                        .normalizeNoEndSeparator("a/b//d"));
0358:                assertEquals("a" + SEP + "b", FilenameUtils
0359:                        .normalizeNoEndSeparator("a/b/././."));
0360:                assertEquals("a" + SEP + "b", FilenameUtils
0361:                        .normalizeNoEndSeparator("a/b/./././"));
0362:                assertEquals("a", FilenameUtils.normalizeNoEndSeparator("./a/"));
0363:                assertEquals("a", FilenameUtils.normalizeNoEndSeparator("./a"));
0364:                assertEquals("", FilenameUtils.normalizeNoEndSeparator("./"));
0365:                assertEquals("", FilenameUtils.normalizeNoEndSeparator("."));
0366:                assertEquals(null, FilenameUtils
0367:                        .normalizeNoEndSeparator("../a"));
0368:                assertEquals(null, FilenameUtils.normalizeNoEndSeparator(".."));
0369:                assertEquals("", FilenameUtils.normalizeNoEndSeparator(""));
0370:
0371:                assertEquals(SEP + "a", FilenameUtils
0372:                        .normalizeNoEndSeparator("/a"));
0373:                assertEquals(SEP + "a", FilenameUtils
0374:                        .normalizeNoEndSeparator("/a/"));
0375:                assertEquals(SEP + "a" + SEP + "c", FilenameUtils
0376:                        .normalizeNoEndSeparator("/a/b/../c"));
0377:                assertEquals(SEP + "c", FilenameUtils
0378:                        .normalizeNoEndSeparator("/a/b/../../c"));
0379:                assertEquals(null, FilenameUtils
0380:                        .normalizeNoEndSeparator("/a/b/../../../c"));
0381:                assertEquals(SEP + "a", FilenameUtils
0382:                        .normalizeNoEndSeparator("/a/b/.."));
0383:                assertEquals(SEP + "", FilenameUtils
0384:                        .normalizeNoEndSeparator("/a/b/../.."));
0385:                assertEquals(null, FilenameUtils
0386:                        .normalizeNoEndSeparator("/a/b/../../.."));
0387:                assertEquals(SEP + "a" + SEP + "d", FilenameUtils
0388:                        .normalizeNoEndSeparator("/a/b/../c/../d"));
0389:                assertEquals(SEP + "a" + SEP + "b" + SEP + "d", FilenameUtils
0390:                        .normalizeNoEndSeparator("/a/b//d"));
0391:                assertEquals(SEP + "a" + SEP + "b", FilenameUtils
0392:                        .normalizeNoEndSeparator("/a/b/././."));
0393:                assertEquals(SEP + "a", FilenameUtils
0394:                        .normalizeNoEndSeparator("/./a"));
0395:                assertEquals(SEP + "", FilenameUtils
0396:                        .normalizeNoEndSeparator("/./"));
0397:                assertEquals(SEP + "", FilenameUtils
0398:                        .normalizeNoEndSeparator("/."));
0399:                assertEquals(null, FilenameUtils
0400:                        .normalizeNoEndSeparator("/../a"));
0401:                assertEquals(null, FilenameUtils.normalizeNoEndSeparator("/.."));
0402:                assertEquals(SEP + "", FilenameUtils
0403:                        .normalizeNoEndSeparator("/"));
0404:
0405:                assertEquals("~" + SEP + "a", FilenameUtils
0406:                        .normalizeNoEndSeparator("~/a"));
0407:                assertEquals("~" + SEP + "a", FilenameUtils
0408:                        .normalizeNoEndSeparator("~/a/"));
0409:                assertEquals("~" + SEP + "a" + SEP + "c", FilenameUtils
0410:                        .normalizeNoEndSeparator("~/a/b/../c"));
0411:                assertEquals("~" + SEP + "c", FilenameUtils
0412:                        .normalizeNoEndSeparator("~/a/b/../../c"));
0413:                assertEquals(null, FilenameUtils
0414:                        .normalizeNoEndSeparator("~/a/b/../../../c"));
0415:                assertEquals("~" + SEP + "a", FilenameUtils
0416:                        .normalizeNoEndSeparator("~/a/b/.."));
0417:                assertEquals("~" + SEP + "", FilenameUtils
0418:                        .normalizeNoEndSeparator("~/a/b/../.."));
0419:                assertEquals(null, FilenameUtils
0420:                        .normalizeNoEndSeparator("~/a/b/../../.."));
0421:                assertEquals("~" + SEP + "a" + SEP + "d", FilenameUtils
0422:                        .normalizeNoEndSeparator("~/a/b/../c/../d"));
0423:                assertEquals("~" + SEP + "a" + SEP + "b" + SEP + "d",
0424:                        FilenameUtils.normalizeNoEndSeparator("~/a/b//d"));
0425:                assertEquals("~" + SEP + "a" + SEP + "b", FilenameUtils
0426:                        .normalizeNoEndSeparator("~/a/b/././."));
0427:                assertEquals("~" + SEP + "a", FilenameUtils
0428:                        .normalizeNoEndSeparator("~/./a"));
0429:                assertEquals("~" + SEP, FilenameUtils
0430:                        .normalizeNoEndSeparator("~/./"));
0431:                assertEquals("~" + SEP, FilenameUtils
0432:                        .normalizeNoEndSeparator("~/."));
0433:                assertEquals(null, FilenameUtils
0434:                        .normalizeNoEndSeparator("~/../a"));
0435:                assertEquals(null, FilenameUtils
0436:                        .normalizeNoEndSeparator("~/.."));
0437:                assertEquals("~" + SEP, FilenameUtils
0438:                        .normalizeNoEndSeparator("~/"));
0439:                assertEquals("~" + SEP, FilenameUtils
0440:                        .normalizeNoEndSeparator("~"));
0441:
0442:                assertEquals("~user" + SEP + "a", FilenameUtils
0443:                        .normalizeNoEndSeparator("~user/a"));
0444:                assertEquals("~user" + SEP + "a", FilenameUtils
0445:                        .normalizeNoEndSeparator("~user/a/"));
0446:                assertEquals("~user" + SEP + "a" + SEP + "c", FilenameUtils
0447:                        .normalizeNoEndSeparator("~user/a/b/../c"));
0448:                assertEquals("~user" + SEP + "c", FilenameUtils
0449:                        .normalizeNoEndSeparator("~user/a/b/../../c"));
0450:                assertEquals(null, FilenameUtils
0451:                        .normalizeNoEndSeparator("~user/a/b/../../../c"));
0452:                assertEquals("~user" + SEP + "a", FilenameUtils
0453:                        .normalizeNoEndSeparator("~user/a/b/.."));
0454:                assertEquals("~user" + SEP + "", FilenameUtils
0455:                        .normalizeNoEndSeparator("~user/a/b/../.."));
0456:                assertEquals(null, FilenameUtils
0457:                        .normalizeNoEndSeparator("~user/a/b/../../.."));
0458:                assertEquals("~user" + SEP + "a" + SEP + "d", FilenameUtils
0459:                        .normalizeNoEndSeparator("~user/a/b/../c/../d"));
0460:                assertEquals("~user" + SEP + "a" + SEP + "b" + SEP + "d",
0461:                        FilenameUtils.normalizeNoEndSeparator("~user/a/b//d"));
0462:                assertEquals("~user" + SEP + "a" + SEP + "b", FilenameUtils
0463:                        .normalizeNoEndSeparator("~user/a/b/././."));
0464:                assertEquals("~user" + SEP + "a", FilenameUtils
0465:                        .normalizeNoEndSeparator("~user/./a"));
0466:                assertEquals("~user" + SEP + "", FilenameUtils
0467:                        .normalizeNoEndSeparator("~user/./"));
0468:                assertEquals("~user" + SEP + "", FilenameUtils
0469:                        .normalizeNoEndSeparator("~user/."));
0470:                assertEquals(null, FilenameUtils
0471:                        .normalizeNoEndSeparator("~user/../a"));
0472:                assertEquals(null, FilenameUtils
0473:                        .normalizeNoEndSeparator("~user/.."));
0474:                assertEquals("~user" + SEP, FilenameUtils
0475:                        .normalizeNoEndSeparator("~user/"));
0476:                assertEquals("~user" + SEP, FilenameUtils
0477:                        .normalizeNoEndSeparator("~user"));
0478:
0479:                assertEquals("C:" + SEP + "a", FilenameUtils
0480:                        .normalizeNoEndSeparator("C:/a"));
0481:                assertEquals("C:" + SEP + "a", FilenameUtils
0482:                        .normalizeNoEndSeparator("C:/a/"));
0483:                assertEquals("C:" + SEP + "a" + SEP + "c", FilenameUtils
0484:                        .normalizeNoEndSeparator("C:/a/b/../c"));
0485:                assertEquals("C:" + SEP + "c", FilenameUtils
0486:                        .normalizeNoEndSeparator("C:/a/b/../../c"));
0487:                assertEquals(null, FilenameUtils
0488:                        .normalizeNoEndSeparator("C:/a/b/../../../c"));
0489:                assertEquals("C:" + SEP + "a", FilenameUtils
0490:                        .normalizeNoEndSeparator("C:/a/b/.."));
0491:                assertEquals("C:" + SEP + "", FilenameUtils
0492:                        .normalizeNoEndSeparator("C:/a/b/../.."));
0493:                assertEquals(null, FilenameUtils
0494:                        .normalizeNoEndSeparator("C:/a/b/../../.."));
0495:                assertEquals("C:" + SEP + "a" + SEP + "d", FilenameUtils
0496:                        .normalizeNoEndSeparator("C:/a/b/../c/../d"));
0497:                assertEquals("C:" + SEP + "a" + SEP + "b" + SEP + "d",
0498:                        FilenameUtils.normalizeNoEndSeparator("C:/a/b//d"));
0499:                assertEquals("C:" + SEP + "a" + SEP + "b", FilenameUtils
0500:                        .normalizeNoEndSeparator("C:/a/b/././."));
0501:                assertEquals("C:" + SEP + "a", FilenameUtils
0502:                        .normalizeNoEndSeparator("C:/./a"));
0503:                assertEquals("C:" + SEP + "", FilenameUtils
0504:                        .normalizeNoEndSeparator("C:/./"));
0505:                assertEquals("C:" + SEP + "", FilenameUtils
0506:                        .normalizeNoEndSeparator("C:/."));
0507:                assertEquals(null, FilenameUtils
0508:                        .normalizeNoEndSeparator("C:/../a"));
0509:                assertEquals(null, FilenameUtils
0510:                        .normalizeNoEndSeparator("C:/.."));
0511:                assertEquals("C:" + SEP + "", FilenameUtils
0512:                        .normalizeNoEndSeparator("C:/"));
0513:
0514:                assertEquals("C:" + "a", FilenameUtils
0515:                        .normalizeNoEndSeparator("C:a"));
0516:                assertEquals("C:" + "a", FilenameUtils
0517:                        .normalizeNoEndSeparator("C:a/"));
0518:                assertEquals("C:" + "a" + SEP + "c", FilenameUtils
0519:                        .normalizeNoEndSeparator("C:a/b/../c"));
0520:                assertEquals("C:" + "c", FilenameUtils
0521:                        .normalizeNoEndSeparator("C:a/b/../../c"));
0522:                assertEquals(null, FilenameUtils
0523:                        .normalizeNoEndSeparator("C:a/b/../../../c"));
0524:                assertEquals("C:" + "a", FilenameUtils
0525:                        .normalizeNoEndSeparator("C:a/b/.."));
0526:                assertEquals("C:" + "", FilenameUtils
0527:                        .normalizeNoEndSeparator("C:a/b/../.."));
0528:                assertEquals(null, FilenameUtils
0529:                        .normalizeNoEndSeparator("C:a/b/../../.."));
0530:                assertEquals("C:" + "a" + SEP + "d", FilenameUtils
0531:                        .normalizeNoEndSeparator("C:a/b/../c/../d"));
0532:                assertEquals("C:" + "a" + SEP + "b" + SEP + "d", FilenameUtils
0533:                        .normalizeNoEndSeparator("C:a/b//d"));
0534:                assertEquals("C:" + "a" + SEP + "b", FilenameUtils
0535:                        .normalizeNoEndSeparator("C:a/b/././."));
0536:                assertEquals("C:" + "a", FilenameUtils
0537:                        .normalizeNoEndSeparator("C:./a"));
0538:                assertEquals("C:" + "", FilenameUtils
0539:                        .normalizeNoEndSeparator("C:./"));
0540:                assertEquals("C:" + "", FilenameUtils
0541:                        .normalizeNoEndSeparator("C:."));
0542:                assertEquals(null, FilenameUtils
0543:                        .normalizeNoEndSeparator("C:../a"));
0544:                assertEquals(null, FilenameUtils
0545:                        .normalizeNoEndSeparator("C:.."));
0546:                assertEquals("C:" + "", FilenameUtils
0547:                        .normalizeNoEndSeparator("C:"));
0548:
0549:                assertEquals(SEP + SEP + "server" + SEP + "a", FilenameUtils
0550:                        .normalizeNoEndSeparator("//server/a"));
0551:                assertEquals(SEP + SEP + "server" + SEP + "a", FilenameUtils
0552:                        .normalizeNoEndSeparator("//server/a/"));
0553:                assertEquals(SEP + SEP + "server" + SEP + "a" + SEP + "c",
0554:                        FilenameUtils
0555:                                .normalizeNoEndSeparator("//server/a/b/../c"));
0556:                assertEquals(SEP + SEP + "server" + SEP + "c", FilenameUtils
0557:                        .normalizeNoEndSeparator("//server/a/b/../../c"));
0558:                assertEquals(null, FilenameUtils
0559:                        .normalizeNoEndSeparator("//server/a/b/../../../c"));
0560:                assertEquals(SEP + SEP + "server" + SEP + "a", FilenameUtils
0561:                        .normalizeNoEndSeparator("//server/a/b/.."));
0562:                assertEquals(SEP + SEP + "server" + SEP + "", FilenameUtils
0563:                        .normalizeNoEndSeparator("//server/a/b/../.."));
0564:                assertEquals(null, FilenameUtils
0565:                        .normalizeNoEndSeparator("//server/a/b/../../.."));
0566:                assertEquals(
0567:                        SEP + SEP + "server" + SEP + "a" + SEP + "d",
0568:                        FilenameUtils
0569:                                .normalizeNoEndSeparator("//server/a/b/../c/../d"));
0570:                assertEquals(SEP + SEP + "server" + SEP + "a" + SEP + "b" + SEP
0571:                        + "d", FilenameUtils
0572:                        .normalizeNoEndSeparator("//server/a/b//d"));
0573:                assertEquals(SEP + SEP + "server" + SEP + "a" + SEP + "b",
0574:                        FilenameUtils
0575:                                .normalizeNoEndSeparator("//server/a/b/././."));
0576:                assertEquals(SEP + SEP + "server" + SEP + "a", FilenameUtils
0577:                        .normalizeNoEndSeparator("//server/./a"));
0578:                assertEquals(SEP + SEP + "server" + SEP + "", FilenameUtils
0579:                        .normalizeNoEndSeparator("//server/./"));
0580:                assertEquals(SEP + SEP + "server" + SEP + "", FilenameUtils
0581:                        .normalizeNoEndSeparator("//server/."));
0582:                assertEquals(null, FilenameUtils
0583:                        .normalizeNoEndSeparator("//server/../a"));
0584:                assertEquals(null, FilenameUtils
0585:                        .normalizeNoEndSeparator("//server/.."));
0586:                assertEquals(SEP + SEP + "server" + SEP + "", FilenameUtils
0587:                        .normalizeNoEndSeparator("//server/"));
0588:            }
0589:
0590:            //-----------------------------------------------------------------------
0591:            public void testConcat() {
0592:                assertEquals(null, FilenameUtils.concat("", null));
0593:                assertEquals(null, FilenameUtils.concat(null, null));
0594:                assertEquals(null, FilenameUtils.concat(null, ""));
0595:                assertEquals(null, FilenameUtils.concat(null, "a"));
0596:                assertEquals(SEP + "a", FilenameUtils.concat(null, "/a"));
0597:
0598:                assertEquals(null, FilenameUtils.concat("", ":")); // invalid prefix
0599:                assertEquals(null, FilenameUtils.concat(":", "")); // invalid prefix
0600:
0601:                assertEquals("f" + SEP, FilenameUtils.concat("", "f/"));
0602:                assertEquals("f", FilenameUtils.concat("", "f"));
0603:                assertEquals("a" + SEP + "f" + SEP, FilenameUtils.concat("a/",
0604:                        "f/"));
0605:                assertEquals("a" + SEP + "f", FilenameUtils.concat("a", "f"));
0606:                assertEquals("a" + SEP + "b" + SEP + "f" + SEP, FilenameUtils
0607:                        .concat("a/b/", "f/"));
0608:                assertEquals("a" + SEP + "b" + SEP + "f", FilenameUtils.concat(
0609:                        "a/b", "f"));
0610:
0611:                assertEquals("a" + SEP + "f" + SEP, FilenameUtils.concat(
0612:                        "a/b/", "../f/"));
0613:                assertEquals("a" + SEP + "f", FilenameUtils.concat("a/b",
0614:                        "../f"));
0615:                assertEquals("a" + SEP + "c" + SEP + "g" + SEP, FilenameUtils
0616:                        .concat("a/b/../c/", "f/../g/"));
0617:                assertEquals("a" + SEP + "c" + SEP + "g", FilenameUtils.concat(
0618:                        "a/b/../c", "f/../g"));
0619:
0620:                assertEquals("a" + SEP + "c.txt" + SEP + "f", FilenameUtils
0621:                        .concat("a/c.txt", "f"));
0622:
0623:                assertEquals(SEP + "f" + SEP, FilenameUtils.concat("", "/f/"));
0624:                assertEquals(SEP + "f", FilenameUtils.concat("", "/f"));
0625:                assertEquals(SEP + "f" + SEP, FilenameUtils.concat("a/", "/f/"));
0626:                assertEquals(SEP + "f", FilenameUtils.concat("a", "/f"));
0627:
0628:                assertEquals(SEP + "c" + SEP + "d", FilenameUtils.concat(
0629:                        "a/b/", "/c/d"));
0630:                assertEquals("C:c" + SEP + "d", FilenameUtils.concat("a/b/",
0631:                        "C:c/d"));
0632:                assertEquals("C:" + SEP + "c" + SEP + "d", FilenameUtils
0633:                        .concat("a/b/", "C:/c/d"));
0634:                assertEquals("~" + SEP + "c" + SEP + "d", FilenameUtils.concat(
0635:                        "a/b/", "~/c/d"));
0636:                assertEquals("~user" + SEP + "c" + SEP + "d", FilenameUtils
0637:                        .concat("a/b/", "~user/c/d"));
0638:                assertEquals("~" + SEP, FilenameUtils.concat("a/b/", "~"));
0639:                assertEquals("~user" + SEP, FilenameUtils.concat("a/b/",
0640:                        "~user"));
0641:            }
0642:
0643:            //-----------------------------------------------------------------------
0644:            public void testSeparatorsToUnix() {
0645:                assertEquals(null, FilenameUtils.separatorsToUnix(null));
0646:                assertEquals("/a/b/c", FilenameUtils.separatorsToUnix("/a/b/c"));
0647:                assertEquals("/a/b/c.txt", FilenameUtils
0648:                        .separatorsToUnix("/a/b/c.txt"));
0649:                assertEquals("/a/b/c", FilenameUtils
0650:                        .separatorsToUnix("/a/b\\c"));
0651:                assertEquals("/a/b/c", FilenameUtils
0652:                        .separatorsToUnix("\\a\\b\\c"));
0653:                assertEquals("D:/a/b/c", FilenameUtils
0654:                        .separatorsToUnix("D:\\a\\b\\c"));
0655:            }
0656:
0657:            public void testSeparatorsToWindows() {
0658:                assertEquals(null, FilenameUtils.separatorsToWindows(null));
0659:                assertEquals("\\a\\b\\c", FilenameUtils
0660:                        .separatorsToWindows("\\a\\b\\c"));
0661:                assertEquals("\\a\\b\\c.txt", FilenameUtils
0662:                        .separatorsToWindows("\\a\\b\\c.txt"));
0663:                assertEquals("\\a\\b\\c", FilenameUtils
0664:                        .separatorsToWindows("\\a\\b/c"));
0665:                assertEquals("\\a\\b\\c", FilenameUtils
0666:                        .separatorsToWindows("/a/b/c"));
0667:                assertEquals("D:\\a\\b\\c", FilenameUtils
0668:                        .separatorsToWindows("D:/a/b/c"));
0669:            }
0670:
0671:            public void testSeparatorsToSystem() {
0672:                if (WINDOWS) {
0673:                    assertEquals(null, FilenameUtils.separatorsToSystem(null));
0674:                    assertEquals("\\a\\b\\c", FilenameUtils
0675:                            .separatorsToSystem("\\a\\b\\c"));
0676:                    assertEquals("\\a\\b\\c.txt", FilenameUtils
0677:                            .separatorsToSystem("\\a\\b\\c.txt"));
0678:                    assertEquals("\\a\\b\\c", FilenameUtils
0679:                            .separatorsToSystem("\\a\\b/c"));
0680:                    assertEquals("\\a\\b\\c", FilenameUtils
0681:                            .separatorsToSystem("/a/b/c"));
0682:                    assertEquals("D:\\a\\b\\c", FilenameUtils
0683:                            .separatorsToSystem("D:/a/b/c"));
0684:                } else {
0685:                    assertEquals(null, FilenameUtils.separatorsToSystem(null));
0686:                    assertEquals("/a/b/c", FilenameUtils
0687:                            .separatorsToSystem("/a/b/c"));
0688:                    assertEquals("/a/b/c.txt", FilenameUtils
0689:                            .separatorsToSystem("/a/b/c.txt"));
0690:                    assertEquals("/a/b/c", FilenameUtils
0691:                            .separatorsToSystem("/a/b\\c"));
0692:                    assertEquals("/a/b/c", FilenameUtils
0693:                            .separatorsToSystem("\\a\\b\\c"));
0694:                    assertEquals("D:/a/b/c", FilenameUtils
0695:                            .separatorsToSystem("D:\\a\\b\\c"));
0696:                }
0697:            }
0698:
0699:            //-----------------------------------------------------------------------
0700:            public void testGetPrefixLength() {
0701:                assertEquals(-1, FilenameUtils.getPrefixLength(null));
0702:                assertEquals(-1, FilenameUtils.getPrefixLength(":"));
0703:                assertEquals(-1, FilenameUtils
0704:                        .getPrefixLength("1:\\a\\b\\c.txt"));
0705:                assertEquals(-1, FilenameUtils.getPrefixLength("1:"));
0706:                assertEquals(-1, FilenameUtils.getPrefixLength("1:a"));
0707:                assertEquals(-1, FilenameUtils
0708:                        .getPrefixLength("\\\\\\a\\b\\c.txt"));
0709:                assertEquals(-1, FilenameUtils.getPrefixLength("\\\\a"));
0710:
0711:                assertEquals(0, FilenameUtils.getPrefixLength(""));
0712:                assertEquals(1, FilenameUtils.getPrefixLength("\\"));
0713:                assertEquals(2, FilenameUtils.getPrefixLength("C:"));
0714:                assertEquals(3, FilenameUtils.getPrefixLength("C:\\"));
0715:                assertEquals(9, FilenameUtils.getPrefixLength("//server/"));
0716:                assertEquals(2, FilenameUtils.getPrefixLength("~"));
0717:                assertEquals(2, FilenameUtils.getPrefixLength("~/"));
0718:                assertEquals(6, FilenameUtils.getPrefixLength("~user"));
0719:                assertEquals(6, FilenameUtils.getPrefixLength("~user/"));
0720:
0721:                assertEquals(0, FilenameUtils.getPrefixLength("a\\b\\c.txt"));
0722:                assertEquals(1, FilenameUtils.getPrefixLength("\\a\\b\\c.txt"));
0723:                assertEquals(2, FilenameUtils.getPrefixLength("C:a\\b\\c.txt"));
0724:                assertEquals(3, FilenameUtils
0725:                        .getPrefixLength("C:\\a\\b\\c.txt"));
0726:                assertEquals(9, FilenameUtils
0727:                        .getPrefixLength("\\\\server\\a\\b\\c.txt"));
0728:
0729:                assertEquals(0, FilenameUtils.getPrefixLength("a/b/c.txt"));
0730:                assertEquals(1, FilenameUtils.getPrefixLength("/a/b/c.txt"));
0731:                assertEquals(3, FilenameUtils.getPrefixLength("C:/a/b/c.txt"));
0732:                assertEquals(9, FilenameUtils
0733:                        .getPrefixLength("//server/a/b/c.txt"));
0734:                assertEquals(2, FilenameUtils.getPrefixLength("~/a/b/c.txt"));
0735:                assertEquals(6, FilenameUtils
0736:                        .getPrefixLength("~user/a/b/c.txt"));
0737:
0738:                assertEquals(0, FilenameUtils.getPrefixLength("a\\b\\c.txt"));
0739:                assertEquals(1, FilenameUtils.getPrefixLength("\\a\\b\\c.txt"));
0740:                assertEquals(2, FilenameUtils.getPrefixLength("~\\a\\b\\c.txt"));
0741:                assertEquals(6, FilenameUtils
0742:                        .getPrefixLength("~user\\a\\b\\c.txt"));
0743:            }
0744:
0745:            public void testIndexOfLastSeparator() {
0746:                assertEquals(-1, FilenameUtils.indexOfLastSeparator(null));
0747:                assertEquals(-1, FilenameUtils
0748:                        .indexOfLastSeparator("noseperator.inthispath"));
0749:                assertEquals(3, FilenameUtils.indexOfLastSeparator("a/b/c"));
0750:                assertEquals(3, FilenameUtils.indexOfLastSeparator("a\\b\\c"));
0751:            }
0752:
0753:            public void testIndexOfExtension() {
0754:                assertEquals(-1, FilenameUtils.indexOfExtension(null));
0755:                assertEquals(-1, FilenameUtils.indexOfExtension("file"));
0756:                assertEquals(4, FilenameUtils.indexOfExtension("file.txt"));
0757:                assertEquals(13, FilenameUtils
0758:                        .indexOfExtension("a.txt/b.txt/c.txt"));
0759:                assertEquals(-1, FilenameUtils.indexOfExtension("a/b/c"));
0760:                assertEquals(-1, FilenameUtils.indexOfExtension("a\\b\\c"));
0761:                assertEquals(-1, FilenameUtils
0762:                        .indexOfExtension("a/b.notextension/c"));
0763:                assertEquals(-1, FilenameUtils
0764:                        .indexOfExtension("a\\b.notextension\\c"));
0765:            }
0766:
0767:            //-----------------------------------------------------------------------
0768:            public void testGetPrefix() {
0769:                assertEquals(null, FilenameUtils.getPrefix(null));
0770:                assertEquals(null, FilenameUtils.getPrefix(":"));
0771:                assertEquals(null, FilenameUtils.getPrefix("1:\\a\\b\\c.txt"));
0772:                assertEquals(null, FilenameUtils.getPrefix("1:"));
0773:                assertEquals(null, FilenameUtils.getPrefix("1:a"));
0774:                assertEquals(null, FilenameUtils.getPrefix("\\\\\\a\\b\\c.txt"));
0775:                assertEquals(null, FilenameUtils.getPrefix("\\\\a"));
0776:
0777:                assertEquals("", FilenameUtils.getPrefix(""));
0778:                assertEquals("\\", FilenameUtils.getPrefix("\\"));
0779:                assertEquals("C:", FilenameUtils.getPrefix("C:"));
0780:                assertEquals("C:\\", FilenameUtils.getPrefix("C:\\"));
0781:                assertEquals("//server/", FilenameUtils.getPrefix("//server/"));
0782:                assertEquals("~/", FilenameUtils.getPrefix("~"));
0783:                assertEquals("~/", FilenameUtils.getPrefix("~/"));
0784:                assertEquals("~user/", FilenameUtils.getPrefix("~user"));
0785:                assertEquals("~user/", FilenameUtils.getPrefix("~user/"));
0786:
0787:                assertEquals("", FilenameUtils.getPrefix("a\\b\\c.txt"));
0788:                assertEquals("\\", FilenameUtils.getPrefix("\\a\\b\\c.txt"));
0789:                assertEquals("C:\\", FilenameUtils.getPrefix("C:\\a\\b\\c.txt"));
0790:                assertEquals("\\\\server\\", FilenameUtils
0791:                        .getPrefix("\\\\server\\a\\b\\c.txt"));
0792:
0793:                assertEquals("", FilenameUtils.getPrefix("a/b/c.txt"));
0794:                assertEquals("/", FilenameUtils.getPrefix("/a/b/c.txt"));
0795:                assertEquals("C:/", FilenameUtils.getPrefix("C:/a/b/c.txt"));
0796:                assertEquals("//server/", FilenameUtils
0797:                        .getPrefix("//server/a/b/c.txt"));
0798:                assertEquals("~/", FilenameUtils.getPrefix("~/a/b/c.txt"));
0799:                assertEquals("~user/", FilenameUtils
0800:                        .getPrefix("~user/a/b/c.txt"));
0801:
0802:                assertEquals("", FilenameUtils.getPrefix("a\\b\\c.txt"));
0803:                assertEquals("\\", FilenameUtils.getPrefix("\\a\\b\\c.txt"));
0804:                assertEquals("~\\", FilenameUtils.getPrefix("~\\a\\b\\c.txt"));
0805:                assertEquals("~user\\", FilenameUtils
0806:                        .getPrefix("~user\\a\\b\\c.txt"));
0807:            }
0808:
0809:            public void testGetPath() {
0810:                assertEquals(null, FilenameUtils.getPath(null));
0811:                assertEquals("", FilenameUtils
0812:                        .getPath("noseperator.inthispath"));
0813:                assertEquals("a/b/", FilenameUtils.getPath("a/b/c.txt"));
0814:                assertEquals("a/b/", FilenameUtils.getPath("a/b/c"));
0815:                assertEquals("a/b/c/", FilenameUtils.getPath("a/b/c/"));
0816:                assertEquals("a\\b\\", FilenameUtils.getPath("a\\b\\c"));
0817:
0818:                assertEquals(null, FilenameUtils.getPath(":"));
0819:                assertEquals(null, FilenameUtils.getPath("1:/a/b/c.txt"));
0820:                assertEquals(null, FilenameUtils.getPath("1:"));
0821:                assertEquals(null, FilenameUtils.getPath("1:a"));
0822:                assertEquals(null, FilenameUtils.getPath("///a/b/c.txt"));
0823:                assertEquals(null, FilenameUtils.getPath("//a"));
0824:
0825:                assertEquals("", FilenameUtils.getPath(""));
0826:                assertEquals("", FilenameUtils.getPath("C:"));
0827:                assertEquals("", FilenameUtils.getPath("C:/"));
0828:                assertEquals("", FilenameUtils.getPath("//server/"));
0829:                assertEquals("", FilenameUtils.getPath("~"));
0830:                assertEquals("", FilenameUtils.getPath("~/"));
0831:                assertEquals("", FilenameUtils.getPath("~user"));
0832:                assertEquals("", FilenameUtils.getPath("~user/"));
0833:
0834:                assertEquals("a/b/", FilenameUtils.getPath("a/b/c.txt"));
0835:                assertEquals("a/b/", FilenameUtils.getPath("/a/b/c.txt"));
0836:                assertEquals("", FilenameUtils.getPath("C:a"));
0837:                assertEquals("a/b/", FilenameUtils.getPath("C:a/b/c.txt"));
0838:                assertEquals("a/b/", FilenameUtils.getPath("C:/a/b/c.txt"));
0839:                assertEquals("a/b/", FilenameUtils
0840:                        .getPath("//server/a/b/c.txt"));
0841:                assertEquals("a/b/", FilenameUtils.getPath("~/a/b/c.txt"));
0842:                assertEquals("a/b/", FilenameUtils.getPath("~user/a/b/c.txt"));
0843:            }
0844:
0845:            public void testGetPathNoEndSeparator() {
0846:                assertEquals(null, FilenameUtils.getPath(null));
0847:                assertEquals("", FilenameUtils
0848:                        .getPath("noseperator.inthispath"));
0849:                assertEquals("a/b", FilenameUtils
0850:                        .getPathNoEndSeparator("a/b/c.txt"));
0851:                assertEquals("a/b", FilenameUtils
0852:                        .getPathNoEndSeparator("a/b/c"));
0853:                assertEquals("a/b/c", FilenameUtils
0854:                        .getPathNoEndSeparator("a/b/c/"));
0855:                assertEquals("a\\b", FilenameUtils
0856:                        .getPathNoEndSeparator("a\\b\\c"));
0857:
0858:                assertEquals(null, FilenameUtils.getPathNoEndSeparator(":"));
0859:                assertEquals(null, FilenameUtils
0860:                        .getPathNoEndSeparator("1:/a/b/c.txt"));
0861:                assertEquals(null, FilenameUtils.getPathNoEndSeparator("1:"));
0862:                assertEquals(null, FilenameUtils.getPathNoEndSeparator("1:a"));
0863:                assertEquals(null, FilenameUtils
0864:                        .getPathNoEndSeparator("///a/b/c.txt"));
0865:                assertEquals(null, FilenameUtils.getPathNoEndSeparator("//a"));
0866:
0867:                assertEquals("", FilenameUtils.getPathNoEndSeparator(""));
0868:                assertEquals("", FilenameUtils.getPathNoEndSeparator("C:"));
0869:                assertEquals("", FilenameUtils.getPathNoEndSeparator("C:/"));
0870:                assertEquals("", FilenameUtils
0871:                        .getPathNoEndSeparator("//server/"));
0872:                assertEquals("", FilenameUtils.getPathNoEndSeparator("~"));
0873:                assertEquals("", FilenameUtils.getPathNoEndSeparator("~/"));
0874:                assertEquals("", FilenameUtils.getPathNoEndSeparator("~user"));
0875:                assertEquals("", FilenameUtils.getPathNoEndSeparator("~user/"));
0876:
0877:                assertEquals("a/b", FilenameUtils
0878:                        .getPathNoEndSeparator("a/b/c.txt"));
0879:                assertEquals("a/b", FilenameUtils
0880:                        .getPathNoEndSeparator("/a/b/c.txt"));
0881:                assertEquals("", FilenameUtils.getPathNoEndSeparator("C:a"));
0882:                assertEquals("a/b", FilenameUtils
0883:                        .getPathNoEndSeparator("C:a/b/c.txt"));
0884:                assertEquals("a/b", FilenameUtils
0885:                        .getPathNoEndSeparator("C:/a/b/c.txt"));
0886:                assertEquals("a/b", FilenameUtils
0887:                        .getPathNoEndSeparator("//server/a/b/c.txt"));
0888:                assertEquals("a/b", FilenameUtils
0889:                        .getPathNoEndSeparator("~/a/b/c.txt"));
0890:                assertEquals("a/b", FilenameUtils
0891:                        .getPathNoEndSeparator("~user/a/b/c.txt"));
0892:            }
0893:
0894:            public void testGetFullPath() {
0895:                assertEquals(null, FilenameUtils.getFullPath(null));
0896:                assertEquals("", FilenameUtils
0897:                        .getFullPath("noseperator.inthispath"));
0898:                assertEquals("a/b/", FilenameUtils.getFullPath("a/b/c.txt"));
0899:                assertEquals("a/b/", FilenameUtils.getFullPath("a/b/c"));
0900:                assertEquals("a/b/c/", FilenameUtils.getFullPath("a/b/c/"));
0901:                assertEquals("a\\b\\", FilenameUtils.getFullPath("a\\b\\c"));
0902:
0903:                assertEquals(null, FilenameUtils.getFullPath(":"));
0904:                assertEquals(null, FilenameUtils.getFullPath("1:/a/b/c.txt"));
0905:                assertEquals(null, FilenameUtils.getFullPath("1:"));
0906:                assertEquals(null, FilenameUtils.getFullPath("1:a"));
0907:                assertEquals(null, FilenameUtils.getFullPath("///a/b/c.txt"));
0908:                assertEquals(null, FilenameUtils.getFullPath("//a"));
0909:
0910:                assertEquals("", FilenameUtils.getFullPath(""));
0911:                assertEquals("C:", FilenameUtils.getFullPath("C:"));
0912:                assertEquals("C:/", FilenameUtils.getFullPath("C:/"));
0913:                assertEquals("//server/", FilenameUtils
0914:                        .getFullPath("//server/"));
0915:                assertEquals("~/", FilenameUtils.getFullPath("~"));
0916:                assertEquals("~/", FilenameUtils.getFullPath("~/"));
0917:                assertEquals("~user/", FilenameUtils.getFullPath("~user"));
0918:                assertEquals("~user/", FilenameUtils.getFullPath("~user/"));
0919:
0920:                assertEquals("a/b/", FilenameUtils.getFullPath("a/b/c.txt"));
0921:                assertEquals("/a/b/", FilenameUtils.getFullPath("/a/b/c.txt"));
0922:                assertEquals("C:", FilenameUtils.getFullPath("C:a"));
0923:                assertEquals("C:a/b/", FilenameUtils.getFullPath("C:a/b/c.txt"));
0924:                assertEquals("C:/a/b/", FilenameUtils
0925:                        .getFullPath("C:/a/b/c.txt"));
0926:                assertEquals("//server/a/b/", FilenameUtils
0927:                        .getFullPath("//server/a/b/c.txt"));
0928:                assertEquals("~/a/b/", FilenameUtils.getFullPath("~/a/b/c.txt"));
0929:                assertEquals("~user/a/b/", FilenameUtils
0930:                        .getFullPath("~user/a/b/c.txt"));
0931:            }
0932:
0933:            public void testGetFullPathNoEndSeparator() {
0934:                assertEquals(null, FilenameUtils
0935:                        .getFullPathNoEndSeparator(null));
0936:                assertEquals("", FilenameUtils
0937:                        .getFullPathNoEndSeparator("noseperator.inthispath"));
0938:                assertEquals("a/b", FilenameUtils
0939:                        .getFullPathNoEndSeparator("a/b/c.txt"));
0940:                assertEquals("a/b", FilenameUtils
0941:                        .getFullPathNoEndSeparator("a/b/c"));
0942:                assertEquals("a/b/c", FilenameUtils
0943:                        .getFullPathNoEndSeparator("a/b/c/"));
0944:                assertEquals("a\\b", FilenameUtils
0945:                        .getFullPathNoEndSeparator("a\\b\\c"));
0946:
0947:                assertEquals(null, FilenameUtils.getFullPathNoEndSeparator(":"));
0948:                assertEquals(null, FilenameUtils
0949:                        .getFullPathNoEndSeparator("1:/a/b/c.txt"));
0950:                assertEquals(null, FilenameUtils
0951:                        .getFullPathNoEndSeparator("1:"));
0952:                assertEquals(null, FilenameUtils
0953:                        .getFullPathNoEndSeparator("1:a"));
0954:                assertEquals(null, FilenameUtils
0955:                        .getFullPathNoEndSeparator("///a/b/c.txt"));
0956:                assertEquals(null, FilenameUtils
0957:                        .getFullPathNoEndSeparator("//a"));
0958:
0959:                assertEquals("", FilenameUtils.getFullPathNoEndSeparator(""));
0960:                assertEquals("C:", FilenameUtils
0961:                        .getFullPathNoEndSeparator("C:"));
0962:                assertEquals("C:/", FilenameUtils
0963:                        .getFullPathNoEndSeparator("C:/"));
0964:                assertEquals("//server/", FilenameUtils
0965:                        .getFullPathNoEndSeparator("//server/"));
0966:                assertEquals("~", FilenameUtils.getFullPathNoEndSeparator("~"));
0967:                assertEquals("~/", FilenameUtils
0968:                        .getFullPathNoEndSeparator("~/"));
0969:                assertEquals("~user", FilenameUtils
0970:                        .getFullPathNoEndSeparator("~user"));
0971:                assertEquals("~user/", FilenameUtils
0972:                        .getFullPathNoEndSeparator("~user/"));
0973:
0974:                assertEquals("a/b", FilenameUtils
0975:                        .getFullPathNoEndSeparator("a/b/c.txt"));
0976:                assertEquals("/a/b", FilenameUtils
0977:                        .getFullPathNoEndSeparator("/a/b/c.txt"));
0978:                assertEquals("C:", FilenameUtils
0979:                        .getFullPathNoEndSeparator("C:a"));
0980:                assertEquals("C:a/b", FilenameUtils
0981:                        .getFullPathNoEndSeparator("C:a/b/c.txt"));
0982:                assertEquals("C:/a/b", FilenameUtils
0983:                        .getFullPathNoEndSeparator("C:/a/b/c.txt"));
0984:                assertEquals("//server/a/b", FilenameUtils
0985:                        .getFullPathNoEndSeparator("//server/a/b/c.txt"));
0986:                assertEquals("~/a/b", FilenameUtils
0987:                        .getFullPathNoEndSeparator("~/a/b/c.txt"));
0988:                assertEquals("~user/a/b", FilenameUtils
0989:                        .getFullPathNoEndSeparator("~user/a/b/c.txt"));
0990:            }
0991:
0992:            public void testGetName() {
0993:                assertEquals(null, FilenameUtils.getName(null));
0994:                assertEquals("noseperator.inthispath", FilenameUtils
0995:                        .getName("noseperator.inthispath"));
0996:                assertEquals("c.txt", FilenameUtils.getName("a/b/c.txt"));
0997:                assertEquals("c", FilenameUtils.getName("a/b/c"));
0998:                assertEquals("", FilenameUtils.getName("a/b/c/"));
0999:                assertEquals("c", FilenameUtils.getName("a\\b\\c"));
1000:            }
1001:
1002:            public void testGetBaseName() {
1003:                assertEquals(null, FilenameUtils.getBaseName(null));
1004:                assertEquals("noseperator", FilenameUtils
1005:                        .getBaseName("noseperator.inthispath"));
1006:                assertEquals("c", FilenameUtils.getBaseName("a/b/c.txt"));
1007:                assertEquals("c", FilenameUtils.getBaseName("a/b/c"));
1008:                assertEquals("", FilenameUtils.getBaseName("a/b/c/"));
1009:                assertEquals("c", FilenameUtils.getBaseName("a\\b\\c"));
1010:                assertEquals("file.txt", FilenameUtils
1011:                        .getBaseName("file.txt.bak"));
1012:            }
1013:
1014:            public void testGetExtension() {
1015:                assertEquals(null, FilenameUtils.getExtension(null));
1016:                assertEquals("ext", FilenameUtils.getExtension("file.ext"));
1017:                assertEquals("", FilenameUtils.getExtension("README"));
1018:                assertEquals("com", FilenameUtils
1019:                        .getExtension("domain.dot.com"));
1020:                assertEquals("jpeg", FilenameUtils.getExtension("image.jpeg"));
1021:                assertEquals("", FilenameUtils.getExtension("a.b/c"));
1022:                assertEquals("txt", FilenameUtils.getExtension("a.b/c.txt"));
1023:                assertEquals("", FilenameUtils.getExtension("a/b/c"));
1024:                assertEquals("", FilenameUtils.getExtension("a.b\\c"));
1025:                assertEquals("txt", FilenameUtils.getExtension("a.b\\c.txt"));
1026:                assertEquals("", FilenameUtils.getExtension("a\\b\\c"));
1027:                assertEquals("", FilenameUtils
1028:                        .getExtension("C:\\temp\\foo.bar\\README"));
1029:                assertEquals("ext", FilenameUtils
1030:                        .getExtension("../filename.ext"));
1031:            }
1032:
1033:            public void testRemoveExtension() {
1034:                assertEquals(null, FilenameUtils.removeExtension(null));
1035:                assertEquals("file", FilenameUtils.removeExtension("file.ext"));
1036:                assertEquals("README", FilenameUtils.removeExtension("README"));
1037:                assertEquals("domain.dot", FilenameUtils
1038:                        .removeExtension("domain.dot.com"));
1039:                assertEquals("image", FilenameUtils
1040:                        .removeExtension("image.jpeg"));
1041:                assertEquals("a.b/c", FilenameUtils.removeExtension("a.b/c"));
1042:                assertEquals("a.b/c", FilenameUtils
1043:                        .removeExtension("a.b/c.txt"));
1044:                assertEquals("a/b/c", FilenameUtils.removeExtension("a/b/c"));
1045:                assertEquals("a.b\\c", FilenameUtils.removeExtension("a.b\\c"));
1046:                assertEquals("a.b\\c", FilenameUtils
1047:                        .removeExtension("a.b\\c.txt"));
1048:                assertEquals("a\\b\\c", FilenameUtils
1049:                        .removeExtension("a\\b\\c"));
1050:                assertEquals("C:\\temp\\foo.bar\\README", FilenameUtils
1051:                        .removeExtension("C:\\temp\\foo.bar\\README"));
1052:                assertEquals("../filename", FilenameUtils
1053:                        .removeExtension("../filename.ext"));
1054:            }
1055:
1056:            //-----------------------------------------------------------------------
1057:            public void testEquals() {
1058:                assertEquals(true, FilenameUtils.equals(null, null));
1059:                assertEquals(false, FilenameUtils.equals(null, ""));
1060:                assertEquals(false, FilenameUtils.equals("", null));
1061:                assertEquals(true, FilenameUtils.equals("", ""));
1062:                assertEquals(true, FilenameUtils.equals("file.txt", "file.txt"));
1063:                assertEquals(false, FilenameUtils
1064:                        .equals("file.txt", "FILE.TXT"));
1065:                assertEquals(false, FilenameUtils.equals("a\\b\\file.txt",
1066:                        "a/b/file.txt"));
1067:            }
1068:
1069:            public void testEqualsOnSystem() {
1070:                assertEquals(true, FilenameUtils.equalsOnSystem(null, null));
1071:                assertEquals(false, FilenameUtils.equalsOnSystem(null, ""));
1072:                assertEquals(false, FilenameUtils.equalsOnSystem("", null));
1073:                assertEquals(true, FilenameUtils.equalsOnSystem("", ""));
1074:                assertEquals(true, FilenameUtils.equalsOnSystem("file.txt",
1075:                        "file.txt"));
1076:                assertEquals(WINDOWS, FilenameUtils.equalsOnSystem("file.txt",
1077:                        "FILE.TXT"));
1078:                assertEquals(false, FilenameUtils.equalsOnSystem(
1079:                        "a\\b\\file.txt", "a/b/file.txt"));
1080:            }
1081:
1082:            //-----------------------------------------------------------------------
1083:            public void testEqualsNormalized() {
1084:                assertEquals(true, FilenameUtils.equalsNormalized(null, null));
1085:                assertEquals(false, FilenameUtils.equalsNormalized(null, ""));
1086:                assertEquals(false, FilenameUtils.equalsNormalized("", null));
1087:                assertEquals(true, FilenameUtils.equalsNormalized("", ""));
1088:                assertEquals(true, FilenameUtils.equalsNormalized("file.txt",
1089:                        "file.txt"));
1090:                assertEquals(false, FilenameUtils.equalsNormalized("file.txt",
1091:                        "FILE.TXT"));
1092:                assertEquals(true, FilenameUtils.equalsNormalized(
1093:                        "a\\b\\file.txt", "a/b/file.txt"));
1094:                assertEquals(false, FilenameUtils.equalsNormalized("a/b/",
1095:                        "a/b"));
1096:            }
1097:
1098:            public void testEqualsNormalizedOnSystem() {
1099:                assertEquals(true, FilenameUtils.equalsNormalizedOnSystem(null,
1100:                        null));
1101:                assertEquals(false, FilenameUtils.equalsNormalizedOnSystem(
1102:                        null, ""));
1103:                assertEquals(false, FilenameUtils.equalsNormalizedOnSystem("",
1104:                        null));
1105:                assertEquals(true, FilenameUtils.equalsNormalizedOnSystem("",
1106:                        ""));
1107:                assertEquals(true, FilenameUtils.equalsNormalizedOnSystem(
1108:                        "file.txt", "file.txt"));
1109:                assertEquals(WINDOWS, FilenameUtils.equalsNormalizedOnSystem(
1110:                        "file.txt", "FILE.TXT"));
1111:                assertEquals(true, FilenameUtils.equalsNormalizedOnSystem(
1112:                        "a\\b\\file.txt", "a/b/file.txt"));
1113:                assertEquals(false, FilenameUtils.equalsNormalizedOnSystem(
1114:                        "a/b/", "a/b"));
1115:            }
1116:
1117:            public void testEquals_fullControl() {
1118:                assertEquals(false, FilenameUtils.equals("file.txt",
1119:                        "FILE.TXT", true, IOCase.SENSITIVE));
1120:                assertEquals(true, FilenameUtils.equals("file.txt", "FILE.TXT",
1121:                        true, IOCase.INSENSITIVE));
1122:                assertEquals(WINDOWS, FilenameUtils.equals("file.txt",
1123:                        "FILE.TXT", true, IOCase.SYSTEM));
1124:                assertEquals(false, FilenameUtils.equals("file.txt",
1125:                        "FILE.TXT", true, null));
1126:            }
1127:
1128:            //-----------------------------------------------------------------------
1129:            public void testIsExtension() {
1130:                assertEquals(false, FilenameUtils.isExtension(null,
1131:                        (String) null));
1132:                assertEquals(false, FilenameUtils.isExtension("file.txt",
1133:                        (String) null));
1134:                assertEquals(true, FilenameUtils.isExtension("file",
1135:                        (String) null));
1136:                assertEquals(false, FilenameUtils.isExtension("file.txt", ""));
1137:                assertEquals(true, FilenameUtils.isExtension("file", ""));
1138:                assertEquals(true, FilenameUtils.isExtension("file.txt", "txt"));
1139:                assertEquals(false, FilenameUtils
1140:                        .isExtension("file.txt", "rtf"));
1141:
1142:                assertEquals(false, FilenameUtils.isExtension("a/b/file.txt",
1143:                        (String) null));
1144:                assertEquals(false, FilenameUtils.isExtension("a/b/file.txt",
1145:                        ""));
1146:                assertEquals(true, FilenameUtils.isExtension("a/b/file.txt",
1147:                        "txt"));
1148:                assertEquals(false, FilenameUtils.isExtension("a/b/file.txt",
1149:                        "rtf"));
1150:
1151:                assertEquals(false, FilenameUtils.isExtension("a.b/file.txt",
1152:                        (String) null));
1153:                assertEquals(false, FilenameUtils.isExtension("a.b/file.txt",
1154:                        ""));
1155:                assertEquals(true, FilenameUtils.isExtension("a.b/file.txt",
1156:                        "txt"));
1157:                assertEquals(false, FilenameUtils.isExtension("a.b/file.txt",
1158:                        "rtf"));
1159:
1160:                assertEquals(false, FilenameUtils.isExtension("a\\b\\file.txt",
1161:                        (String) null));
1162:                assertEquals(false, FilenameUtils.isExtension("a\\b\\file.txt",
1163:                        ""));
1164:                assertEquals(true, FilenameUtils.isExtension("a\\b\\file.txt",
1165:                        "txt"));
1166:                assertEquals(false, FilenameUtils.isExtension("a\\b\\file.txt",
1167:                        "rtf"));
1168:
1169:                assertEquals(false, FilenameUtils.isExtension("a.b\\file.txt",
1170:                        (String) null));
1171:                assertEquals(false, FilenameUtils.isExtension("a.b\\file.txt",
1172:                        ""));
1173:                assertEquals(true, FilenameUtils.isExtension("a.b\\file.txt",
1174:                        "txt"));
1175:                assertEquals(false, FilenameUtils.isExtension("a.b\\file.txt",
1176:                        "rtf"));
1177:
1178:                assertEquals(false, FilenameUtils.isExtension("a.b\\file.txt",
1179:                        "TXT"));
1180:            }
1181:
1182:            public void testIsExtensionArray() {
1183:                assertEquals(false, FilenameUtils.isExtension(null,
1184:                        (String[]) null));
1185:                assertEquals(false, FilenameUtils.isExtension("file.txt",
1186:                        (String[]) null));
1187:                assertEquals(true, FilenameUtils.isExtension("file",
1188:                        (String[]) null));
1189:                assertEquals(false, FilenameUtils.isExtension("file.txt",
1190:                        new String[0]));
1191:                assertEquals(true, FilenameUtils.isExtension("file.txt",
1192:                        new String[] { "txt" }));
1193:                assertEquals(false, FilenameUtils.isExtension("file.txt",
1194:                        new String[] { "rtf" }));
1195:                assertEquals(true, FilenameUtils.isExtension("file",
1196:                        new String[] { "rtf", "" }));
1197:                assertEquals(true, FilenameUtils.isExtension("file.txt",
1198:                        new String[] { "rtf", "txt" }));
1199:
1200:                assertEquals(false, FilenameUtils.isExtension("a/b/file.txt",
1201:                        (String[]) null));
1202:                assertEquals(false, FilenameUtils.isExtension("a/b/file.txt",
1203:                        new String[0]));
1204:                assertEquals(true, FilenameUtils.isExtension("a/b/file.txt",
1205:                        new String[] { "txt" }));
1206:                assertEquals(false, FilenameUtils.isExtension("a/b/file.txt",
1207:                        new String[] { "rtf" }));
1208:                assertEquals(true, FilenameUtils.isExtension("a/b/file.txt",
1209:                        new String[] { "rtf", "txt" }));
1210:
1211:                assertEquals(false, FilenameUtils.isExtension("a.b/file.txt",
1212:                        (String[]) null));
1213:                assertEquals(false, FilenameUtils.isExtension("a.b/file.txt",
1214:                        new String[0]));
1215:                assertEquals(true, FilenameUtils.isExtension("a.b/file.txt",
1216:                        new String[] { "txt" }));
1217:                assertEquals(false, FilenameUtils.isExtension("a.b/file.txt",
1218:                        new String[] { "rtf" }));
1219:                assertEquals(true, FilenameUtils.isExtension("a.b/file.txt",
1220:                        new String[] { "rtf", "txt" }));
1221:
1222:                assertEquals(false, FilenameUtils.isExtension("a\\b\\file.txt",
1223:                        (String[]) null));
1224:                assertEquals(false, FilenameUtils.isExtension("a\\b\\file.txt",
1225:                        new String[0]));
1226:                assertEquals(true, FilenameUtils.isExtension("a\\b\\file.txt",
1227:                        new String[] { "txt" }));
1228:                assertEquals(false, FilenameUtils.isExtension("a\\b\\file.txt",
1229:                        new String[] { "rtf" }));
1230:                assertEquals(true, FilenameUtils.isExtension("a\\b\\file.txt",
1231:                        new String[] { "rtf", "txt" }));
1232:
1233:                assertEquals(false, FilenameUtils.isExtension("a.b\\file.txt",
1234:                        (String[]) null));
1235:                assertEquals(false, FilenameUtils.isExtension("a.b\\file.txt",
1236:                        new String[0]));
1237:                assertEquals(true, FilenameUtils.isExtension("a.b\\file.txt",
1238:                        new String[] { "txt" }));
1239:                assertEquals(false, FilenameUtils.isExtension("a.b\\file.txt",
1240:                        new String[] { "rtf" }));
1241:                assertEquals(true, FilenameUtils.isExtension("a.b\\file.txt",
1242:                        new String[] { "rtf", "txt" }));
1243:
1244:                assertEquals(false, FilenameUtils.isExtension("a.b\\file.txt",
1245:                        new String[] { "TXT" }));
1246:                assertEquals(false, FilenameUtils.isExtension("a.b\\file.txt",
1247:                        new String[] { "TXT", "RTF" }));
1248:            }
1249:
1250:            public void testIsExtensionCollection() {
1251:                assertEquals(false, FilenameUtils.isExtension(null,
1252:                        (Collection) null));
1253:                assertEquals(false, FilenameUtils.isExtension("file.txt",
1254:                        (Collection) null));
1255:                assertEquals(true, FilenameUtils.isExtension("file",
1256:                        (Collection) null));
1257:                assertEquals(false, FilenameUtils.isExtension("file.txt",
1258:                        new ArrayList()));
1259:                assertEquals(true, FilenameUtils.isExtension("file.txt",
1260:                        new ArrayList(Arrays.asList(new String[] { "txt" }))));
1261:                assertEquals(false, FilenameUtils.isExtension("file.txt",
1262:                        new ArrayList(Arrays.asList(new String[] { "rtf" }))));
1263:                assertEquals(true, FilenameUtils
1264:                        .isExtension("file", new ArrayList(Arrays
1265:                                .asList(new String[] { "rtf", "" }))));
1266:                assertEquals(true, FilenameUtils.isExtension("file.txt",
1267:                        new ArrayList(Arrays
1268:                                .asList(new String[] { "rtf", "txt" }))));
1269:
1270:                assertEquals(false, FilenameUtils.isExtension("a/b/file.txt",
1271:                        (Collection) null));
1272:                assertEquals(false, FilenameUtils.isExtension("a/b/file.txt",
1273:                        new ArrayList()));
1274:                assertEquals(true, FilenameUtils.isExtension("a/b/file.txt",
1275:                        new ArrayList(Arrays.asList(new String[] { "txt" }))));
1276:                assertEquals(false, FilenameUtils.isExtension("a/b/file.txt",
1277:                        new ArrayList(Arrays.asList(new String[] { "rtf" }))));
1278:                assertEquals(true, FilenameUtils.isExtension("a/b/file.txt",
1279:                        new ArrayList(Arrays
1280:                                .asList(new String[] { "rtf", "txt" }))));
1281:
1282:                assertEquals(false, FilenameUtils.isExtension("a.b/file.txt",
1283:                        (Collection) null));
1284:                assertEquals(false, FilenameUtils.isExtension("a.b/file.txt",
1285:                        new ArrayList()));
1286:                assertEquals(true, FilenameUtils.isExtension("a.b/file.txt",
1287:                        new ArrayList(Arrays.asList(new String[] { "txt" }))));
1288:                assertEquals(false, FilenameUtils.isExtension("a.b/file.txt",
1289:                        new ArrayList(Arrays.asList(new String[] { "rtf" }))));
1290:                assertEquals(true, FilenameUtils.isExtension("a.b/file.txt",
1291:                        new ArrayList(Arrays
1292:                                .asList(new String[] { "rtf", "txt" }))));
1293:
1294:                assertEquals(false, FilenameUtils.isExtension("a\\b\\file.txt",
1295:                        (Collection) null));
1296:                assertEquals(false, FilenameUtils.isExtension("a\\b\\file.txt",
1297:                        new ArrayList()));
1298:                assertEquals(true, FilenameUtils.isExtension("a\\b\\file.txt",
1299:                        new ArrayList(Arrays.asList(new String[] { "txt" }))));
1300:                assertEquals(false, FilenameUtils.isExtension("a\\b\\file.txt",
1301:                        new ArrayList(Arrays.asList(new String[] { "rtf" }))));
1302:                assertEquals(true, FilenameUtils.isExtension("a\\b\\file.txt",
1303:                        new ArrayList(Arrays
1304:                                .asList(new String[] { "rtf", "txt" }))));
1305:
1306:                assertEquals(false, FilenameUtils.isExtension("a.b\\file.txt",
1307:                        (Collection) null));
1308:                assertEquals(false, FilenameUtils.isExtension("a.b\\file.txt",
1309:                        new ArrayList()));
1310:                assertEquals(true, FilenameUtils.isExtension("a.b\\file.txt",
1311:                        new ArrayList(Arrays.asList(new String[] { "txt" }))));
1312:                assertEquals(false, FilenameUtils.isExtension("a.b\\file.txt",
1313:                        new ArrayList(Arrays.asList(new String[] { "rtf" }))));
1314:                assertEquals(true, FilenameUtils.isExtension("a.b\\file.txt",
1315:                        new ArrayList(Arrays
1316:                                .asList(new String[] { "rtf", "txt" }))));
1317:
1318:                assertEquals(false, FilenameUtils.isExtension("a.b\\file.txt",
1319:                        new ArrayList(Arrays.asList(new String[] { "TXT" }))));
1320:                assertEquals(false, FilenameUtils.isExtension("a.b\\file.txt",
1321:                        new ArrayList(Arrays
1322:                                .asList(new String[] { "TXT", "RTF" }))));
1323:            }
1324:
1325:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.