1 18 package org.apache.struts.taglib.html; 19 20 import java.util.ArrayList ; 21 import java.util.HashMap ; 22 import java.util.Locale ; 23 import java.util.StringTokenizer ; 24 25 import javax.servlet.jsp.PageContext ; 26 27 import junit.framework.Test; 28 import junit.framework.TestSuite; 29 30 import org.apache.cactus.JspTestCase; 31 import org.apache.struts.Globals; 32 import org.apache.struts.taglib.SimpleBeanForTesting; 33 34 39 public class TestLinkTag1 extends JspTestCase { 40 41 46 public TestLinkTag1(String theName) { 47 super(theName); 48 } 49 50 55 public static void main(String [] theArgs) { 56 junit.awtui.TestRunner.main(new String [] {TestLinkTag1.class.getName()}); 57 } 58 59 63 public static Test suite() { 64 return new TestSuite(TestLinkTag1.class); 66 } 67 68 private void runMyTest(String whichTest, String locale) throws Exception { 69 pageContext.setAttribute(Globals.LOCALE_KEY, new Locale (locale, locale), PageContext.SESSION_SCOPE); 70 request.setAttribute("runTest", whichTest); 71 pageContext.forward("/test/org/apache/struts/taglib/html/TestLinkTag1.jsp"); 72 } 73 74 77 78 80 public void testLinkForward() throws Exception { 81 runMyTest("testLinkForward", ""); 82 } 83 84 public void testLinkForwardAccesskey() throws Exception { 85 runMyTest("testLinkForwardAccesskey", ""); 86 } 87 88 public void testLinkForwardAnchor() throws Exception { 89 runMyTest("testLinkForwardAnchor", ""); 90 } 91 92 public void testLinkForwardIndexedArray() throws Exception { 93 ArrayList lst = new ArrayList (); 94 lst.add("Test Message"); 95 pageContext.setAttribute("lst", lst, PageContext.REQUEST_SCOPE); 96 runMyTest("testLinkForwardIndexedArray", ""); 97 } 98 99 public void testLinkForwardIndexedArrayProperty() throws Exception { 100 SimpleBeanForTesting sbft = new SimpleBeanForTesting(); 101 ArrayList lst = new ArrayList (); 102 lst.add("Test Message"); 103 sbft.setList(lst); 104 pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE); 105 runMyTest("testLinkForwardIndexedArrayProperty", ""); 106 } 107 108 public void testLinkForwardIndexedMap() throws Exception { 109 HashMap map = new HashMap (); 110 map.put("tst1", "Test Message"); 111 pageContext.setAttribute("lst", map, PageContext.REQUEST_SCOPE); 112 runMyTest("testLinkForwardIndexedMap", ""); 113 } 114 115 public void testLinkForwardIndexedMapProperty() throws Exception { 116 SimpleBeanForTesting sbft = new SimpleBeanForTesting(); 117 HashMap map = new HashMap (); 118 map.put("tst1", "Test Message"); 119 sbft.setMap(map); 120 pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE); 121 runMyTest("testLinkForwardIndexedMapProperty", ""); 122 } 123 124 public void testLinkForwardIndexedEnumeration() throws Exception { 125 StringTokenizer st = new StringTokenizer ("Test Message"); 126 pageContext.setAttribute("lst", st, PageContext.REQUEST_SCOPE); 127 runMyTest("testLinkForwardIndexedEnumeration", ""); 128 } 129 130 public void testLinkForwardIndexedEnumerationProperty() throws Exception { 131 SimpleBeanForTesting sbft = new SimpleBeanForTesting(); 132 StringTokenizer st = new StringTokenizer ("Test Message"); 133 sbft.setEnumeration(st); 134 pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE); 135 runMyTest("testLinkForwardIndexedEnumerationProperty", ""); 136 } 137 138 139 public void testLinkForwardIndexedAlternateIdArray() throws Exception { 140 ArrayList lst = new ArrayList (); 141 lst.add("Test Message"); 142 pageContext.setAttribute("lst", lst, PageContext.REQUEST_SCOPE); 143 runMyTest("testLinkForwardIndexedAlternateIdArray", ""); 144 } 145 146 public void testLinkForwardIndexedAlternateIdArrayProperty() throws Exception { 147 SimpleBeanForTesting sbft = new SimpleBeanForTesting(); 148 ArrayList lst = new ArrayList (); 149 lst.add("Test Message"); 150 sbft.setList(lst); 151 pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE); 152 runMyTest("testLinkForwardIndexedAlternateIdArrayProperty", ""); 153 } 154 155 public void testLinkForwardIndexedAlternateIdMap() throws Exception { 156 HashMap map = new HashMap (); 157 map.put("tst1", "Test Message"); 158 pageContext.setAttribute("lst", map, PageContext.REQUEST_SCOPE); 159 runMyTest("testLinkForwardIndexedAlternateIdMap", ""); 160 } 161 162 public void testLinkForwardIndexedAlternateIdMapProperty() throws Exception { 163 SimpleBeanForTesting sbft = new SimpleBeanForTesting(); 164 HashMap map = new HashMap (); 165 map.put("tst1", "Test Message"); 166 sbft.setMap(map); 167 pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE); 168 runMyTest("testLinkForwardIndexedAlternateIdMapProperty", ""); 169 } 170 171 public void testLinkForwardIndexedAlternateIdEnumeration() throws Exception { 172 StringTokenizer st = new StringTokenizer ("Test Message"); 173 pageContext.setAttribute("lst", st, PageContext.REQUEST_SCOPE); 174 runMyTest("testLinkForwardIndexedAlternateIdEnumeration", ""); 175 } 176 177 public void testLinkForwardIndexedAlternateIdEnumerationProperty() throws Exception { 178 SimpleBeanForTesting sbft = new SimpleBeanForTesting(); 179 StringTokenizer st = new StringTokenizer ("Test Message"); 180 sbft.setEnumeration(st); 181 pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE); 182 runMyTest("testLinkForwardIndexedAlternateIdEnumerationProperty", ""); 183 } 184 185 public void testLinkForwardLinkName() throws Exception { 186 runMyTest("testLinkForwardLinkName", ""); 187 } 188 189 public void testLinkForwardNameNoScope() throws Exception { 190 HashMap map = new HashMap (); 191 map.put("param1","value1"); 192 map.put("param2","value2"); 193 map.put("param3","value3"); 194 map.put("param4","value4"); 195 pageContext.setAttribute("paramMap", map, PageContext.REQUEST_SCOPE); 196 runMyTest("testLinkForwardNameNoScope", ""); 197 } 198 199 public void testLinkForwardNamePropertyNoScope() throws Exception { 200 HashMap map = new HashMap (); 201 map.put("param1","value1"); 202 map.put("param2","value2"); 203 map.put("param3","value3"); 204 map.put("param4","value4"); 205 SimpleBeanForTesting sbft = new SimpleBeanForTesting(map); 206 pageContext.setAttribute("paramPropertyMap", sbft, PageContext.REQUEST_SCOPE); 207 runMyTest("testLinkForwardNamePropertyNoScope", ""); 208 } 209 210 public void testLinkForwardNameApplicationScope() throws Exception { 211 HashMap map = new HashMap (); 212 map.put("param1","value1"); 213 map.put("param2","value2"); 214 map.put("param3","value3"); 215 map.put("param4","value4"); 216 pageContext.setAttribute("paramMap", map, PageContext.APPLICATION_SCOPE); 217 runMyTest("testLinkForwardNameApplicationScope", ""); 218 } 219 220 public void testLinkForwardNamePropertyApplicationScope() throws Exception { 221 HashMap map = new HashMap (); 222 map.put("param1","value1"); 223 map.put("param2","value2"); 224 map.put("param3","value3"); 225 map.put("param4","value4"); 226 SimpleBeanForTesting sbft = new SimpleBeanForTesting(map); 227 pageContext.setAttribute("paramPropertyMap", sbft, PageContext.APPLICATION_SCOPE); 228 runMyTest("testLinkForwardNamePropertyApplicationScope", ""); 229 } 230 231 public void testLinkForwardNameSessionScope() throws Exception { 232 HashMap map = new HashMap (); 233 map.put("param1","value1"); 234 map.put("param2","value2"); 235 map.put("param3","value3"); 236 map.put("param4","value4"); 237 pageContext.setAttribute("paramMap", map, PageContext.SESSION_SCOPE); 238 runMyTest("testLinkForwardNameSessionScope", ""); 239 } 240 241 public void testLinkForwardNamePropertySessionScope() throws Exception { 242 HashMap map = new HashMap (); 243 map.put("param1","value1"); 244 map.put("param2","value2"); 245 map.put("param3","value3"); 246 map.put("param4","value4"); 247 SimpleBeanForTesting sbft = new SimpleBeanForTesting(map); 248 pageContext.setAttribute("paramPropertyMap", sbft, PageContext.SESSION_SCOPE); 249 runMyTest("testLinkForwardNamePropertySessionScope", ""); 250 } 251 252 public void testLinkForwardNameRequestScope() throws Exception { 253 HashMap map = new HashMap (); 254 map.put("param1","value1"); 255 map.put("param2","value2"); 256 map.put("param3","value3"); 257 map.put("param4","value4"); 258 pageContext.setAttribute("paramMap", map, PageContext.REQUEST_SCOPE); 259 runMyTest("testLinkForwardNameRequestScope", ""); 260 } 261 262 public void testLinkForwardNamePropertyRequestScope() throws Exception { 263 HashMap map = new HashMap (); 264 map.put("param1","value1"); 265 map.put("param2","value2"); 266 map.put("param3","value3"); 267 map.put("param4","value4"); 268 SimpleBeanForTesting sbft = new SimpleBeanForTesting(map); 269 pageContext.setAttribute("paramPropertyMap", sbft, PageContext.REQUEST_SCOPE); 270 runMyTest("testLinkForwardNamePropertyRequestScope", ""); 271 } 272 273 } 274 | Popular Tags |