2009/05/20 - Apache Shale has been retired.
For more information, please explore the Attic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.shale.usecases.systest;
19
20 import com.gargoylesoftware.htmlunit.html.HtmlElement;
21 import com.gargoylesoftware.htmlunit.html.HtmlForm;
22 import com.gargoylesoftware.htmlunit.html.HtmlHiddenInput;
23 import com.gargoylesoftware.htmlunit.html.HtmlPage;
24 import com.gargoylesoftware.htmlunit.html.HtmlSpan;
25 import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
26 import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
27 import java.util.ArrayList;
28 import java.util.List;
29 import java.util.Locale;
30
31 import junit.framework.Test;
32 import junit.framework.TestSuite;
33 import org.apache.shale.test.cargo.CargoTestSetup;
34
35 /***
36 * <p>Test case for the exception handling use case.</p>
37 */
38 public class ExceptionTestCase extends AbstractTestCase {
39
40
41
42
43
44
45 public ExceptionTestCase(String name) {
46 super(name);
47 }
48
49
50
51
52
53
54 protected void setUp() throws Exception {
55
56 super.setUp();
57 page("/exception/test.faces");
58
59 }
60
61
62 public static Test suite() {
63
64 return new CargoTestSetup(new TestSuite(ExceptionTestCase.class));
65
66 }
67
68
69
70 protected void tearDown() throws Exception {
71
72 super.tearDown();
73
74 }
75
76
77
78
79
80 /***
81 * <p>Test the "normal" flow of submitting a correctly entered form.</p>
82 */
83 public void testNormal() throws Exception {
84
85 HtmlElement element = null;
86
87
88 assertEquals("Exception Handling Test", title());
89
90
91 HtmlSubmitInput submit = (HtmlSubmitInput) element("form:submit");
92 submit(submit);
93
94
95 assertEquals("Exception Handling - Correct Result", title());
96
97
98 element = element("form:status_code");
99 assertNotNull(element);
100 assertEquals("200", element.asText());
101 element = element("form:exception_type");
102 assertNotNull(element);
103 assertEquals("org.apache.shale.view.ApplicationException", element.asText());
104
105 }
106
107
108 /***
109 * <p>Validate pristine instance of the "Token" test page.</p>
110 */
111 public void testPristine() throws Exception {
112
113 HtmlForm form = null;
114 HtmlElement messages = null;
115 HtmlSubmitInput submit = null;
116
117
118 assertEquals("Exception Handling Test", title());
119 form = (HtmlForm) element("form");
120 assertNotNull(form);
121 messages = element("form:messages");
122
123
124
125 submit = (HtmlSubmitInput) element("form:submit");
126 assertNotNull(submit);
127
128 }
129
130
131 }