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 TestImgTag1a extends JspTestCase { 38 39 44 public TestImgTag1a(String theName) { 45 super(theName); 46 } 47 48 53 public static void main(String [] theArgs) { 54 junit.awtui.TestRunner.main(new String [] {TestImgTag1a.class.getName()}); 55 } 56 57 61 public static Test suite() { 62 return new TestSuite(TestImgTag1a.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/TestImgTag1a.jsp"); 71 } 72 73 76 77 79 public void testImgPageNameNoScope() 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("testImgPageNameNoScope", ""); 87 } 88 89 public void testImgPageNamePropertyNoScope() 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("testImgPageNamePropertyNoScope", ""); 98 } 99 100 public void testImgPageNameApplicationScope() 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("testImgPageNameApplicationScope", ""); 108 } 109 110 public void testImgPageNamePropertyApplicationScope() 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("testImgPageNamePropertyApplicationScope", ""); 119 } 120 121 public void testImgPageNameSessionScope() 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("testImgPageNameSessionScope", ""); 129 } 130 131 public void testImgPageNamePropertySessionScope() 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("testImgPageNamePropertySessionScope", ""); 140 } 141 142 public void testImgPageNameRequestScope() 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("testImgPageNameRequestScope", ""); 150 } 151 152 public void testImgPageNamePropertyRequestScope() 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("testImgPageNamePropertyRequestScope", ""); 161 } 162 163 164 165 } 166 | Popular Tags |