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 TestLinkTag5 extends JspTestCase { 40 41 46 public TestLinkTag5(String theName) { 47 super(theName); 48 } 49 50 55 public static void main(String [] theArgs) { 56 junit.awtui.TestRunner.main(new String [] {TestLinkTag5.class.getName()}); 57 } 58 59 63 public static Test suite() { 64 return new TestSuite(TestLinkTag5.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/TestLinkTag5.jsp"); 72 } 73 74 77 78 80 public void testLinkHref() throws Exception { 81 runMyTest("testLinkHref", ""); 82 } 83 84 public void testLinkHrefAccesskey() throws Exception { 85 runMyTest("testLinkHrefAccesskey", ""); 86 } 87 88 public void testLinkHrefAnchor() throws Exception { 89 runMyTest("testLinkHrefAnchor", ""); 90 } 91 92 public void testLinkHrefIndexedArray() throws Exception { 93 ArrayList lst = new ArrayList (); 94 lst.add("Test Message"); 95 pageContext.setAttribute("lst", lst, PageContext.REQUEST_SCOPE); 96 runMyTest("testLinkHrefIndexedArray", ""); 97 } 98 99 public void testLinkHrefIndexedArrayProperty() 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("testLinkHrefIndexedArrayProperty", ""); 106 } 107 108 public void testLinkHrefIndexedMap() throws Exception { 109 HashMap map = new HashMap (); 110 map.put("tst1", "Test Message"); 111 pageContext.setAttribute("lst", map, PageContext.REQUEST_SCOPE); 112 runMyTest("testLinkHrefIndexedMap", ""); 113 } 114 115 public void testLinkHrefIndexedMapProperty() 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("testLinkHrefIndexedMapProperty", ""); 122 } 123 124 public void testLinkHrefIndexedEnumeration() throws Exception { 125 StringTokenizer st = new StringTokenizer ("Test Message"); 126 pageContext.setAttribute("lst", st, PageContext.REQUEST_SCOPE); 127 runMyTest("testLinkHrefIndexedEnumeration", ""); 128 } 129 130 public void testLinkHrefIndexedEnumerationProperty() 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("testLinkHrefIndexedEnumerationProperty", ""); 136 } 137 138 139 public void testLinkHrefIndexedAlternateIdArray() throws Exception { 140 ArrayList lst = new ArrayList (); 141 lst.add("Test Message"); 142 pageContext.setAttribute("lst", lst, PageContext.REQUEST_SCOPE); 143 runMyTest("testLinkHrefIndexedAlternateIdArray", ""); 144 } 145 146 public void testLinkHrefIndexedAlternateIdArrayProperty() 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("testLinkHrefIndexedAlternateIdArrayProperty", ""); 153 } 154 155 public void testLinkHrefIndexedAlternateIdMap() throws Exception { 156 HashMap map = new HashMap (); 157 map.put("tst1", "Test Message"); 158 pageContext.setAttribute("lst", map, PageContext.REQUEST_SCOPE); 159 runMyTest("testLinkHrefIndexedAlternateIdMap", ""); 160 } 161 162 public void testLinkHrefIndexedAlternateIdMapProperty() 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("testLinkHrefIndexedAlternateIdMapProperty", ""); 169 } 170 171 public void testLinkHrefIndexedAlternateIdEnumeration() throws Exception { 172 StringTokenizer st = new StringTokenizer ("Test Message"); 173 pageContext.setAttribute("lst", st, PageContext.REQUEST_SCOPE); 174 runMyTest("testLinkHrefIndexedAlternateIdEnumeration", ""); 175 } 176 177 public void testLinkHrefIndexedAlternateIdEnumerationProperty() 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("testLinkHrefIndexedAlternateIdEnumerationProperty", ""); 183 } 184 185 public void testLinkHrefLinkName() throws Exception { 186 runMyTest("testLinkHrefLinkName", ""); 187 } 188 189 public void testLinkHrefNameNoScope() 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("testLinkHrefNameNoScope", ""); 197 } 198 199 public void testLinkHrefNamePropertyNoScope() 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("testLinkHrefNamePropertyNoScope", ""); 208 } 209 210 public void testLinkHrefNameApplicationScope() 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("testLinkHrefNameApplicationScope", ""); 218 } 219 220 public void testLinkHrefNamePropertyApplicationScope() 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("testLinkHrefNamePropertyApplicationScope", ""); 229 } 230 231 public void testLinkHrefNameSessionScope() 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("testLinkHrefNameSessionScope", ""); 239 } 240 241 public void testLinkHrefNamePropertySessionScope() 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("testLinkHrefNamePropertySessionScope", ""); 250 } 251 252 public void testLinkHrefNameRequestScope() 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("testLinkHrefNameRequestScope", ""); 260 } 261 262 public void testLinkHrefNamePropertyRequestScope() 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("testLinkHrefNamePropertyRequestScope", ""); 271 } 272 273 } 274 | Popular Tags |