jmitchell 2003/02/28 22:00:13 Added: src/test/org/apache/struts/taglib/html TestErrorsTag1.java TestErrorsTag2.java TestFileTag1.java TestFileTag2.java web/test/test/org/apache/struts/taglib/html TestErrorsTag1.jsp TestErrorsTag2.jsp TestFileTag1.jsp TestFileTag2.jsp Log: New tests Revision Changes Path 1.1 jakarta-struts/src/test/org/apache/struts/taglib/html/TestErrorsTag1.java Index: TestErrorsTag1.java =================================================================== /* * The Apache Software License, Version 1.1 * * Copyright (c) 1999-2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Struts", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * */ package org.apache.struts.taglib.html; import java.util.Locale; import javax.servlet.jsp.PageContext; import junit.framework.Test; import junit.framework.TestSuite; import org.apache.cactus.JspTestCase; import org.apache.struts.Globals; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; /** * Suite of unit tests for the * <code>org.apache.struts.taglib.bean.ErrorsTag</code> class. * * @author James Mitchell */ public class TestErrorsTag1 extends JspTestCase { /** * Defines the testcase name for JUnit. * * @param theName the testcase's name. */ public TestErrorsTag1(String theName) { super(theName); } /** * Start the tests. * * @param theArgs the arguments. Not used */ public static void main(String[] theArgs) { junit.awtui.TestRunner.main(new String[] {TestErrorsTag1.class.getName()}); } /** * @return a test suite (<code>TestSuite</code>) that includes all methods * starting with "test" */ public static Test suite() { // All methods starting with "test" will be executed in the test suite. return new TestSuite(TestErrorsTag1.class); } private void runMyTest(String whichTest, String locale){ request.setAttribute("runTest", whichTest); pageContext.setAttribute(Globals.LOCALE_KEY, new Locale(locale, locale), PageContext.SESSION_SCOPE); try { pageContext.forward("/test/org/apache/struts/taglib/html/TestErrorsTag1.jsp"); } catch (Exception e) { e.printStackTrace(); fail("There is a problem that is preventing the tests to continue!"); } } private void formatAndTest(String compare, String output) { //fix for introduced carriage return / line feeds output = output.replaceAll("\r",""); output = output.replaceAll("\n",""); output = output.trim(); assertEquals(compare, output); } /* * Testing ErrorsTag. */ public void testErrorsDefaultBundle0Errors(){ runMyTest("testErrorsDefaultBundle0Errors", ""); } public void testErrorsDefaultBundle2Errors(){ runMyTest("testErrorsDefaultBundle2Errors", ""); } public void testErrorsAlternateBundle0Errors(){ runMyTest("testErrorsAlternateBundle0Errors", ""); } public void testErrorsAlternateBundle2Errors(){ runMyTest("testErrorsAlternateBundle2Errors", ""); } public void testErrorsDefaultBundle0Errors_fr(){ runMyTest("testErrorsDefaultBundle0Errors_fr", "fr"); } public void testErrorsDefaultBundle2Errors_fr(){ runMyTest("testErrorsDefaultBundle2Errors_fr", "fr"); } public void testErrorsAlternateBundle0Errors_fr(){ runMyTest("testErrorsAlternateBundle0Errors_fr", "fr"); } public void testErrorsAlternateBundle2Errors_fr(){ runMyTest("testErrorsAlternateBundle2Errors_fr", "fr"); } public void testErrorsDefaultBundle0ErrorsLocale(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsDefaultBundle0ErrorsLocale", ""); } public void testErrorsDefaultBundle2ErrorsLocale(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsDefaultBundle2ErrorsLocale", ""); } public void testErrorsAlternateBundle0ErrorsLocale(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsAlternateBundle0ErrorsLocale", ""); } public void testErrorsAlternateBundle2ErrorsLocale(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsAlternateBundle2ErrorsLocale", ""); } public void testErrorsDefaultBundle0ErrorsLocale_fr(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsDefaultBundle0ErrorsLocale_fr", ""); } public void testErrorsDefaultBundle2ErrorsLocale_fr(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsDefaultBundle2ErrorsLocale_fr", ""); } public void testErrorsAlternateBundle0ErrorsLocale_fr(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsAlternateBundle0ErrorsLocale_fr", ""); } public void testErrorsAlternateBundle2ErrorsLocale_fr(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsAlternateBundle2ErrorsLocale_fr", ""); } public void testErrorsDefaultBundle0ErrorsName(){ runMyTest("testErrorsDefaultBundle0ErrorsName", ""); } public void testErrorsDefaultBundle2ErrorsName(){ runMyTest("testErrorsDefaultBundle2ErrorsName", ""); } public void testErrorsAlternateBundle0ErrorsName(){ runMyTest("testErrorsAlternateBundle0ErrorsName", ""); } public void testErrorsAlternateBundle2ErrorsName(){ runMyTest("testErrorsAlternateBundle2ErrorsName", ""); } public void testErrorsDefaultBundle0ErrorsName_fr(){ runMyTest("testErrorsDefaultBundle0ErrorsName_fr", "fr"); } public void testErrorsDefaultBundle2ErrorsName_fr(){ runMyTest("testErrorsDefaultBundle2ErrorsName_fr", "fr"); } public void testErrorsAlternateBundle0ErrorsName_fr(){ runMyTest("testErrorsAlternateBundle0ErrorsName_fr", "fr"); } public void testErrorsAlternateBundle2ErrorsName_fr(){ runMyTest("testErrorsAlternateBundle2ErrorsName_fr", "fr"); } public void testErrorsDefaultBundle0ErrorsLocaleName(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsDefaultBundle0ErrorsLocaleName", ""); } public void testErrorsDefaultBundle2ErrorsLocaleName(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsDefaultBundle2ErrorsLocaleName", ""); } public void testErrorsAlternateBundle0ErrorsLocaleName(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsAlternateBundle0ErrorsLocaleName", ""); } public void testErrorsAlternateBundle2ErrorsLocaleName(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsAlternateBundle2ErrorsLocaleName", ""); } public void testErrorsDefaultBundle0ErrorsLocaleName_fr(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsDefaultBundle0ErrorsLocaleName_fr", ""); } public void testErrorsDefaultBundle2ErrorsLocaleName_fr(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsDefaultBundle2ErrorsLocaleName_fr", ""); } public void testErrorsAlternateBundle0ErrorsLocaleName_fr(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsAlternateBundle0ErrorsLocaleName_fr", ""); } public void testErrorsAlternateBundle2ErrorsLocaleName_fr(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsAlternateBundle2ErrorsLocaleName_fr", ""); } } 1.1 jakarta-struts/src/test/org/apache/struts/taglib/html/TestErrorsTag2.java Index: TestErrorsTag2.java =================================================================== /* * The Apache Software License, Version 1.1 * * Copyright (c) 1999-2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Struts", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * */ package org.apache.struts.taglib.html; import java.util.Locale; import javax.servlet.jsp.PageContext; import junit.framework.Test; import junit.framework.TestSuite; import org.apache.cactus.JspTestCase; import org.apache.struts.Globals; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; /** * Suite of unit tests for the * <code>org.apache.struts.taglib.bean.ErrorsTag</code> class. * * @author James Mitchell */ public class TestErrorsTag2 extends JspTestCase { /** * Defines the testcase name for JUnit. * * @param theName the testcase's name. */ public TestErrorsTag2(String theName) { super(theName); } /** * Start the tests. * * @param theArgs the arguments. Not used */ public static void main(String[] theArgs) { junit.awtui.TestRunner.main(new String[] {TestErrorsTag2.class.getName()}); } /** * @return a test suite (<code>TestSuite</code>) that includes all methods * starting with "test" */ public static Test suite() { // All methods starting with "test" will be executed in the test suite. return new TestSuite(TestErrorsTag2.class); } private void runMyTest(String whichTest, String locale){ request.setAttribute("runTest", whichTest); pageContext.setAttribute(Globals.LOCALE_KEY, new Locale(locale, locale), PageContext.SESSION_SCOPE); try { pageContext.forward("/test/org/apache/struts/taglib/html/TestErrorsTag2.jsp"); } catch (Exception e) { e.printStackTrace(); fail("There is a problem that is preventing the tests to continue!"); } } private void formatAndTest(String compare, String output) { //fix for introduced carriage return / line feeds output = output.replaceAll("\r",""); output = output.replaceAll("\n",""); output = output.trim(); assertEquals(compare, output); } /* * Testing ErrorsTag. */ public void testErrorsDefaultBundle0ErrorsProperty(){ runMyTest("testErrorsDefaultBundle0ErrorsProperty", ""); } public void testErrorsDefaultBundle2ErrorsProperty(){ runMyTest("testErrorsDefaultBundle2ErrorsProperty", ""); } public void testErrorsAlternateBundle0ErrorsProperty(){ runMyTest("testErrorsAlternateBundle0ErrorsProperty", ""); } public void testErrorsAlternateBundle2ErrorsProperty(){ runMyTest("testErrorsAlternateBundle2ErrorsProperty", ""); } public void testErrorsDefaultBundle0ErrorsProperty_fr(){ runMyTest("testErrorsDefaultBundle0ErrorsProperty_fr", "fr"); } public void testErrorsDefaultBundle2ErrorsProperty_fr(){ runMyTest("testErrorsDefaultBundle2ErrorsProperty_fr", "fr"); } public void testErrorsAlternateBundle0ErrorsProperty_fr(){ runMyTest("testErrorsAlternateBundle0ErrorsProperty_fr", "fr"); } public void testErrorsAlternateBundle2ErrorsProperty_fr(){ runMyTest("testErrorsAlternateBundle2ErrorsProperty_fr", "fr"); } public void testErrorsDefaultBundle0ErrorsLocaleProperty(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsDefaultBundle0ErrorsLocaleProperty", ""); } public void testErrorsDefaultBundle2ErrorsLocaleProperty(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsDefaultBundle2ErrorsLocaleProperty", ""); } public void testErrorsAlternateBundle0ErrorsLocaleProperty(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsAlternateBundle0ErrorsLocaleProperty", ""); } public void testErrorsAlternateBundle2ErrorsLocaleProperty(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsAlternateBundle2ErrorsLocaleProperty", ""); } public void testErrorsDefaultBundle0ErrorsLocaleProperty_fr(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsDefaultBundle0ErrorsLocaleProperty_fr", ""); } public void testErrorsDefaultBundle2ErrorsLocaleProperty_fr(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsDefaultBundle2ErrorsLocaleProperty_fr", ""); } public void testErrorsAlternateBundle0ErrorsLocaleProperty_fr(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsAlternateBundle0ErrorsLocaleProperty_fr", ""); } public void testErrorsAlternateBundle2ErrorsLocaleProperty_fr(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsAlternateBundle2ErrorsLocaleProperty_fr", ""); } public void testErrorsDefaultBundle0ErrorsNameProperty(){ runMyTest("testErrorsDefaultBundle0ErrorsNameProperty", ""); } public void testErrorsDefaultBundle2ErrorsNameProperty(){ runMyTest("testErrorsDefaultBundle2ErrorsNameProperty", ""); } public void testErrorsAlternateBundle0ErrorsNameProperty(){ runMyTest("testErrorsAlternateBundle0ErrorsNameProperty", ""); } public void testErrorsAlternateBundle2ErrorsNameProperty(){ runMyTest("testErrorsAlternateBundle2ErrorsNameProperty", ""); } public void testErrorsDefaultBundle0ErrorsNameProperty_fr(){ runMyTest("testErrorsDefaultBundle0ErrorsNameProperty_fr", "fr"); } public void testErrorsDefaultBundle2ErrorsNameProperty_fr(){ runMyTest("testErrorsDefaultBundle2ErrorsNameProperty_fr", "fr"); } public void testErrorsAlternateBundle0ErrorsNameProperty_fr(){ runMyTest("testErrorsAlternateBundle0ErrorsNameProperty_fr", "fr"); } public void testErrorsAlternateBundle2ErrorsNameProperty_fr(){ runMyTest("testErrorsAlternateBundle2ErrorsNameProperty_fr", "fr"); } public void testErrorsDefaultBundle0ErrorsLocaleNameProperty(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsDefaultBundle0ErrorsLocaleNameProperty", ""); } public void testErrorsDefaultBundle2ErrorsLocaleNameProperty(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsDefaultBundle2ErrorsLocaleNameProperty", ""); } public void testErrorsAlternateBundle0ErrorsLocaleNameProperty(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsAlternateBundle0ErrorsLocaleNameProperty", ""); } public void testErrorsAlternateBundle2ErrorsLocaleNameProperty(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsAlternateBundle2ErrorsLocaleNameProperty", ""); } public void testErrorsDefaultBundle0ErrorsLocaleNameProperty_fr(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsDefaultBundle0ErrorsLocaleNameProperty_fr", ""); } public void testErrorsDefaultBundle2ErrorsLocaleNameProperty_fr(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsDefaultBundle2ErrorsLocaleNameProperty_fr", ""); } public void testErrorsAlternateBundle0ErrorsLocaleNameProperty_fr(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsAlternateBundle0ErrorsLocaleNameProperty_fr", ""); } public void testErrorsAlternateBundle2ErrorsLocaleNameProperty_fr(){ pageContext.setAttribute("MY_LOCALE_KEY", new Locale("fr", "fr"), PageContext.SESSION_SCOPE); runMyTest("testErrorsAlternateBundle2ErrorsLocaleNameProperty_fr", ""); } } 1.1 jakarta-struts/src/test/org/apache/struts/taglib/html/TestFileTag1.java Index: TestFileTag1.java =================================================================== /* * The Apache Software License, Version 1.1 * * Copyright (c) 1999-2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Struts", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * */ package org.apache.struts.taglib.html; import java.util.Locale; import javax.servlet.jsp.PageContext; import junit.framework.Test; import junit.framework.TestSuite; import org.apache.cactus.JspTestCase; import org.apache.struts.Globals; import org.apache.struts.taglib.SimpleBeanForTesting; /** * Suite of unit tests for the * <code>org.apache.struts.taglib.bean.FileTag</code> class. * * @author James Mitchell */ public class TestFileTag1 extends JspTestCase { /** * Defines the testcase name for JUnit. * * @param theName the testcase's name. */ public TestFileTag1(String theName) { super(theName); } /** * Start the tests. * * @param theArgs the arguments. Not used */ public static void main(String[] theArgs) { junit.awtui.TestRunner.main(new String[] {TestFileTag1.class.getName()}); } /** * @return a test suite (<code>TestSuite</code>) that includes all methods * starting with "test" */ public static Test suite() { // All methods starting with "test" will be executed in the test suite. return new TestSuite(TestFileTag1.class); } private void runMyTest(String whichTest, String locale){ pageContext.setAttribute(Globals.LOCALE_KEY, new Locale(locale, locale), PageContext.SESSION_SCOPE); pageContext.setAttribute(Constants.BEAN_KEY, new SimpleBeanForTesting("Test Value"), PageContext.REQUEST_SCOPE); request.setAttribute("runTest", whichTest); try { pageContext.forward("/test/org/apache/struts/taglib/html/TestFileTag1.jsp"); } catch (Exception e) { e.printStackTrace(); fail("There is a problem that is preventing the tests to continue!"); } } /* * Testing FileTag. */ public void testFileProperty(){ runMyTest("testFileProperty", ""); } public void testFilePropertyAccept(){ runMyTest("testFilePropertyAccept", ""); } public void testFilePropertyAccesskey(){ runMyTest("testFilePropertyAccesskey", ""); } public void testFilePropertyAlt(){ runMyTest("testFilePropertyAlt", ""); } public void testFilePropertyAltKey1(){ runMyTest("testFilePropertyAltKey1", ""); } public void testFilePropertyAltKey2(){ runMyTest("testFilePropertyAltKey2", ""); } public void testFilePropertyAltKey_fr1(){ runMyTest("testFilePropertyAltKey1_fr", "fr"); } public void testFilePropertyAltKey_fr2(){ runMyTest("testFilePropertyAltKey2_fr", "fr"); } public void testFilePropertyDisabled_True(){ runMyTest("testFilePropertyDisabled_True", ""); } public void testFilePropertyDisabled_False1(){ runMyTest("testFilePropertyDisabled_False1", ""); } public void testFilePropertyDisabled_False2(){ runMyTest("testFilePropertyDisabled_False2", ""); } public void testFilePropertyOnblur(){ runMyTest("testFilePropertyOnblur", ""); } public void testFilePropertyOnchange(){ runMyTest("testFilePropertyOnchange", ""); } public void testFilePropertyOnclick(){ runMyTest("testFilePropertyOnclick", ""); } public void testFilePropertyOndblclick(){ runMyTest("testFilePropertyOndblclick", ""); } public void testFilePropertyOnfocus(){ runMyTest("testFilePropertyOnfocus", ""); } public void testFilePropertyOnkeydown(){ runMyTest("testFilePropertyOnkeydown", ""); } public void testFilePropertyOnkeypress(){ runMyTest("testFilePropertyOnkeypress", ""); } public void testFilePropertyOnkeyup(){ runMyTest("testFilePropertyOnkeyup", ""); } public void testFilePropertyOnmousedown(){ runMyTest("testFilePropertyOnmousedown", ""); } public void testFilePropertyOnmousemove(){ runMyTest("testFilePropertyOnmousemove", ""); } public void testFilePropertyOnmouseout(){ runMyTest("testFilePropertyOnmouseout", ""); } public void testFilePropertyOnmouseover(){ runMyTest("testFilePropertyOnmouseover", ""); } public void testFilePropertyOnmouseup(){ runMyTest("testFilePropertyOnmouseup", ""); } } 1.1 jakarta-struts/src/test/org/apache/struts/taglib/html/TestFileTag2.java Index: TestFileTag2.java =================================================================== /* * The Apache Software License, Version 1.1 * * Copyright (c) 1999-2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Struts", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * */ package org.apache.struts.taglib.html; import java.util.ArrayList; import java.util.HashMap; import java.util.Hashtable; import java.util.Locale; import java.util.StringTokenizer; import javax.servlet.jsp.PageContext; import junit.framework.Test; import junit.framework.TestSuite; import org.apache.cactus.JspTestCase; import org.apache.struts.Globals; import org.apache.struts.taglib.SimpleBeanForTesting; /** * Suite of unit tests for the * <code>org.apache.struts.taglib.bean.FileTag</code> class. * * @author James Mitchell */ public class TestFileTag2 extends JspTestCase { /** * Defines the testcase name for JUnit. * * @param theName the testcase's name. */ public TestFileTag2(String theName) { super(theName); } /** * Start the tests. * * @param theArgs the arguments. Not used */ public static void main(String[] theArgs) { junit.awtui.TestRunner.main(new String[] {TestFileTag2.class.getName()}); } /** * @return a test suite (<code>TestSuite</code>) that includes all methods * starting with "test" */ public static Test suite() { // All methods starting with "test" will be executed in the test suite. return new TestSuite(TestFileTag2.class); } private void runMyTest(String whichTest, String locale){ pageContext.setAttribute(Globals.LOCALE_KEY, new Locale(locale, locale), PageContext.SESSION_SCOPE); pageContext.setAttribute(Constants.BEAN_KEY, new SimpleBeanForTesting("Test Value"), PageContext.REQUEST_SCOPE); request.setAttribute("runTest", whichTest); try { pageContext.forward("/test/org/apache/struts/taglib/html/TestFileTag2.jsp"); } catch (Exception e) { e.printStackTrace(); fail("There is a problem that is preventing the tests to continue!"); } } /* * Testing FileTag. */ public void testFilePropertyStyle(){ runMyTest("testFilePropertyStyle", ""); } public void testFilePropertyStyleClass(){ runMyTest("testFilePropertyStyleClass", ""); } public void testFilePropertyStyleId(){ runMyTest("testFilePropertyStyleId", ""); } public void testFilePropertyTabindex(){ runMyTest("testFilePropertyTabindex", ""); } public void testFilePropertyTitle(){ runMyTest("testFilePropertyTitle", ""); } public void testFilePropertyTitleKey(){ runMyTest("testFilePropertyTitleKey", ""); } public void testFilePropertyTitleKey_fr(){ runMyTest("testFilePropertyTitleKey_fr", "fr"); } public void testFilePropertyValue(){ runMyTest("testFilePropertyValue", ""); } public void testFilePropertyBodyContent(){ runMyTest("testFilePropertyBodyContent", ""); } public void testFilePropertyBodyContentMessageKey(){ runMyTest("testFilePropertyBodyContentMessageKey", ""); } public void testFilePropertyBodyContentMessageKey_fr(){ runMyTest("testFilePropertyBodyContentMessageKey_fr", "fr"); } public void testFilePropertyIndexedArray(){ ArrayList lst = new ArrayList(); lst.add("Test Message"); pageContext.setAttribute("lst", lst, PageContext.REQUEST_SCOPE); runMyTest("testFilePropertyIndexedArray", ""); } public void testFilePropertyIndexedArrayProperty(){ SimpleBeanForTesting sbft = new SimpleBeanForTesting(); ArrayList lst = new ArrayList(); lst.add("Test Message"); sbft.setList(lst); pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE); runMyTest("testFilePropertyIndexedArrayProperty", ""); } public void testFilePropertyIndexedMap(){ HashMap map = new HashMap(); map.put("tst1", "Test Message"); pageContext.setAttribute("lst", map, PageContext.REQUEST_SCOPE); runMyTest("testFilePropertyIndexedMap", ""); } public void testFilePropertyIndexedMapProperty(){ SimpleBeanForTesting sbft = new SimpleBeanForTesting(); HashMap map = new HashMap(); map.put("tst1", "Test Message"); sbft.setMap(map); pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE); runMyTest("testFilePropertyIndexedMapProperty", ""); } public void testFilePropertyIndexedEnumeration(){ StringTokenizer st = new StringTokenizer("Test Message"); pageContext.setAttribute("lst", st, PageContext.REQUEST_SCOPE); runMyTest("testFilePropertyIndexedEnumeration", ""); } public void testFilePropertyIndexedEnumerationProperty(){ SimpleBeanForTesting sbft = new SimpleBeanForTesting(); StringTokenizer st = new StringTokenizer("Test Message"); sbft.setEnumeration(st); pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE); runMyTest("testFilePropertyIndexedEnumerationProperty", ""); } } 1.1 jakarta-struts/web/test/test/org/apache/struts/taglib/html/TestErrorsTag1.jsp Index: TestErrorsTag1.jsp =================================================================== <%@ page contentType="text/html;charset=UTF-8" language="java" %> <[EMAIL PROTECTED] import="junit.framework.Assert"%> <[EMAIL PROTECTED] import="org.apache.struts.Globals"%> <[EMAIL PROTECTED] import="org.apache.struts.action.ActionError"%> <[EMAIL PROTECTED] import="org.apache.struts.action.ActionErrors"%> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <!-- Default Bundle --> <logic:equal name="runTest" value="testErrorsDefaultBundle0Errors"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle2Errors"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("default.testing.errors.tag")); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("default.testing.errors.tag2")); request.setAttribute(Globals.ERROR_KEY, errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<default_errors_header> <default_errors_prefix>My Errors Text <default_errors_suffix><default_errors_prefix>My Errors Text 2 <default_errors_suffix><default_errors_footer> </bean:define> </logic:equal> <!-- Alternate Bundle --> <logic:equal name="runTest" value="testErrorsAlternateBundle0Errors"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle2Errors"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("alternate.testing.errors.tag")); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("alternate.testing.errors.tag2")); request.setAttribute(Globals.ERROR_KEY, errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors bundle="alternate"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<alternate_errors_header> <alternate_errors_prefix>My Alternate Errors Text <alternate_errors_suffix><alternate_errors_prefix>My Alternate Errors Text 2 <alternate_errors_suffix><alternate_errors_footer> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle0Errors_fr"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <!-- French Locale --> <logic:equal name="runTest" value="testErrorsDefaultBundle2Errors_fr"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("default.testing.errors.tag")); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("default.testing.errors.tag2")); request.setAttribute(Globals.ERROR_KEY, errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<default_errors_header_fr> <default_errors_prefix_fr>My Errors Text (fr) <default_errors_suffix_fr><default_errors_prefix_fr>My Errors Text 2 (fr) <default_errors_suffix_fr><default_errors_footer_fr> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle0Errors_fr"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle2Errors_fr"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("alternate.testing.errors.tag")); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("alternate.testing.errors.tag2")); request.setAttribute(Globals.ERROR_KEY, errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors bundle="alternate"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<alternate_errors_header_fr> <alternate_errors_prefix_fr>My Alternate Errors Text (fr) <alternate_errors_suffix_fr><alternate_errors_prefix_fr>My Alternate Errors Text 2 (fr) <alternate_errors_suffix_fr><alternate_errors_footer_fr> </bean:define> </logic:equal> <!-- Specified Locale --> <logic:equal name="runTest" value="testErrorsDefaultBundle0ErrorsLocale"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle2ErrorsLocale"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("default.testing.errors.tag")); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("default.testing.errors.tag2")); request.setAttribute(Globals.ERROR_KEY, errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<default_errors_header_fr> <default_errors_prefix_fr>My Errors Text (fr) <default_errors_suffix_fr><default_errors_prefix_fr>My Errors Text 2 (fr) <default_errors_suffix_fr><default_errors_footer_fr> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle0ErrorsLocale"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle2ErrorsLocale"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("alternate.testing.errors.tag")); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("alternate.testing.errors.tag2")); request.setAttribute(Globals.ERROR_KEY, errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" bundle="alternate"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<alternate_errors_header_fr> <alternate_errors_prefix_fr>My Alternate Errors Text (fr) <alternate_errors_suffix_fr><alternate_errors_prefix_fr>My Alternate Errors Text 2 (fr) <alternate_errors_suffix_fr><alternate_errors_footer_fr> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle0ErrorsLocale_fr"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle2ErrorsLocale_fr"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("default.testing.errors.tag")); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("default.testing.errors.tag2")); request.setAttribute(Globals.ERROR_KEY, errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<default_errors_header_fr> <default_errors_prefix_fr>My Errors Text (fr) <default_errors_suffix_fr><default_errors_prefix_fr>My Errors Text 2 (fr) <default_errors_suffix_fr><default_errors_footer_fr> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle0ErrorsLocale_fr"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle2ErrorsLocale_fr"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("alternate.testing.errors.tag")); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("alternate.testing.errors.tag2")); request.setAttribute(Globals.ERROR_KEY, errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" bundle="alternate"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<alternate_errors_header_fr> <alternate_errors_prefix_fr>My Alternate Errors Text (fr) <alternate_errors_suffix_fr><alternate_errors_prefix_fr>My Alternate Errors Text 2 (fr) <alternate_errors_suffix_fr><alternate_errors_footer_fr> </bean:define> </logic:equal> <!-- Name --> <logic:equal name="runTest" value="testErrorsDefaultBundle0ErrorsName"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors name="MY_ERRORS_KEY"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle2ErrorsName"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("default.testing.errors.tag")); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("default.testing.errors.tag2")); request.setAttribute("MY_ERRORS_KEY", errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors name="MY_ERRORS_KEY"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<default_errors_header> <default_errors_prefix>My Errors Text <default_errors_suffix><default_errors_prefix>My Errors Text 2 <default_errors_suffix><default_errors_footer> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle0ErrorsName"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors name="MY_ERRORS_KEY"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle2ErrorsName"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("alternate.testing.errors.tag")); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("alternate.testing.errors.tag2")); request.setAttribute("MY_ERRORS_KEY", errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors bundle="alternate" name="MY_ERRORS_KEY"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<alternate_errors_header> <alternate_errors_prefix>My Alternate Errors Text <alternate_errors_suffix><alternate_errors_prefix>My Alternate Errors Text 2 <alternate_errors_suffix><alternate_errors_footer> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle0ErrorsName_fr"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors name="MY_ERRORS_KEY"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle2ErrorsName_fr"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("default.testing.errors.tag")); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("default.testing.errors.tag2")); request.setAttribute("MY_ERRORS_KEY", errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors name="MY_ERRORS_KEY"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<default_errors_header_fr> <default_errors_prefix_fr>My Errors Text (fr) <default_errors_suffix_fr><default_errors_prefix_fr>My Errors Text 2 (fr) <default_errors_suffix_fr><default_errors_footer_fr> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle0ErrorsName_fr"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors name="MY_ERRORS_KEY"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle2ErrorsName_fr"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("alternate.testing.errors.tag")); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("alternate.testing.errors.tag2")); request.setAttribute("MY_ERRORS_KEY", errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors bundle="alternate" name="MY_ERRORS_KEY"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<alternate_errors_header_fr> <alternate_errors_prefix_fr>My Alternate Errors Text (fr) <alternate_errors_suffix_fr><alternate_errors_prefix_fr>My Alternate Errors Text 2 (fr) <alternate_errors_suffix_fr><alternate_errors_footer_fr> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle0ErrorsLocaleName"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" name="MY_ERRORS_KEY"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle2ErrorsLocaleName"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("default.testing.errors.tag")); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("default.testing.errors.tag2")); request.setAttribute("MY_ERRORS_KEY", errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" name="MY_ERRORS_KEY"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<default_errors_header_fr> <default_errors_prefix_fr>My Errors Text (fr) <default_errors_suffix_fr><default_errors_prefix_fr>My Errors Text 2 (fr) <default_errors_suffix_fr><default_errors_footer_fr> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle0ErrorsLocaleName"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" name="MY_ERRORS_KEY"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle2ErrorsLocaleName"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("alternate.testing.errors.tag")); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("alternate.testing.errors.tag2")); request.setAttribute("MY_ERRORS_KEY", errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" bundle="alternate" name="MY_ERRORS_KEY"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<alternate_errors_header_fr> <alternate_errors_prefix_fr>My Alternate Errors Text (fr) <alternate_errors_suffix_fr><alternate_errors_prefix_fr>My Alternate Errors Text 2 (fr) <alternate_errors_suffix_fr><alternate_errors_footer_fr> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle0ErrorsLocaleName_fr"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" name="MY_ERRORS_KEY"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle2ErrorsLocaleName_fr"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("default.testing.errors.tag")); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("default.testing.errors.tag2")); request.setAttribute("MY_ERRORS_KEY", errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" name="MY_ERRORS_KEY"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<default_errors_header_fr> <default_errors_prefix_fr>My Errors Text (fr) <default_errors_suffix_fr><default_errors_prefix_fr>My Errors Text 2 (fr) <default_errors_suffix_fr><default_errors_footer_fr> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle0ErrorsLocaleName_fr"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" name="MY_ERRORS_KEY"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle2ErrorsLocaleName_fr"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("alternate.testing.errors.tag")); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("alternate.testing.errors.tag2")); request.setAttribute("MY_ERRORS_KEY", errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" bundle="alternate" name="MY_ERRORS_KEY"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<alternate_errors_header_fr> <alternate_errors_prefix_fr>My Alternate Errors Text (fr) <alternate_errors_suffix_fr><alternate_errors_prefix_fr>My Alternate Errors Text 2 (fr) <alternate_errors_suffix_fr><alternate_errors_footer_fr> </bean:define> </logic:equal> <% String expected = ""; String compareTo = ""; if (pageContext.getAttribute("EXPECTED_RESULTS") != null){ expected=pageContext.getAttribute("TEST_RESULTS").toString(); } if (pageContext.getAttribute("TEST_RESULTS") != null){ compareTo=pageContext.getAttribute("EXPECTED_RESULTS").toString(); } Assert.assertEquals(compareTo, expected); %> 1.1 jakarta-struts/web/test/test/org/apache/struts/taglib/html/TestErrorsTag2.jsp Index: TestErrorsTag2.jsp =================================================================== <%@ page contentType="text/html;charset=UTF-8" language="java" %> <[EMAIL PROTECTED] import="junit.framework.Assert"%> <[EMAIL PROTECTED] import="org.apache.struts.Globals"%> <[EMAIL PROTECTED] import="org.apache.struts.action.ActionError"%> <[EMAIL PROTECTED] import="org.apache.struts.action.ActionErrors"%> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <!-- Property --> <!-- Default Bundle --> <logic:equal name="runTest" value="testErrorsDefaultBundle0ErrorsProperty"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle2ErrorsProperty"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add("someProperty", new ActionError("default.testing.errors.tag")); errors.add("someProperty", new ActionError("default.testing.errors.tag2")); request.setAttribute(Globals.ERROR_KEY, errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<default_errors_header> <default_errors_prefix>My Errors Text <default_errors_suffix><default_errors_prefix>My Errors Text 2 <default_errors_suffix><default_errors_footer> </bean:define> </logic:equal> <!-- Alternate Bundle --> <logic:equal name="runTest" value="testErrorsAlternateBundle0ErrorsProperty"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle2ErrorsProperty"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add("someProperty", new ActionError("alternate.testing.errors.tag")); errors.add("someProperty", new ActionError("alternate.testing.errors.tag2")); request.setAttribute(Globals.ERROR_KEY, errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors bundle="alternate" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<alternate_errors_header> <alternate_errors_prefix>My Alternate Errors Text <alternate_errors_suffix><alternate_errors_prefix>My Alternate Errors Text 2 <alternate_errors_suffix><alternate_errors_footer> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle0ErrorsProperty_fr"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <!-- French Locale --> <logic:equal name="runTest" value="testErrorsDefaultBundle2ErrorsProperty_fr"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add("someProperty", new ActionError("default.testing.errors.tag")); errors.add("someProperty", new ActionError("default.testing.errors.tag2")); request.setAttribute(Globals.ERROR_KEY, errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<default_errors_header_fr> <default_errors_prefix_fr>My Errors Text (fr) <default_errors_suffix_fr><default_errors_prefix_fr>My Errors Text 2 (fr) <default_errors_suffix_fr><default_errors_footer_fr> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle0ErrorsProperty_fr"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle2ErrorsProperty_fr"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add("someProperty", new ActionError("alternate.testing.errors.tag")); errors.add("someProperty", new ActionError("alternate.testing.errors.tag2")); request.setAttribute(Globals.ERROR_KEY, errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors bundle="alternate" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<alternate_errors_header_fr> <alternate_errors_prefix_fr>My Alternate Errors Text (fr) <alternate_errors_suffix_fr><alternate_errors_prefix_fr>My Alternate Errors Text 2 (fr) <alternate_errors_suffix_fr><alternate_errors_footer_fr> </bean:define> </logic:equal> <!-- Specified Locale --> <logic:equal name="runTest" value="testErrorsDefaultBundle0ErrorsLocaleProperty"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle2ErrorsLocaleProperty"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add("someProperty", new ActionError("default.testing.errors.tag")); errors.add("someProperty", new ActionError("default.testing.errors.tag2")); request.setAttribute(Globals.ERROR_KEY, errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<default_errors_header_fr> <default_errors_prefix_fr>My Errors Text (fr) <default_errors_suffix_fr><default_errors_prefix_fr>My Errors Text 2 (fr) <default_errors_suffix_fr><default_errors_footer_fr> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle0ErrorsLocaleProperty"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle2ErrorsLocaleProperty"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add("someProperty", new ActionError("alternate.testing.errors.tag")); errors.add("someProperty", new ActionError("alternate.testing.errors.tag2")); request.setAttribute(Globals.ERROR_KEY, errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" bundle="alternate" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<alternate_errors_header_fr> <alternate_errors_prefix_fr>My Alternate Errors Text (fr) <alternate_errors_suffix_fr><alternate_errors_prefix_fr>My Alternate Errors Text 2 (fr) <alternate_errors_suffix_fr><alternate_errors_footer_fr> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle0ErrorsLocaleProperty_fr"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle2ErrorsLocaleProperty_fr"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add("someProperty", new ActionError("default.testing.errors.tag")); errors.add("someProperty", new ActionError("default.testing.errors.tag2")); request.setAttribute(Globals.ERROR_KEY, errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<default_errors_header_fr> <default_errors_prefix_fr>My Errors Text (fr) <default_errors_suffix_fr><default_errors_prefix_fr>My Errors Text 2 (fr) <default_errors_suffix_fr><default_errors_footer_fr> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle0ErrorsLocaleProperty_fr"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle2ErrorsLocaleProperty_fr"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add("someProperty", new ActionError("alternate.testing.errors.tag")); errors.add("someProperty", new ActionError("alternate.testing.errors.tag2")); request.setAttribute(Globals.ERROR_KEY, errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" bundle="alternate" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<alternate_errors_header_fr> <alternate_errors_prefix_fr>My Alternate Errors Text (fr) <alternate_errors_suffix_fr><alternate_errors_prefix_fr>My Alternate Errors Text 2 (fr) <alternate_errors_suffix_fr><alternate_errors_footer_fr> </bean:define> </logic:equal> <!-- Name --> <logic:equal name="runTest" value="testErrorsDefaultBundle0ErrorsName"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors name="MY_ERRORS_KEY" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle2ErrorsName"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add("someProperty", new ActionError("default.testing.errors.tag")); errors.add("someProperty", new ActionError("default.testing.errors.tag2")); request.setAttribute("MY_ERRORS_KEY", errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors name="MY_ERRORS_KEY" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<default_errors_header> <default_errors_prefix>My Errors Text <default_errors_suffix><default_errors_prefix>My Errors Text 2 <default_errors_suffix><default_errors_footer> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle0ErrorsName"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors name="MY_ERRORS_KEY" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle2ErrorsName"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add("someProperty", new ActionError("alternate.testing.errors.tag")); errors.add("someProperty", new ActionError("alternate.testing.errors.tag2")); request.setAttribute("MY_ERRORS_KEY", errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors bundle="alternate" name="MY_ERRORS_KEY" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<alternate_errors_header> <alternate_errors_prefix>My Alternate Errors Text <alternate_errors_suffix><alternate_errors_prefix>My Alternate Errors Text 2 <alternate_errors_suffix><alternate_errors_footer> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle0ErrorsName_fr"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors name="MY_ERRORS_KEY" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle2ErrorsName_fr"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add("someProperty", new ActionError("default.testing.errors.tag")); errors.add("someProperty", new ActionError("default.testing.errors.tag2")); request.setAttribute("MY_ERRORS_KEY", errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors name="MY_ERRORS_KEY" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<default_errors_header_fr> <default_errors_prefix_fr>My Errors Text (fr) <default_errors_suffix_fr><default_errors_prefix_fr>My Errors Text 2 (fr) <default_errors_suffix_fr><default_errors_footer_fr> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle0ErrorsName_fr"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors name="MY_ERRORS_KEY" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle2ErrorsName_fr"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add("someProperty", new ActionError("alternate.testing.errors.tag")); errors.add("someProperty", new ActionError("alternate.testing.errors.tag2")); request.setAttribute("MY_ERRORS_KEY", errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors bundle="alternate" name="MY_ERRORS_KEY" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<alternate_errors_header_fr> <alternate_errors_prefix_fr>My Alternate Errors Text (fr) <alternate_errors_suffix_fr><alternate_errors_prefix_fr>My Alternate Errors Text 2 (fr) <alternate_errors_suffix_fr><alternate_errors_footer_fr> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle0ErrorsLocaleNameProperty"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" name="MY_ERRORS_KEY" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle2ErrorsLocaleNameProperty"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add("someProperty", new ActionError("default.testing.errors.tag")); errors.add("someProperty", new ActionError("default.testing.errors.tag2")); request.setAttribute("MY_ERRORS_KEY", errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" name="MY_ERRORS_KEY" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<default_errors_header_fr> <default_errors_prefix_fr>My Errors Text (fr) <default_errors_suffix_fr><default_errors_prefix_fr>My Errors Text 2 (fr) <default_errors_suffix_fr><default_errors_footer_fr> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle0ErrorsLocaleNameProperty"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" name="MY_ERRORS_KEY" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle2ErrorsLocaleNameProperty"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add("someProperty", new ActionError("alternate.testing.errors.tag")); errors.add("someProperty", new ActionError("alternate.testing.errors.tag2")); request.setAttribute("MY_ERRORS_KEY", errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" bundle="alternate" name="MY_ERRORS_KEY" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<alternate_errors_header_fr> <alternate_errors_prefix_fr>My Alternate Errors Text (fr) <alternate_errors_suffix_fr><alternate_errors_prefix_fr>My Alternate Errors Text 2 (fr) <alternate_errors_suffix_fr><alternate_errors_footer_fr> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle0ErrorsLocaleNameProperty_fr"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" name="MY_ERRORS_KEY" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsDefaultBundle2ErrorsLocaleNameProperty_fr"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add("someProperty", new ActionError("default.testing.errors.tag")); errors.add("someProperty", new ActionError("default.testing.errors.tag2")); request.setAttribute("MY_ERRORS_KEY", errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" name="MY_ERRORS_KEY" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<default_errors_header_fr> <default_errors_prefix_fr>My Errors Text (fr) <default_errors_suffix_fr><default_errors_prefix_fr>My Errors Text 2 (fr) <default_errors_suffix_fr><default_errors_footer_fr> </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle0ErrorsLocaleNameProperty_fr"> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" name="MY_ERRORS_KEY" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here: </bean:define> </logic:equal> <logic:equal name="runTest" value="testErrorsAlternateBundle2ErrorsLocaleNameProperty_fr"> <% //This should be done in your action. I do it here to keep the tests simple. ActionErrors errors = new ActionErrors(); errors.add("someProperty", new ActionError("alternate.testing.errors.tag")); errors.add("someProperty", new ActionError("alternate.testing.errors.tag2")); request.setAttribute("MY_ERRORS_KEY", errors); %> <bean:define id="EXPECTED_RESULTS" toScope="page"> My Errors go here:<html:errors locale="MY_LOCALE_KEY" bundle="alternate" name="MY_ERRORS_KEY" property="someProperty"/> </bean:define> <bean:define id="TEST_RESULTS" toScope="page"> My Errors go here:<alternate_errors_header_fr> <alternate_errors_prefix_fr>My Alternate Errors Text (fr) <alternate_errors_suffix_fr><alternate_errors_prefix_fr>My Alternate Errors Text 2 (fr) <alternate_errors_suffix_fr><alternate_errors_footer_fr> </bean:define> </logic:equal> <% String expected = ""; String compareTo = ""; if (pageContext.getAttribute("EXPECTED_RESULTS") != null){ expected=pageContext.getAttribute("TEST_RESULTS").toString(); } if (pageContext.getAttribute("TEST_RESULTS") != null){ compareTo=pageContext.getAttribute("EXPECTED_RESULTS").toString(); } Assert.assertEquals(compareTo, expected); %> 1.1 jakarta-struts/web/test/test/org/apache/struts/taglib/html/TestFileTag1.jsp Index: TestFileTag1.jsp =================================================================== <%@ page contentType="text/html;charset=UTF-8" language="java" %> <[EMAIL PROTECTED] import="junit.framework.Assert"%> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <logic:equal name="runTest" value="testFileProperty"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value"> </bean:define> </logic:equal> enctype="multipart/form-data" accept="image/jpeg, image/gif" <logic:equal name="runTest" value="testFilePropertyAccept"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" accept="image/jpeg, image/gif"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" accept="image/jpeg, image/gif" value="Test Value"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyAccesskey"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" accesskey="a"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" accesskey="a" value="Test Value"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyAlt"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" alt="Testing alt attribute"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value" alt="Testing alt attribute"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyAltKey1"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" altKey="default.bundle.message"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value" alt="Testing Message"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyAltKey2"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" altKey="no.such.key"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyAltKey1_fr"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" altKey="default.bundle.message"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value" alt="Message D'Essai"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyAltKey2_fr"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" altKey="no.such.key"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyDisabled_True"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" disabled="true"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value" disabled="disabled"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyDisabled_False1"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" disabled="false"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyDisabled_False2"> <!-- This was changed recently by overwhelming consensus. The prior functionality was very counter-intuitive. It used to be that putting disabled="false" was the same as putting disabled="true". Craig sited the confusion is due to the HTML spec. --> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" disabled="anything but true"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyOnblur"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" onblur="Put script here"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value" onblur="Put script here"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyOnchange"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" onchange="Put script here"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value" onchange="Put script here"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyOnclick"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" onclick="Put script here"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value" onclick="Put script here"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyOndblclick"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" ondblclick="Put script here"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value" ondblclick="Put script here"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyOnfocus"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" onfocus="Put script here"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value" onfocus="Put script here"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyOnkeydown"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" onkeydown="Put script here"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value" onkeydown="Put script here"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyOnkeypress"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" onkeypress="Put script here"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value" onkeypress="Put script here"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyOnkeyup"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" onkeyup="Put script here"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value" onkeyup="Put script here"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyOnmousedown"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" onmousedown="Put script here"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value" onmousedown="Put script here"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyOnmousemove"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" onmousemove="Put script here"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value" onmousemove="Put script here"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyOnmouseout"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" onmouseout="Put script here"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value" onmouseout="Put script here"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyOnmouseover"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" onmouseover="Put script here"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value" onmouseover="Put script here"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyOnmouseup"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" onmouseup="Put script here"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value" onmouseup="Put script here"> </bean:define> </logic:equal> <% Assert.assertEquals( pageContext.getAttribute("TEST_RESULTS").toString(), pageContext.getAttribute("EXPECTED_RESULTS").toString() ); %> 1.1 jakarta-struts/web/test/test/org/apache/struts/taglib/html/TestFileTag2.jsp Index: TestFileTag2.jsp =================================================================== <%@ page contentType="text/html;charset=UTF-8" language="java" %> <[EMAIL PROTECTED] import="junit.framework.Assert"%> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <logic:equal name="runTest" value="testFilePropertyStyle"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" style="Put something here"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value" style="Put something here"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyStyleClass"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" styleClass="Put something here"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value" class="Put something here"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyStyleId"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" styleId="Put something here"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value" id="Put something here"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyTabindex"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" tabindex="Put something here"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" tabindex="Put something here" value="Test Value"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyTitle"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" title="Put something here"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value" title="Put something here"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyTitleKey"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" titleKey="default.bundle.message"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value" title="Testing Message"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyTitleKey_fr"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" titleKey="default.bundle.message"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value" title="Message D'Essai"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyValue"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string" value ="Put something here"/> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Put something here"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyBodyContent"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string">File Value Here</html:file> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyBodyContentMessageKey"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string"> <bean:message key="default.bundle.message"/> </html:file> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyBodyContentMessageKey_fr"> <bean:define id="TEST_RESULTS" toScope="page"> <html:file property="string"> <bean:message key="default.bundle.message"/> </html:file> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="string" value="Test Value"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyIndexedArray"> <bean:define id="TEST_RESULTS" toScope="page"> <logic:iterate id="indivItem" name="lst"> <html:file property="string" indexed="true"/> </logic:iterate> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="org.apache.struts.taglib.html.BEAN[0].string" value="Test Value"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyIndexedArrayProperty"> <bean:define id="TEST_RESULTS" toScope="page"> <logic:iterate id="indivItem" name="lst" property="list"> <html:file property="string" indexed="true"/> </logic:iterate> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="org.apache.struts.taglib.html.BEAN[0].string" value="Test Value"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyIndexedMap"> <bean:define id="TEST_RESULTS" toScope="page"> <logic:iterate id="indivItem" name="lst"> <html:file property="string" indexed="true"/> </logic:iterate> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="org.apache.struts.taglib.html.BEAN[0].string" value="Test Value"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyIndexedMapProperty"> <bean:define id="TEST_RESULTS" toScope="page"> <logic:iterate id="indivItem" name="lst" property="map"> <html:file property="string" indexed="true"/> </logic:iterate> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="org.apache.struts.taglib.html.BEAN[0].string" value="Test Value"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyIndexedEnumeration"> <bean:define id="TEST_RESULTS" toScope="page"> <logic:iterate id="indivItem" name="lst"> <html:file property="string" indexed="true"/> </logic:iterate> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="org.apache.struts.taglib.html.BEAN[0].string" value="Test Value"> <input type="file" name="org.apache.struts.taglib.html.BEAN[1].string" value="Test Value"> </bean:define> </logic:equal> <logic:equal name="runTest" value="testFilePropertyIndexedEnumerationProperty"> <bean:define id="TEST_RESULTS" toScope="page"> <logic:iterate id="indivItem" name="lst" property="enumeration"> <html:file property="string" indexed="true"/> </logic:iterate> </bean:define> <bean:define id="EXPECTED_RESULTS" toScope="page"> <input type="file" name="org.apache.struts.taglib.html.BEAN[0].string" value="Test Value"> <input type="file" name="org.apache.struts.taglib.html.BEAN[1].string" value="Test Value"> </bean:define> </logic:equal> <% Assert.assertEquals( pageContext.getAttribute("TEST_RESULTS").toString(), pageContext.getAttribute("EXPECTED_RESULTS").toString() ); %>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]