1 18 package org.apache.struts.taglib.bean; 19 20 import java.util.Locale ; 21 22 import javax.servlet.jsp.PageContext ; 23 24 import junit.framework.Test; 25 import junit.framework.TestSuite; 26 27 import org.apache.cactus.WebResponse; 28 import org.apache.struts.Globals; 29 import org.apache.struts.taglib.SimpleBeanForTesting; 30 import org.apache.struts.taglib.TaglibTestBase; 31 32 43 public class TestMessageTag4 extends TaglibTestBase { 44 45 protected final static String TEST_KEY = "BeanKey"; 46 protected final static String TEST_VAL = "Testing Message 1 2 3 4"; 47 48 public TestMessageTag4(String theName) { 49 super(theName); 50 } 51 52 57 public static void main(String [] theArgs) { 58 junit.awtui.TestRunner.main(new String [] {TestMessageTag4.class.getName()}); 59 } 60 61 65 public static Test suite() { 66 return new TestSuite(TestMessageTag4.class); 68 } 69 70 private void runMyTest(String whichTest, Locale locale) throws Exception { 71 pageContext.setAttribute(Globals.LOCALE_KEY, locale, PageContext.SESSION_SCOPE); 72 request.setAttribute("runTest", whichTest); 73 pageContext.forward("/test/org/apache/struts/taglib/bean/TestMessageTag4.jsp"); 74 } 75 76 private void formatAndTest(String compare, String output) { 77 output = replace(output,"\r",""); 79 output = replace(output,"\n",""); 80 output = output.trim(); 81 assertEquals(compare, output); 83 } 84 85 94 95 96 public void testMessageTag4ArgKeyNoScopeDefaultBundle() throws Exception { 97 runMyTest("testMessageTag4ArgKeyNoScopeDefaultBundle", new Locale ("","")); 98 } 99 public void endMessageTag4ArgKeyNoScopeDefaultBundle(WebResponse response){ 100 formatAndTest(TEST_VAL, response.getText()); 101 } 102 103 public void testMessageTag4ArgKeyApplicationScopeDefaultBundle() throws Exception { 104 runMyTest("testMessageTag4ArgKeyApplicationScopeDefaultBundle", new Locale ("","")); 105 } 106 public void endMessageTag4ArgKeyApplicationScopeDefaultBundle(WebResponse response){ 107 formatAndTest(TEST_VAL, response.getText()); 108 } 109 110 public void testMessageTag4ArgKeySessionScopeDefaultBundle() throws Exception { 111 runMyTest("testMessageTag4ArgKeySessionScopeDefaultBundle", new Locale ("","")); 112 } 113 public void endMessageTag4ArgKeySessionScopeDefaultBundle(WebResponse response){ 114 formatAndTest(TEST_VAL, response.getText()); 115 } 116 117 public void testMessageTag4ArgKeyRequestScopeDefaultBundle() throws Exception { 118 runMyTest("testMessageTag4ArgKeyRequestScopeDefaultBundle", new Locale ("","")); 119 } 120 public void endMessageTag4ArgKeyRequestScopeDefaultBundle(WebResponse response){ 121 formatAndTest(TEST_VAL, response.getText()); 122 } 123 124 125 public void testMessageTag4ArgKeyNoScopeAlternateBundle() throws Exception { 126 runMyTest("testMessageTag4ArgKeyNoScopeAlternateBundle", new Locale ("","")); 127 } 128 public void endMessageTag4ArgKeyNoScopeAlternateBundle(WebResponse response){ 129 formatAndTest(TEST_VAL, response.getText()); 130 } 131 132 public void testMessageTag4ArgKeyApplicationScopeAlternateBundle() throws Exception { 133 runMyTest("testMessageTag4ArgKeyApplicationScopeAlternateBundle", new Locale ("","")); 134 } 135 public void endMessageTag4ArgKeyApplicationScopeAlternateBundle(WebResponse response){ 136 formatAndTest(TEST_VAL, response.getText()); 137 } 138 139 public void testMessageTag4ArgKeySessionScopeAlternateBundle() throws Exception { 140 runMyTest("testMessageTag4ArgKeySessionScopeAlternateBundle", new Locale ("","")); 141 } 142 public void endMessageTag4ArgKeySessionScopeAlternateBundle(WebResponse response){ 143 formatAndTest(TEST_VAL, response.getText()); 144 } 145 146 public void testMessageTag4ArgKeyRequestScopeAlternateBundle() throws Exception { 147 runMyTest("testMessageTag4ArgKeyRequestScopeAlternateBundle", new Locale ("","")); 148 } 149 public void endMessageTag4ArgKeyRequestScopeAlternateBundle(WebResponse response){ 150 formatAndTest(TEST_VAL, response.getText()); 151 } 152 153 154 155 public void testMessageTag4ArgNameNoScopeDefaultBundle() throws Exception { 156 runMyTest("testMessageTag4ArgNameNoScopeDefaultBundle", new Locale ("","")); 157 } 158 public void endMessageTag4ArgNameNoScopeDefaultBundle(WebResponse response){ 159 formatAndTest(TEST_VAL, response.getText()); 160 } 161 162 public void testMessageTag4ArgNameApplicationScopeDefaultBundle() throws Exception { 163 runMyTest("testMessageTag4ArgNameApplicationScopeDefaultBundle", new Locale ("","")); 164 } 165 public void endMessageTag4ArgNameApplicationScopeDefaultBundle(WebResponse response){ 166 formatAndTest(TEST_VAL, response.getText()); 167 } 168 169 public void testMessageTag4ArgNameSessionScopeDefaultBundle() throws Exception { 170 runMyTest("testMessageTag4ArgNameSessionScopeDefaultBundle", new Locale ("","")); 171 } 172 public void endMessageTag4ArgNameSessionScopeDefaultBundle(WebResponse response){ 173 formatAndTest(TEST_VAL, response.getText()); 174 } 175 176 public void testMessageTag4ArgNameRequestScopeDefaultBundle() throws Exception { 177 runMyTest("testMessageTag4ArgNameRequestScopeDefaultBundle", new Locale ("","")); 178 } 179 public void endMessageTag4ArgNameRequestScopeDefaultBundle(WebResponse response){ 180 formatAndTest(TEST_VAL, response.getText()); 181 } 182 183 184 public void testMessageTag4ArgNameNoScopeAlternateBundle() throws Exception { 185 runMyTest("testMessageTag4ArgNameNoScopeAlternateBundle", new Locale ("","")); 186 } 187 public void endMessageTag4ArgNameNoScopeAlternateBundle(WebResponse response){ 188 formatAndTest(TEST_VAL, response.getText()); 189 } 190 191 public void testMessageTag4ArgNameApplicationScopeAlternateBundle() throws Exception { 192 runMyTest("testMessageTag4ArgNameApplicationScopeAlternateBundle", new Locale ("","")); 193 } 194 public void endMessageTag4ArgNameApplicationScopeAlternateBundle(WebResponse response){ 195 formatAndTest(TEST_VAL, response.getText()); 196 } 197 198 public void testMessageTag4ArgNameSessionScopeAlternateBundle() throws Exception { 199 runMyTest("testMessageTag4ArgNameSessionScopeAlternateBundle", new Locale ("","")); 200 } 201 public void endMessageTag4ArgNameSessionScopeAlternateBundle(WebResponse response){ 202 formatAndTest(TEST_VAL, response.getText()); 203 } 204 205 public void testMessageTag4ArgNameRequestScopeAlternateBundle() throws Exception { 206 runMyTest("testMessageTag4ArgNameRequestScopeAlternateBundle", new Locale ("","")); 207 } 208 public void endMessageTag4ArgNameRequestScopeAlternateBundle(WebResponse response){ 209 formatAndTest(TEST_VAL, response.getText()); 210 } 211 212 213 214 215 public void testMessageTag4ArgNamePropertyNoScopeDefaultBundle() throws Exception { 216 pageContext.setAttribute("key", new SimpleBeanForTesting("default.bundle.message.4"), PageContext.REQUEST_SCOPE); 217 runMyTest("testMessageTag4ArgNamePropertyNoScopeDefaultBundle", new Locale ("","")); 218 } 219 public void endMessageTag4ArgNamePropertyNoScopeDefaultBundle(WebResponse response){ 220 formatAndTest(TEST_VAL, response.getText()); 221 } 222 223 public void testMessageTag4ArgNamePropertyApplicationScopeDefaultBundle() throws Exception { 224 pageContext.setAttribute("key", new SimpleBeanForTesting("default.bundle.message.4"), PageContext.APPLICATION_SCOPE); 225 runMyTest("testMessageTag4ArgNamePropertyApplicationScopeDefaultBundle", new Locale ("","")); 226 } 227 public void endMessageTag4ArgNamePropertyApplicationScopeDefaultBundle(WebResponse response){ 228 formatAndTest(TEST_VAL, response.getText()); 229 } 230 231 public void testMessageTag4ArgNamePropertySessionScopeDefaultBundle() throws Exception { 232 pageContext.setAttribute("key", new SimpleBeanForTesting("default.bundle.message.4"), PageContext.SESSION_SCOPE); 233 runMyTest("testMessageTag4ArgNamePropertySessionScopeDefaultBundle", new Locale ("","")); 234 } 235 public void endMessageTag4ArgNamePropertySessionScopeDefaultBundle(WebResponse response){ 236 formatAndTest(TEST_VAL, response.getText()); 237 } 238 239 public void testMessageTag4ArgNamePropertyRequestScopeDefaultBundle() throws Exception { 240 pageContext.setAttribute("key", new SimpleBeanForTesting("default.bundle.message.4"), PageContext.REQUEST_SCOPE); 241 runMyTest("testMessageTag4ArgNamePropertyRequestScopeDefaultBundle", new Locale ("","")); 242 } 243 public void endMessageTag4ArgNamePropertyRequestScopeDefaultBundle(WebResponse response){ 244 formatAndTest(TEST_VAL, response.getText()); 245 } 246 247 248 public void testMessageTag4ArgNamePropertyNoScopeAlternateBundle() throws Exception { 249 pageContext.setAttribute("key", new SimpleBeanForTesting("alternate.bundle.message.4"), PageContext.REQUEST_SCOPE); 250 runMyTest("testMessageTag4ArgNamePropertyNoScopeAlternateBundle", new Locale ("","")); 251 } 252 public void endMessageTag4ArgNamePropertyNoScopeAlternateBundle(WebResponse response){ 253 formatAndTest(TEST_VAL, response.getText()); 254 } 255 256 public void testMessageTag4ArgNamePropertyApplicationScopeAlternateBundle() throws Exception { 257 pageContext.setAttribute("key", new SimpleBeanForTesting("alternate.bundle.message.4"), PageContext.APPLICATION_SCOPE); 258 runMyTest("testMessageTag4ArgNamePropertyApplicationScopeAlternateBundle", new Locale ("","")); 259 } 260 public void endMessageTag4ArgNamePropertyApplicationScopeAlternateBundle(WebResponse response){ 261 formatAndTest(TEST_VAL, response.getText()); 262 } 263 264 public void testMessageTag4ArgNamePropertySessionScopeAlternateBundle() throws Exception { 265 pageContext.setAttribute("key", new SimpleBeanForTesting("alternate.bundle.message.4"), PageContext.SESSION_SCOPE); 266 runMyTest("testMessageTag4ArgNamePropertySessionScopeAlternateBundle", new Locale ("","")); 267 } 268 public void endMessageTag4ArgNamePropertySessionScopeAlternateBundle(WebResponse response){ 269 formatAndTest(TEST_VAL, response.getText()); 270 } 271 272 public void testMessageTag4ArgNamePropertyRequestScopeAlternateBundle() throws Exception { 273 pageContext.setAttribute("key", new SimpleBeanForTesting("alternate.bundle.message.4"), PageContext.REQUEST_SCOPE); 274 runMyTest("testMessageTag4ArgNamePropertyRequestScopeAlternateBundle", new Locale ("","")); 275 } 276 public void endMessageTag4ArgNamePropertyRequestScopeAlternateBundle(WebResponse response){ 277 formatAndTest(TEST_VAL, response.getText()); 278 } 279 280 281 } 282 | Popular Tags |