1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.chain.web;
17
18
19 import junit.framework.Test;
20 import junit.framework.TestCase;
21 import junit.framework.TestSuite;
22
23
24
25
26 public class ChainResourcesTestCase extends TestCase {
27
28
29
30
31 /***
32 * Construct a new instance of this test case.
33 *
34 * @param name Name of the test case
35 */
36 public ChainResourcesTestCase(String name) {
37 super(name);
38 }
39
40
41
42
43
44 protected TestData[] data = new TestData[]
45 {
46 new TestData("a,b,c", new String[] {"a", "b", "c"}),
47 new TestData("a , b , c ", new String[] {"a", "b", "c"}),
48 new TestData("a,\tb,\tc ", new String[] {"a", "b", "c"}),
49 new TestData("\na,\nb,\nc\n", new String[] {"a", "b", "c"}),
50 new TestData("a,,b,c ", new String[] {"a", "b", "c"}),
51 new TestData(",a,b,,c,,", new String[] {"a", "b", "c"}),
52 new TestData(null, new String[] {}),
53 new TestData("", new String[] {}),
54 new TestData(",", new String[] {}),
55 new TestData(",,", new String[] {})
56 };
57
58
59
60
61
62 public void testGetPaths() throws Exception {
63 for (int i = 0; i < data.length; i++) {
64 TestData datum = data[i];
65 String[] expected = datum.getExpected();
66 String[] actual = ChainResources.getResourcePaths(datum.getInput());
67
68 assertNotNull(actual);
69 assertEquals(expected.length, actual.length);
70 for (int j = 0; j < actual.length; j++) {
71 assertEquals(expected[j], actual[j]);
72 }
73 }
74 }
75
76
77
78
79
80
81 public static final class TestData {
82 private String input;
83 private String[] expected;
84 public TestData(String input, String[] expected) {
85 this.input = input;
86 this.expected = expected;
87 }
88 public String getInput() {
89 return input;
90 }
91 public String[] getExpected() {
92 return expected;
93 }
94 }
95
96 }