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 junit.framework.Test;
23  import junit.framework.TestSuite;
24  import org.apache.shale.test.cargo.CargoTestSetup;
25  
26  /***
27   * <p>Simple integration test to validate access to the main menu.</p>
28   */
29  public class UseCasesTestCase extends AbstractTestCase {
30      
31  
32      // ------------------------------------------------------------ Constructors
33  
34  
35      /***
36       * <p>Construct a new instance of this test case.</p>
37       *
38       * @param name Name of the new test case
39       */
40      public UseCasesTestCase(String name) {
41  
42          super(name);
43  
44      }
45  
46  
47      // ------------------------------------------------------ Instance Variables
48  
49  
50      // ------------------------------------------------------ Test Setup Methods
51  
52  
53      /***
54       * <p>Set up the instance variables required for this test case.</p>
55       */
56      protected void setUp() throws Exception {
57  
58          super.setUp();
59          page("/usecases.faces");
60  
61      }
62  
63  
64      /***
65       * <p>Return the set of tests included in this test suite.</p>
66       */
67      public static Test suite() {
68  
69          return new CargoTestSetup(new TestSuite(UseCasesTestCase.class));
70  
71      }
72  
73  
74      /***
75       * <p>Tear down instance variables required by this test case.</p>
76       */
77      protected void tearDown() throws Exception {
78  
79          super.tearDown();
80  
81      }
82  
83  
84  
85      // ------------------------------------------------- Individual Test Methods
86  
87  
88      /***
89       * <p>Verify the availability of an appropriate form.</p>
90       */
91      public void testForm() throws Exception {
92  
93          HtmlForm form = (HtmlForm) element("usecasesForm");
94          assertNotNull(form);
95          assertEquals("", form.getAcceptAttribute());
96          assertEquals("", form.getAcceptCharsetAttribute());
97          String action = form.getActionAttribute();
98          int semicolon = action.indexOf(";jsessionid=");
99          if (semicolon >= 0) {
100             action = action.substring(0, semicolon);
101         }
102         assertEquals("/shale-usecases/usecases.faces", action);
103         assertEquals("application/x-www-form-urlencoded", form.getEnctypeAttribute());
104         assertEquals("", form.getLangAttribute());
105         assertEquals("post", form.getMethodAttribute());
106         // assertEquals("", form.getNameAttribute()); // Remove test for RI behavior that is not in the spec
107         assertEquals("", form.getOnResetAttribute());
108         assertEquals("", form.getOnSubmitAttribute());
109         assertEquals("", form.getTargetAttribute());
110 
111     }
112 
113 
114     /***
115      * <p>Verify the availability of an appropriate subview hyperlink.</p>
116      */
117     public void testSubview() throws Exception {
118 
119         HtmlAnchor anchor = (HtmlAnchor) element("usecasesForm:subview");
120         assertNotNull(anchor);
121         assertEquals("", anchor.getAccessKeyAttribute());
122         assertEquals("", anchor.getCharsetAttribute());
123         assertEquals("", anchor.getCoordsAttribute());
124         // assertEquals("#", anchor.getHrefAttribute());
125         assertEquals("", anchor.getHrefLangAttribute());
126         assertEquals("", anchor.getNameAttribute());
127         assertEquals("", anchor.getRelAttribute());
128         assertEquals("", anchor.getRevAttribute());
129         assertEquals("", anchor.getShapeAttribute());
130         assertEquals("", anchor.getTabIndexAttribute());
131         assertEquals("", anchor.getTargetAttribute());
132         assertEquals("", anchor.getTypeAttribute());
133         assertEquals("Subview Processing", anchor.asText());
134 
135     }
136 
137 
138     /***
139      * <p>Verify the title of the returned page.</p>
140      */
141     public void testTitle() throws Exception {
142 
143         assertEquals("Shale Framework Use Cases", title());
144 
145     }
146 
147 
148 }