1 18 package org.apache.struts.taglib.html; 19 20 import java.util.HashMap ; 21 import java.util.Locale ; 22 23 import javax.servlet.jsp.PageContext ; 24 25 import junit.framework.Test; 26 import junit.framework.TestSuite; 27 28 import org.apache.cactus.JspTestCase; 29 import org.apache.struts.Globals; 30 import org.apache.struts.taglib.SimpleBeanForTesting; 31 32 37 public class TestImgTag3a extends JspTestCase { 38 39 44 public TestImgTag3a(String theName) { 45 super(theName); 46 } 47 48 53 public static void main(String [] theArgs) { 54 junit.awtui.TestRunner.main(new String [] {TestImgTag3a.class.getName()}); 55 } 56 57 61 public static Test suite() { 62 return new TestSuite(TestImgTag3a.class); 64 } 65 66 private void runMyTest(String whichTest, String locale) throws Exception { 67 pageContext.setAttribute(Globals.LOCALE_KEY, new Locale (locale, locale), PageContext.SESSION_SCOPE); 68 pageContext.setAttribute(Constants.BEAN_KEY, new SimpleBeanForTesting("Test Value"), PageContext.REQUEST_SCOPE); 69 request.setAttribute("runTest", whichTest); 70 pageContext.forward("/test/org/apache/struts/taglib/html/TestImgTag3a.jsp"); 71 } 72 73 76 77 79 public void testImgPageKeyNameNoScope() throws Exception { 80 HashMap map = new HashMap (); 81 map.put("param1","value1"); 82 map.put("param2","value2"); 83 map.put("param3","value3"); 84 map.put("param4","value4"); 85 pageContext.setAttribute("paramMapNoScope", map, PageContext.REQUEST_SCOPE); 86 runMyTest("testImgPageKeyNameNoScope", ""); 87 } 88 89 public void testImgPageKeyNamePropertyNoScope() throws Exception { 90 HashMap map = new HashMap (); 91 map.put("param1","value1"); 92 map.put("param2","value2"); 93 map.put("param3","value3"); 94 map.put("param4","value4"); 95 SimpleBeanForTesting sbft = new SimpleBeanForTesting(map); 96 pageContext.setAttribute("paramPropertyMapNoScope", sbft, PageContext.REQUEST_SCOPE); 97 runMyTest("testImgPageKeyNamePropertyNoScope", ""); 98 } 99 100 public void testImgPageKeyNameApplicationScope() throws Exception { 101 HashMap map = new HashMap (); 102 map.put("param1","value1"); 103 map.put("param2","value2"); 104 map.put("param3","value3"); 105 map.put("param4","value4"); 106 pageContext.setAttribute("paramMapApplicationScope", map, PageContext.APPLICATION_SCOPE); 107 runMyTest("testImgPageKeyNameApplicationScope", ""); 108 } 109 110 public void testImgPageKeyNamePropertyApplicationScope() throws Exception { 111 HashMap map = new HashMap (); 112 map.put("param1","value1"); 113 map.put("param2","value2"); 114 map.put("param3","value3"); 115 map.put("param4","value4"); 116 SimpleBeanForTesting sbft = new SimpleBeanForTesting(map); 117 pageContext.setAttribute("paramPropertyMapApplicationScope", sbft, PageContext.APPLICATION_SCOPE); 118 runMyTest("testImgPageKeyNamePropertyApplicationScope", ""); 119 } 120 121 public void testImgPageKeyNameSessionScope() throws Exception { 122 HashMap map = new HashMap (); 123 map.put("param1","value1"); 124 map.put("param2","value2"); 125 map.put("param3","value3"); 126 map.put("param4","value4"); 127 pageContext.setAttribute("paramMapSessionScope", map, PageContext.SESSION_SCOPE); 128 runMyTest("testImgPageKeyNameSessionScope", ""); 129 } 130 131 public void testImgPageKeyNamePropertySessionScope() throws Exception { 132 HashMap map = new HashMap (); 133 map.put("param1","value1"); 134 map.put("param2","value2"); 135 map.put("param3","value3"); 136 map.put("param4","value4"); 137 SimpleBeanForTesting sbft = new SimpleBeanForTesting(map); 138 pageContext.setAttribute("paramPropertyMapSessionScope", sbft, PageContext.SESSION_SCOPE); 139 runMyTest("testImgPageKeyNamePropertySessionScope", ""); 140 } 141 142 public void testImgPageKeyNameRequestScope() throws Exception { 143 HashMap map = new HashMap (); 144 map.put("param1","value1"); 145 map.put("param2","value2"); 146 map.put("param3","value3"); 147 map.put("param4","value4"); 148 pageContext.setAttribute("paramMapRequestScope", map, PageContext.REQUEST_SCOPE); 149 runMyTest("testImgPageKeyNameRequestScope", ""); 150 } 151 152 public void testImgPageKeyNamePropertyRequestScope() throws Exception { 153 HashMap map = new HashMap (); 154 map.put("param1","value1"); 155 map.put("param2","value2"); 156 map.put("param3","value3"); 157 map.put("param4","value4"); 158 SimpleBeanForTesting sbft = new SimpleBeanForTesting(map); 159 pageContext.setAttribute("paramPropertyMapRequestScope", sbft, PageContext.REQUEST_SCOPE); 160 runMyTest("testImgPageKeyNamePropertyRequestScope", ""); 161 } 162 163 164 165 } 166 | Popular Tags |