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 TestLinkTag3 extends JspTestCase { 40 41 46 public TestLinkTag3(String theName) { 47 super(theName); 48 } 49 50 55 public static void main(String [] theArgs) { 56 junit.awtui.TestRunner.main(new String [] {TestLinkTag3.class.getName()}); 57 } 58 59 63 public static Test suite() { 64 return new TestSuite(TestLinkTag3.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/TestLinkTag3.jsp"); 72 } 73 74 77 78 80 public void testLinkAction() throws Exception { 81 runMyTest("testLinkAction", ""); 82 } 83 84 public void testLinkActionAccesskey() throws Exception { 85 runMyTest("testLinkActionAccesskey", ""); 86 } 87 88 public void testLinkActionAnchor() throws Exception { 89 runMyTest("testLinkActionAnchor", ""); 90 } 91 92 public void testLinkActionIndexedArray() throws Exception { 93 ArrayList lst = new ArrayList (); 94 lst.add("Test Message"); 95 pageContext.setAttribute("lst", lst, PageContext.REQUEST_SCOPE); 96 runMyTest("testLinkActionIndexedArray", ""); 97 } 98 99 public void testLinkActionIndexedArrayProperty() 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("testLinkActionIndexedArrayProperty", ""); 106 } 107 108 public void testLinkActionIndexedMap() throws Exception { 109 HashMap map = new HashMap (); 110 map.put("tst1", "Test Message"); 111 pageContext.setAttribute("lst", map, PageContext.REQUEST_SCOPE); 112 runMyTest("testLinkActionIndexedMap", ""); 113 } 114 115 public void testLinkActionIndexedMapProperty() 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("testLinkActionIndexedMapProperty", ""); 122 } 123 124 public void testLinkActionIndexedEnumeration() throws Exception { 125 StringTokenizer st = new StringTokenizer ("Test Message"); 126 pageContext.setAttribute("lst", st, PageContext.REQUEST_SCOPE); 127 runMyTest("testLinkActionIndexedEnumeration", ""); 128 } 129 130 public void testLinkActionIndexedEnumerationProperty() 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("testLinkActionIndexedEnumerationProperty", ""); 136 } 137 138 139 public void testLinkActionIndexedAlternateIdArray() throws Exception { 140 ArrayList lst = new ArrayList (); 141 lst.add("Test Message"); 142 pageContext.setAttribute("lst", lst, PageContext.REQUEST_SCOPE); 143 runMyTest("testLinkActionIndexedAlternateIdArray", ""); 144 } 145 146 public void testLinkActionIndexedAlternateIdArrayProperty() 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("testLinkActionIndexedAlternateIdArrayProperty", ""); 153 } 154 155 public void testLinkActionIndexedAlternateIdMap() throws Exception { 156 HashMap map = new HashMap (); 157 map.put("tst1", "Test Message"); 158 pageContext.setAttribute("lst", map, PageContext.REQUEST_SCOPE); 159 runMyTest("testLinkActionIndexedAlternateIdMap", ""); 160 } 161 162 public void testLinkActionIndexedAlternateIdMapProperty() 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("testLinkActionIndexedAlternateIdMapProperty", ""); 169 } 170 171 public void testLinkActionIndexedAlternateIdEnumeration() throws Exception { 172 StringTokenizer st = new StringTokenizer ("Test Message"); 173 pageContext.setAttribute("lst", st, PageContext.REQUEST_SCOPE); 174 runMyTest("testLinkActionIndexedAlternateIdEnumeration", ""); 175 } 176 177 public void testLinkActionIndexedAlternateIdEnumerationProperty() 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("testLinkActionIndexedAlternateIdEnumerationProperty", ""); 183 } 184 185 public void testLinkActionLinkName() throws Exception { 186 runMyTest("testLinkActionLinkName", ""); 187 } 188 189 public void testLinkActionNameNoScope() 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("testLinkActionNameNoScope", ""); 197 } 198 199 public void testLinkActionNamePropertyNoScope() 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("testLinkActionNamePropertyNoScope", ""); 208 } 209 210 public void testLinkActionNameApplicationScope() 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("testLinkActionNameApplicationScope", ""); 218 } 219 220 public void testLinkActionNamePropertyApplicationScope() 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("testLinkActionNamePropertyApplicationScope", ""); 229 } 230 231 public void testLinkActionNameSessionScope() 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("testLinkActionNameSessionScope", ""); 239 } 240 241 public void testLinkActionNamePropertySessionScope() 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("testLinkActionNamePropertySessionScope", ""); 250 } 251 252 public void testLinkActionNameRequestScope() 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("testLinkActionNameRequestScope", ""); 260 } 261 262 public void testLinkActionNamePropertyRequestScope() 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("testLinkActionNamePropertyRequestScope", ""); 271 } 272 273 } 274 | Popular Tags |