01: package org.apache.velocity.test;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21:
22: import java.io.File;
23:
24: import junit.framework.Test;
25: import junit.framework.TestSuite;
26:
27: /**
28: * I keep breaking the getFileName method all the time...
29: */
30: public class TestBaseTestCase extends BaseTestCase {
31: public TestBaseTestCase(final String name) {
32: super (name);
33: }
34:
35: public static Test suite() {
36: return new TestSuite(TestBaseTestCase.class);
37: }
38:
39: public void testGetFileName() throws Exception {
40: String fs = System.getProperty("file.separator");
41: String pwd = System.getProperty("user.dir");
42:
43: String root = new File("/").getCanonicalPath();
44:
45: assertEquals(pwd + fs + "baz" + fs + "foo.bar", getFileName(
46: "baz", "foo", "bar"));
47: assertEquals(root + "baz" + fs + "foo.bar", getFileName(root
48: + "baz", "foo", "bar"));
49: assertEquals(root + "foo.bar", getFileName("baz", root + "foo",
50: "bar"));
51: assertEquals(root + "foo.bar", getFileName(root + "baz", root
52: + "foo", "bar"));
53: assertEquals("", getFileName(null, "", ""));
54: assertEquals(root + "", getFileName("", "", ""));
55: assertEquals(".x", getFileName(null, "", "x"));
56: assertEquals(root + ".x", getFileName("", "", "x"));
57: assertEquals("foo.bar", getFileName(null, "foo", "bar"));
58: assertEquals(root + "foo.bar", getFileName(null, root + "foo",
59: "bar"));
60: assertEquals(root + "foo.bar", getFileName("", "foo", "bar"));
61: assertEquals(root + "foo.bar", getFileName("", root + "foo",
62: "bar"));
63: }
64: }
|