1 16 17 package org.apache.struts.faces.sysclient; 18 19 import junit.framework.Test; 20 import junit.framework.TestSuite; 21 22 import com.gargoylesoftware.htmlunit.html.HtmlSpan; 23 import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput; 24 25 26 32 33 public class ContextTestCase extends AbstractTestCase { 34 35 36 38 39 44 public ContextTestCase(String name) { 45 46 super(name); 47 48 } 49 50 51 53 54 56 57 60 public void setUp() throws Exception { 61 62 super.setUp(); 63 page("/context.faces"); 64 65 } 66 67 68 71 public static Test suite() { 72 73 return (new TestSuite(ContextTestCase.class)); 74 75 } 76 77 78 81 public void tearDown() { 82 83 super.tearDown(); 84 85 } 86 87 88 89 91 92 96 public void testPristine() throws Exception { 97 98 HtmlSpan span = null; 99 assertEquals("context", title()); 100 101 103 span = (HtmlSpan) element("form:renderKitIdFC"); 104 assertEquals("HTML_BASIC", span.asText()); 105 106 span = (HtmlSpan) element("form:viewIdFC"); 107 assertEquals("/context.jsp", span.asText()); 108 109 111 span = (HtmlSpan) element("form:authTypeEC"); 112 assertEquals("", span.asText()); 113 114 span = (HtmlSpan) element("form:remoteUserEC"); 115 assertEquals("", span.asText()); 116 117 span = (HtmlSpan) element("form:requestContextPathEC"); 118 assertEquals("/struts-faces-systest1", span.asText()); 120 121 span = (HtmlSpan) element("form:requestLocaleEC"); 122 String formRequestLocaleEC = span.asText(); 124 span = (HtmlSpan) element("form:requestPathInfoEC"); 125 assertEquals("", span.asText()); 126 127 span = (HtmlSpan) element("form:requestServletPathEC"); 128 assertEquals("/context.jsp", span.asText()); 129 130 132 span = (HtmlSpan) element("form:authTypeRQ"); 133 assertEquals("", span.asText()); 134 135 span = (HtmlSpan) element("form:contextPathRQ"); 136 assertEquals("/struts-faces-systest1", span.asText()); 138 span = (HtmlSpan) element("form:localeRQ"); 139 assertEquals(formRequestLocaleEC, span.asText()); 140 141 span = (HtmlSpan) element("form:pathInfoRQ"); 142 assertEquals("", span.asText()); 143 144 span = (HtmlSpan) element("form:remoteUserRQ"); 145 assertEquals("", span.asText()); 146 147 span = (HtmlSpan) element("form:servletPathRQ"); 148 assertEquals("/context.jsp", span.asText()); 149 150 152 span = (HtmlSpan) element("form:majorVersionSC"); 153 assertEquals("2", span.asText()); 154 155 span = (HtmlSpan) element("form:minorVersionSC"); 156 assertTrue("3".equals(span.asText()) || "4".equals(span.asText())); 157 158 } 159 160 161 164 public void testSubmit() throws Exception { 165 166 HtmlSpan span = null; 167 HtmlSpan spanCA = null; 168 HtmlSubmitInput submit = (HtmlSubmitInput) element("form:submit"); 169 submit(submit); 170 assertEquals("context1", title()); 171 172 174 span = (HtmlSpan) element("form:renderKitIdFC"); 175 assertEquals("HTML_BASIC", span.asText()); 176 177 span = (HtmlSpan) element("form:viewIdFC"); 178 assertEquals("/context1.jsp", span.asText()); 179 180 182 span = (HtmlSpan) element("form:authTypeEC"); 183 assertEquals("", span.asText()); 184 185 span = (HtmlSpan) element("form:remoteUserEC"); 186 assertEquals("", span.asText()); 187 188 span = (HtmlSpan) element("form:requestContextPathEC"); 189 assertEquals("/struts-faces-systest1", span.asText()); 191 span = (HtmlSpan) element("form:requestLocaleEC"); 192 String formRequestLocaleEC = span.asText(); 194 span = (HtmlSpan) element("form:requestPathInfoEC"); 195 assertEquals("", span.asText()); 196 197 span = (HtmlSpan) element("form:requestServletPathEC"); 198 assertEquals("/context1.jsp", span.asText()); 199 200 202 span = (HtmlSpan) element("form:authTypeRQ"); 203 assertEquals("", span.asText()); 204 205 span = (HtmlSpan) element("form:contextPathRQ"); 206 assertEquals("/struts-faces-systest1", span.asText()); spanCA = (HtmlSpan) element("form:contextPathCA"); 208 assertEquals(span.asText(), spanCA.asText()); 209 210 span = (HtmlSpan) element("form:localeRQ"); 211 assertEquals(formRequestLocaleEC, span.asText()); 212 spanCA = (HtmlSpan) element("form:localeCA"); 213 assertEquals(span.asText(), spanCA.asText()); 214 215 span = (HtmlSpan) element("form:pathInfoRQ"); 216 assertEquals("", span.asText()); 217 spanCA = (HtmlSpan) element("form:pathInfoCA"); 218 assertEquals(span.asText(), spanCA.asText()); 219 220 span = (HtmlSpan) element("form:remoteUserRQ"); 221 assertEquals("", span.asText()); 222 spanCA = (HtmlSpan) element("form:remoteUserCA"); 223 assertEquals(span.asText(), spanCA.asText()); 224 225 span = (HtmlSpan) element("form:servletPathRQ"); 226 assertEquals("/context1.jsp", span.asText()); 227 spanCA = (HtmlSpan) element("form:servletPathCA"); 228 assertEquals("/context.faces", spanCA.asText()); 229 230 232 span = (HtmlSpan) element("form:majorVersionSC"); 233 assertEquals("2", span.asText()); 234 235 span = (HtmlSpan) element("form:minorVersionSC"); 236 assertTrue("3".equals(span.asText()) || "4".equals(span.asText())); 237 238 } 239 240 241 } 242
| Popular Tags
|