2009/05/20 - Apache Shale has been retired.

For more information, please explore the Attic.

View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to you under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.shale.usecases.systest;
19  
20  import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
21  import com.gargoylesoftware.htmlunit.html.HtmlForm;
22  import com.gargoylesoftware.htmlunit.html.HtmlSpan;
23  import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
24  import junit.framework.Test;
25  import junit.framework.TestSuite;
26  import org.apache.shale.test.cargo.CargoTestSetup;
27  
28  /***
29   * <p>Validate the "Subview Processing" path through the application</p>
30   */
31  public class SubviewTestCase extends AbstractTestCase {
32      
33  
34      // ------------------------------------------------------------ Constructors
35  
36  
37      /***
38       * <p>Construct a new instance of this test case.</p>
39       *
40       * @param name Name of the new test case
41       */
42      public SubviewTestCase(String name) {
43  
44          super(name);
45  
46      }
47  
48  
49      // ------------------------------------------------------ Instance Variables
50  
51  
52      // ------------------------------------------------------ Test Setup Methods
53  
54  
55      /***
56       * <p>Set up the instance variables required for this test case.</p>
57       */
58      protected void setUp() throws Exception {
59  
60          super.setUp();
61          page("/subview/first.faces");
62  
63      }
64  
65  
66      /***
67       * <p>Return the set of tests included in this test suite.</p>
68       */
69      public static Test suite() {
70  
71          return new CargoTestSetup(new TestSuite(SubviewTestCase.class));
72  
73      }
74  
75  
76      /***
77       * <p>Tear down instance variables required by this test case.</p>
78       */
79      protected void tearDown() throws Exception {
80  
81          super.tearDown();
82  
83      }
84  
85  
86  
87      // ------------------------------------------------- Individual Test Methods
88  
89  
90      /***
91       * <p>Execute the "Subview Processing" path.</p>
92       */
93      public void testExecute() throws Exception {
94  
95          HtmlSpan span, expected, actual = null;
96          HtmlSubmitInput submit = null;
97  
98          // setUp() should have put us on the first page
99          assertEquals("Subview Processing (Page 1 of 2)", title());
100 
101         // Verify contents of the first page
102         span = (HtmlSpan) element("form:subview_alpha:alpha");
103         assertNotNull(span);
104         assertEquals("This is the alpha dynamic include", span.asText());
105 
106         span = (HtmlSpan) element("form:subview_beta:beta");
107         assertNotNull(span);
108         assertEquals("This is the beta dynamic include", span.asText());
109 
110         expected = (HtmlSpan) element("form:expected");
111         assertNotNull(expected);
112         actual = (HtmlSpan) element("form:actual");
113         assertNotNull(actual);
114         assertEquals(expected.asText(), actual.asText());
115 
116         // Advance to the second page
117         submit = (HtmlSubmitInput) element("form:continue");
118         assertNotNull(submit);
119         submit(submit);
120         assertEquals("Subview Processing (Page 2 of 2)", title());
121 
122         // Verify the contents of the second page
123         span = (HtmlSpan) element("form:subview_gamma:gamma");
124         assertNotNull(span);
125         assertEquals("This is the gamma dynamic include", span.asText());
126 
127         span = (HtmlSpan) element("form:subview_delta:delta");
128         assertNotNull(span);
129         assertEquals("This is the delta dynamic include", span.asText());
130 
131         expected = (HtmlSpan) element("form:expected");
132         assertNotNull(expected);
133         actual = (HtmlSpan) element("form:actual");
134         assertNotNull(actual);
135         assertEquals(expected.asText(), actual.asText());
136 
137         // Advance to the third page
138         submit = (HtmlSubmitInput) element("form:continue");
139         assertNotNull(submit);
140         submit(submit);
141         assertEquals("Subview Processing (Page 2 of 2)", title());
142 
143         // Verify the contents of the third page
144         span = (HtmlSpan) element("form:subview_gamma:gamma");
145         assertNotNull(span);
146         assertEquals("This is the gamma dynamic include", span.asText());
147 
148         span = (HtmlSpan) element("form:subview_delta:delta");
149         assertNotNull(span);
150         assertEquals("This is the delta dynamic include", span.asText());
151 
152         expected = (HtmlSpan) element("form:expected");
153         assertNotNull(expected);
154         actual = (HtmlSpan) element("form:actual");
155         assertNotNull(actual);
156         assertEquals(expected.asText(), actual.asText());
157 
158         // Advance back to the main menu
159         submit = (HtmlSubmitInput) element("form:finish");
160         assertNotNull(submit);
161         submit(submit);
162         assertEquals("Shale Framework Use Cases", title());
163 
164     }
165 
166 
167 }