01: /*
02: * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
03: *
04: * http://izpack.org/
05: * http://izpack.codehaus.org/
06: *
07: * Licensed under the Apache License, Version 2.0 (the "License");
08: * you may not use this file except in compliance with the License.
09: * You may obtain a copy of the License at
10: *
11: * http://www.apache.org/licenses/LICENSE-2.0
12: *
13: * Unless required by applicable law or agreed to in writing, software
14: * distributed under the License is distributed on an "AS IS" BASIS,
15: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16: * See the License for the specific language governing permissions and
17: * limitations under the License.
18: */
19:
20: package com.izforge.izpack.util;
21:
22: import junit.framework.TestCase;
23:
24: public class StringToolTest extends TestCase {
25:
26: /*
27: * Class under test for String replace(String, String, String[, boolean])
28: */
29: public void testReplace() {
30: String ref = "ABC-012-def";
31:
32: TestCase.assertEquals(null, StringTool
33: .replace(null, null, null));
34: TestCase.assertEquals("ABC-012-def", StringTool.replace(ref,
35: null, null));
36: TestCase.assertEquals("ABC-012-def", StringTool.replace(ref,
37: "something", null));
38: TestCase.assertEquals("ABC012def", StringTool.replace(ref, "-",
39: null));
40: TestCase.assertEquals("abc-012-def", StringTool.replace(ref,
41: "ABC", "abc"));
42: TestCase.assertEquals("ABC-012-def", StringTool.replace(ref,
43: "abc", "abc", false));
44: TestCase.assertEquals("ABC-012-def", StringTool.replace(ref,
45: "abc", "abc", true));
46: }
47:
48: /*
49: * Class under test for String normalizePath(String[, String])
50: */
51: public void testNormalizePath() {
52: TestCase.assertEquals("C:\\Foo\\Bar\\is\\so\\boring;plop;plop",
53: StringTool.normalizePath(
54: "C:\\Foo/Bar/is\\so\\boring:plop;plop", "\\"));
55: TestCase.assertEquals("/some/where/that:matters:really",
56: StringTool.normalizePath(
57: "/some/where\\that:matters;really", "/"));
58: }
59:
60: }
|