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 TestLinkTag7 extends JspTestCase { 40 41 46 public TestLinkTag7(String theName) { 47 super(theName); 48 } 49 50 55 public static void main(String [] theArgs) { 56 junit.awtui.TestRunner.main(new String [] {TestLinkTag7.class.getName()}); 57 } 58 59 63 public static Test suite() { 64 return new TestSuite(TestLinkTag7.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/TestLinkTag7.jsp"); 72 } 73 74 77 78 80 public void testLinkPage() throws Exception { 81 runMyTest("testLinkPage", ""); 82 } 83 84 public void testLinkPageAccesskey() throws Exception { 85 runMyTest("testLinkPageAccesskey", ""); 86 } 87 88 public void testLinkPageAnchor() throws Exception { 89 runMyTest("testLinkPageAnchor", ""); 90 } 91 92 public void testLinkPageIndexedArray() throws Exception { 93 ArrayList lst = new ArrayList (); 94 lst.add("Test Message"); 95 pageContext.setAttribute("lst", lst, PageContext.REQUEST_SCOPE); 96 runMyTest("testLinkPageIndexedArray", ""); 97 } 98 99 public void testLinkPageIndexedArrayProperty() 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("testLinkPageIndexedArrayProperty", ""); 106 } 107 108 public void testLinkPageIndexedMap() throws Exception { 109 HashMap map = new HashMap (); 110 map.put("tst1", "Test Message"); 111 pageContext.setAttribute("lst", map, PageContext.REQUEST_SCOPE); 112 runMyTest("testLinkPageIndexedMap", ""); 113 } 114 115 public void testLinkPageIndexedMapProperty() 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("testLinkPageIndexedMapProperty", ""); 122 } 123 124 public void testLinkPageIndexedEnumeration() throws Exception { 125 StringTokenizer st = new StringTokenizer ("Test Message"); 126 pageContext.setAttribute("lst", st, PageContext.REQUEST_SCOPE); 127 runMyTest("testLinkPageIndexedEnumeration", ""); 128 } 129 130 public void testLinkPageIndexedEnumerationProperty() 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("testLinkPageIndexedEnumerationProperty", ""); 136 } 137 138 139 public void testLinkPageIndexedAlternateIdArray() throws Exception { 140 ArrayList lst = new ArrayList (); 141 lst.add("Test Message"); 142 pageContext.setAttribute("lst", lst, PageContext.REQUEST_SCOPE); 143 runMyTest("testLinkPageIndexedAlternateIdArray", ""); 144 } 145 146 public void testLinkPageIndexedAlternateIdArrayProperty() 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("testLinkPageIndexedAlternateIdArrayProperty", ""); 153 } 154 155 public void testLinkPageIndexedAlternateIdMap() throws Exception { 156 HashMap map = new HashMap (); 157 map.put("tst1", "Test Message"); 158 pageContext.setAttribute("lst", map, PageContext.REQUEST_SCOPE); 159 runMyTest("testLinkPageIndexedAlternateIdMap", ""); 160 } 161 162 public void testLinkPageIndexedAlternateIdMapProperty() 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("testLinkPageIndexedAlternateIdMapProperty", ""); 169 } 170 171 public void testLinkPageIndexedAlternateIdEnumeration() throws Exception { 172 StringTokenizer st = new StringTokenizer ("Test Message"); 173 pageContext.setAttribute("lst", st, PageContext.REQUEST_SCOPE); 174 runMyTest("testLinkPageIndexedAlternateIdEnumeration", ""); 175 } 176 177 public void testLinkPageIndexedAlternateIdEnumerationProperty() 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("testLinkPageIndexedAlternateIdEnumerationProperty", ""); 183 } 184 185 public void testLinkPageLinkName() throws Exception { 186 runMyTest("testLinkPageLinkName", ""); 187 } 188 189 public void testLinkPageNameNoScope() 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("testLinkPageNameNoScope", ""); 197 } 198 199 public void testLinkPageNamePropertyNoScope() 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("testLinkPageNamePropertyNoScope", ""); 208 } 209 210 public void testLinkPageNameApplicationScope() 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("testLinkPageNameApplicationScope", ""); 218 } 219 220 public void testLinkPageNamePropertyApplicationScope() 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("testLinkPageNamePropertyApplicationScope", ""); 229 } 230 231 public void testLinkPageNameSessionScope() 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("testLinkPageNameSessionScope", ""); 239 } 240 241 public void testLinkPageNamePropertySessionScope() 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("testLinkPageNamePropertySessionScope", ""); 250 } 251 252 public void testLinkPageNameRequestScope() 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("testLinkPageNameRequestScope", ""); 260 } 261 262 public void testLinkPageNamePropertyRequestScope() 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("testLinkPageNamePropertyRequestScope", ""); 271 } 272 273 } 274 | Popular Tags |