jmitchell    2003/03/13 17:19:46

  Added:       src/test/org/apache/struts/taglib/html TestLinkTag3.java
                        TestLinkTag4.java
  Log:
  New tests
  
  Revision  Changes    Path
  1.1                  
jakarta-struts/src/test/org/apache/struts/taglib/html/TestLinkTag3.java
  
  Index: TestLinkTag3.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-struts/src/test/org/apache/struts/taglib/html/TestLinkTag3.java,v 
1.1 2003/03/14 01:19:46 jmitchell Exp $
   * $Revision: 1.1 $
   * $Date: 2003/03/14 01:19:46 $
   * 
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2003 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.HashMap;
  import java.util.Locale;
  import java.util.ArrayList;
  import java.util.StringTokenizer;
  
  import javax.servlet.jsp.JspException;
  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;
  import org.apache.struts.util.LabelValueBean;
  
  /**
   * Suite of unit tests for the
   * <code>org.apache.struts.taglib.bean.LinkTag</code> class.
   *
   * @author James Mitchell
   */
  public class TestLinkTag3 extends JspTestCase {
  
      /**
       * Defines the testcase name for JUnit.
       *
       * @param theName the testcase's name.
       */
      public TestLinkTag3(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[] {TestLinkTag3.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(TestLinkTag3.class);
      }
  
      private void runMyTest(String whichTest, String locale){
        pageContext.setAttribute(Globals.LOCALE_KEY, new Locale(locale, locale), 
PageContext.SESSION_SCOPE);
                request.setAttribute("runTest", whichTest);
          try {
                        
pageContext.forward("/test/org/apache/struts/taglib/html/TestLinkTag3.jsp");
                }
                catch (Exception e) {
                        e.printStackTrace();
                        fail("There is a problem that is preventing the tests to 
continue!");
                }
      }
  
      /*
       * Testing LinkTag.
       */
  
  //--------Testing attributes using forward------
  
      public void testLinkAction(){
          runMyTest("testLinkAction", "");
      }
  
      public void testLinkActionAccesskey(){
          runMyTest("testLinkActionAccesskey", "");
      }
  
      public void testLinkActionAnchor(){
          runMyTest("testLinkActionAnchor", "");
      }
  
      public void testLinkActionIndexedArray(){ 
        ArrayList lst = new ArrayList();
        lst.add("Test Message");
        pageContext.setAttribute("lst", lst, PageContext.REQUEST_SCOPE);
        runMyTest("testLinkActionIndexedArray", "");
        }
  
      public void testLinkActionIndexedArrayProperty(){ 
        SimpleBeanForTesting sbft = new SimpleBeanForTesting();
        ArrayList lst = new ArrayList();
        lst.add("Test Message");
        sbft.setList(lst);
        pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
        runMyTest("testLinkActionIndexedArrayProperty", "");
        }
  
      public void testLinkActionIndexedMap(){ 
        HashMap map = new HashMap();
        map.put("tst1", "Test Message");
        pageContext.setAttribute("lst", map, PageContext.REQUEST_SCOPE);
        runMyTest("testLinkActionIndexedMap", "");
        }
  
      public void testLinkActionIndexedMapProperty(){ 
        SimpleBeanForTesting sbft = new SimpleBeanForTesting();
        HashMap map = new HashMap();
        map.put("tst1", "Test Message");
        sbft.setMap(map);
        pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
        runMyTest("testLinkActionIndexedMapProperty", "");
        }
  
      public void testLinkActionIndexedEnumeration(){ 
        StringTokenizer st = new StringTokenizer("Test Message");
        pageContext.setAttribute("lst", st, PageContext.REQUEST_SCOPE);
        runMyTest("testLinkActionIndexedEnumeration", "");
        }
  
      public void testLinkActionIndexedEnumerationProperty(){ 
        SimpleBeanForTesting sbft = new SimpleBeanForTesting();
        StringTokenizer st = new StringTokenizer("Test Message");
        sbft.setEnumeration(st);
        pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
        runMyTest("testLinkActionIndexedEnumerationProperty", "");
        }
  
  
      public void testLinkActionIndexedAlternateIdArray(){ 
        ArrayList lst = new ArrayList();
        lst.add("Test Message");
        pageContext.setAttribute("lst", lst, PageContext.REQUEST_SCOPE);
        runMyTest("testLinkActionIndexedAlternateIdArray", "");
        }
  
      public void testLinkActionIndexedAlternateIdArrayProperty(){ 
        SimpleBeanForTesting sbft = new SimpleBeanForTesting();
        ArrayList lst = new ArrayList();
        lst.add("Test Message");
        sbft.setList(lst);
        pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
        runMyTest("testLinkActionIndexedAlternateIdArrayProperty", "");
        }
  
      public void testLinkActionIndexedAlternateIdMap(){ 
        HashMap map = new HashMap();
        map.put("tst1", "Test Message");
        pageContext.setAttribute("lst", map, PageContext.REQUEST_SCOPE);
        runMyTest("testLinkActionIndexedAlternateIdMap", "");
        }
  
      public void testLinkActionIndexedAlternateIdMapProperty(){ 
        SimpleBeanForTesting sbft = new SimpleBeanForTesting();
        HashMap map = new HashMap();
        map.put("tst1", "Test Message");
        sbft.setMap(map);
        pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
        runMyTest("testLinkActionIndexedAlternateIdMapProperty", "");
        }
  
      public void testLinkActionIndexedAlternateIdEnumeration(){ 
        StringTokenizer st = new StringTokenizer("Test Message");
        pageContext.setAttribute("lst", st, PageContext.REQUEST_SCOPE);
        runMyTest("testLinkActionIndexedAlternateIdEnumeration", "");
        }
  
      public void testLinkActionIndexedAlternateIdEnumerationProperty(){ 
        SimpleBeanForTesting sbft = new SimpleBeanForTesting();
        StringTokenizer st = new StringTokenizer("Test Message");
        sbft.setEnumeration(st);
        pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
        runMyTest("testLinkActionIndexedAlternateIdEnumerationProperty", "");
        }
  
      public void testLinkActionLinkName(){
         runMyTest("testLinkActionLinkName", "");
      }
  
      public void testLinkActionNameNoScope(){
                HashMap map = new HashMap();
                map.put("param1","value1");
                map.put("param2","value2");
                map.put("param3","value3");
                map.put("param4","value4");
                pageContext.setAttribute("paramMap", map, PageContext.REQUEST_SCOPE);
         runMyTest("testLinkActionNameNoScope", "");
      }
  
      public void testLinkActionNamePropertyNoScope(){
                HashMap map = new HashMap();
                map.put("param1","value1");
                map.put("param2","value2");
                map.put("param3","value3");
                map.put("param4","value4");
                SimpleBeanForTesting sbft = new SimpleBeanForTesting(map);
                pageContext.setAttribute("paramPropertyMap", sbft, 
PageContext.REQUEST_SCOPE);
         runMyTest("testLinkActionNamePropertyNoScope", "");
      }
  
      public void testLinkActionNameApplicationScope(){
                HashMap map = new HashMap();
                map.put("param1","value1");
                map.put("param2","value2");
                map.put("param3","value3");
                map.put("param4","value4");
                pageContext.setAttribute("paramMap", map, 
PageContext.APPLICATION_SCOPE);
         runMyTest("testLinkActionNameApplicationScope", "");
      }
  
      public void testLinkActionNamePropertyApplicationScope(){
                HashMap map = new HashMap();
                map.put("param1","value1");
                map.put("param2","value2");
                map.put("param3","value3");
                map.put("param4","value4");
                SimpleBeanForTesting sbft = new SimpleBeanForTesting(map);
                pageContext.setAttribute("paramPropertyMap", sbft, 
PageContext.APPLICATION_SCOPE);
         runMyTest("testLinkActionNamePropertyApplicationScope", "");
      }
  
      public void testLinkActionNameSessionScope(){
                HashMap map = new HashMap();
                map.put("param1","value1");
                map.put("param2","value2");
                map.put("param3","value3");
                map.put("param4","value4");
                pageContext.setAttribute("paramMap", map, PageContext.SESSION_SCOPE);
         runMyTest("testLinkActionNameSessionScope", "");
      }
  
      public void testLinkActionNamePropertySessionScope(){
                HashMap map = new HashMap();
                map.put("param1","value1");
                map.put("param2","value2");
                map.put("param3","value3");
                map.put("param4","value4");
                SimpleBeanForTesting sbft = new SimpleBeanForTesting(map);
                pageContext.setAttribute("paramPropertyMap", sbft, 
PageContext.SESSION_SCOPE);
         runMyTest("testLinkActionNamePropertySessionScope", "");
      }
  
      public void testLinkActionNameRequestScope(){
                HashMap map = new HashMap();
                map.put("param1","value1");
                map.put("param2","value2");
                map.put("param3","value3");
                map.put("param4","value4");
                pageContext.setAttribute("paramMap", map, PageContext.REQUEST_SCOPE);
         runMyTest("testLinkActionNameRequestScope", "");
      }
  
      public void testLinkActionNamePropertyRequestScope(){
                HashMap map = new HashMap();
                map.put("param1","value1");
                map.put("param2","value2");
                map.put("param3","value3");
                map.put("param4","value4");
                SimpleBeanForTesting sbft = new SimpleBeanForTesting(map);
                pageContext.setAttribute("paramPropertyMap", sbft, 
PageContext.REQUEST_SCOPE);
         runMyTest("testLinkActionNamePropertyRequestScope", "");
      }
  
  }
  
  
  
  1.1                  
jakarta-struts/src/test/org/apache/struts/taglib/html/TestLinkTag4.java
  
  Index: TestLinkTag4.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-struts/src/test/org/apache/struts/taglib/html/TestLinkTag4.java,v 
1.1 2003/03/14 01:19:46 jmitchell Exp $
   * $Revision: 1.1 $
   * $Date: 2003/03/14 01:19:46 $
   * 
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2003 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.JspException;
  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;
  import org.apache.struts.util.LabelValueBean;
  
  /**
   * Suite of unit tests for the
   * <code>org.apache.struts.taglib.bean.FrameTag</code> class.
   *
   * @author James Mitchell
   */
  public class TestLinkTag4 extends JspTestCase {
  
      /**
       * Defines the testcase name for JUnit.
       *
       * @param theName the testcase's name.
       */
      public TestLinkTag4(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[] {TestLinkTag4.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(TestLinkTag4.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/TestLinkTag4.jsp");
                }
                catch (Exception e) {
                        e.printStackTrace();
                        fail("There is a problem that is preventing the tests to 
continue!");
                }
      }
  
      /*
       * Testing FrameTag.
       */
  
  //--------Testing attributes using forward------
      public void testLinkActionOnblur(){
          runMyTest("testLinkActionOnblur", "");
      }
  
      public void testLinkActionOnclick(){
          runMyTest("testLinkActionOnclick", "");
      }
  
      public void testLinkActionOndblclick(){
          runMyTest("testLinkActionOndblclick", "");
      }
  
      public void testLinkActionOnfocus(){
          runMyTest("testLinkActionOnfocus", "");
      }
  
      public void testLinkActionOnkeydown(){
          runMyTest("testLinkActionOnkeydown", "");
      }
  
      public void testLinkActionOnkeypress(){
          runMyTest("testLinkActionOnkeypress", "");
      }
  
      public void testLinkActionOnkeyup(){
          runMyTest("testLinkActionOnkeyup", "");
      }
  
      public void testLinkActionOnmousedown(){
          runMyTest("testLinkActionOnmousedown", "");
      }
  
      public void testLinkActionOnmousemove(){
          runMyTest("testLinkActionOnmousemove", "");
      }
  
      public void testLinkActionOnmouseout(){
          runMyTest("testLinkActionOnmouseout", "");
      }
  
      public void testLinkActionOnmouseover(){
          runMyTest("testLinkActionOnmouseover", "");
      }
  
      public void testLinkActionOnmouseup(){
          runMyTest("testLinkActionOnmouseup", "");
      }
  
      public void testLinkActionParamIdParamNameNoScope(){
                pageContext.setAttribute("paramName", "paramValue", 
PageContext.REQUEST_SCOPE);
          runMyTest("testLinkActionParamIdParamNameNoScope", "");
      }
  
      public void testLinkActionParamIdParamNameParamPropertyNoScope(){
        SimpleBeanForTesting sbft = new SimpleBeanForTesting("paramPropertyValue");
                pageContext.setAttribute("testingParamProperty", sbft, 
PageContext.REQUEST_SCOPE);
          runMyTest("testLinkActionParamIdParamNameParamPropertyNoScope", "");
      }
  
      public void testLinkActionParamIdParamNameApplicationScope(){
                pageContext.setAttribute("paramName", "paramValue", 
PageContext.APPLICATION_SCOPE);
          runMyTest("testLinkActionParamIdParamNameApplicationScope", "");
      }
  
      public void testLinkActionParamIdParamNameParamPropertyApplicationScope(){
        SimpleBeanForTesting sbft = new SimpleBeanForTesting("paramPropertyValue");
                pageContext.setAttribute("testingParamProperty", sbft, 
PageContext.APPLICATION_SCOPE);
          runMyTest("testLinkActionParamIdParamNameParamPropertyApplicationScope", "");
      }
  
      public void testLinkActionParamIdParamNameSessionScope(){
                pageContext.setAttribute("paramName", "paramValue", 
PageContext.SESSION_SCOPE);
          runMyTest("testLinkActionParamIdParamNameSessionScope", "");
      }
  
      public void testLinkActionParamIdParamNameParamPropertySessionScope(){
        SimpleBeanForTesting sbft = new SimpleBeanForTesting("paramPropertyValue");
                pageContext.setAttribute("testingParamProperty", sbft, 
PageContext.SESSION_SCOPE);
          runMyTest("testLinkActionParamIdParamNameParamPropertySessionScope", "");
      }
  
      public void testLinkActionParamIdParamNameRequestScope(){
                pageContext.setAttribute("paramName", "paramValue", 
PageContext.REQUEST_SCOPE);
          runMyTest("testLinkActionParamIdParamNameRequestScope", "");
      }
  
      public void testLinkActionParamIdParamNameParamPropertyRequestScope(){
        SimpleBeanForTesting sbft = new SimpleBeanForTesting("paramPropertyValue");
                pageContext.setAttribute("testingParamProperty", sbft, 
PageContext.REQUEST_SCOPE);
          runMyTest("testLinkActionParamIdParamNameParamPropertyRequestScope", "");
      }
  
  
      public void testLinkActionStyle(){
          runMyTest("testLinkActionStyle", "");
      }
  
      public void testLinkActionStyleClass(){
          runMyTest("testLinkActionStyleClass", "");
      }
  
      public void testLinkActionStyleId(){
          runMyTest("testLinkActionStyleId", "");
      }
  
      public void testLinkActionTabIndex(){
          runMyTest("testLinkActionTabIndex", "");
      }
  
      public void testLinkActionTarget(){
          runMyTest("testLinkActionTarget", "");
      }
  
  
  
  
  
  
  
      public void testLinkActionTitle(){
          runMyTest("testLinkActionTitle", "");
      }
  
      public void testLinkActionTitleKey(){
          runMyTest("testLinkActionTitleKey", "");
      }
  
      public void testLinkActionTransaction(){
        pageContext.setAttribute(Globals.TRANSACTION_TOKEN_KEY, "Some_Token_Here", 
PageContext.SESSION_SCOPE);
          runMyTest("testLinkActionTransaction", "");
      }
  
  
  
  
        
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to