01: package org.andromda.cartridges.bpm4struts;
02:
03: import junit.framework.TestCase;
04:
05: import java.util.Arrays;
06:
07: public class Bpm4StrutsUtilsTest extends TestCase {
08: public Bpm4StrutsUtilsTest(String name) {
09: super (name);
10: }
11:
12: public void testParseValidatorArgs() throws Exception {
13: final Object[][] fixture = new Object[][] {
14: new Object[] { "myValidator", new Object[0] },
15: new Object[] { "myValidator(myVar=myArg)",
16: new Object[] { "myArg" } },
17: new Object[] {
18: "myValidator(myVar=myArg,myOtherVar=myOtherArg)",
19: new Object[] { "myArg", "myOtherArg" } } };
20:
21: for (int i = 0; i < fixture.length; i++) {
22: Object[] objects = fixture[i];
23: assertTrue(Arrays.equals(Bpm4StrutsUtils
24: .parseValidatorArgs((String) objects[0]).toArray(),
25: (Object[]) objects[1]));
26: }
27: }
28:
29: public void testParseValidatorVars() throws Exception {
30: final Object[][] fixture = new Object[][] {
31: new Object[] { "myValidator", new Object[0] },
32: new Object[] { "myValidator(myVar=myArg)",
33: new Object[] { "myVar" } },
34: new Object[] {
35: "myValidator(myVar=myArg,myOtherVar=myOtherArg)",
36: new Object[] { "myVar", "myOtherVar" } } };
37:
38: for (int i = 0; i < fixture.length; i++) {
39: Object[] objects = fixture[i];
40: assertTrue(Arrays.equals(Bpm4StrutsUtils
41: .parseValidatorVars((String) objects[0]).toArray(),
42: (Object[]) objects[1]));
43: }
44: }
45:
46: public void testParseValidatorName() throws Exception {
47: final String[][] fixture = new String[][] {
48: new String[] { "myValidator", "myValidator" },
49: new String[] { "myValidator(myVar=myArg)",
50: "myValidator" },
51: new String[] {
52: "myValidator(myVar=myArg,myOtherVar=myOtherArg)",
53: "myValidator" } };
54:
55: for (int i = 0; i < fixture.length; i++) {
56: String[] strings = fixture[i];
57: assertEquals(
58: Bpm4StrutsUtils.parseValidatorName(strings[0]),
59: strings[1]);
60: }
61: }
62:
63: public void testToWebFileName() throws Exception {
64: final String[][] fixture = new String[][] {
65: new String[] { "singleword", "singleword" },
66: new String[] { "two words", "two-words" },
67: new String[] { " stuff with whitespace ",
68: "stuff-with-whitespace" } };
69:
70: for (int i = 0; i < fixture.length; i++) {
71: String[] strings = fixture[i];
72: assertEquals(Bpm4StrutsUtils.toWebFileName(strings[0]),
73: strings[1]);
74: }
75: }
76: }
|