You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by jm...@apache.org on 2003/03/14 02:20:02 UTC

cvs commit: jakarta-struts/src/test/org/apache/struts/taglib/html TestLinkTag5.java TestLinkTag6.java TestLinkTag7.java TestLinkTag8.java

jmitchell    2003/03/13 17:20:02

  Added:       src/test/org/apache/struts/taglib/html TestLinkTag5.java
                        TestLinkTag6.java TestLinkTag7.java
                        TestLinkTag8.java
  Log:
  New tests
  
  Revision  Changes    Path
  1.1                  jakarta-struts/src/test/org/apache/struts/taglib/html/TestLinkTag5.java
  
  Index: TestLinkTag5.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/test/org/apache/struts/taglib/html/TestLinkTag5.java,v 1.1 2003/03/14 01:20:02 jmitchell Exp $
   * $Revision: 1.1 $
   * $Date: 2003/03/14 01:20:02 $
   * 
   * ====================================================================
   * 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 apache@apache.org.
   *
   * 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 TestLinkTag5 extends JspTestCase {
  
      /**
       * Defines the testcase name for JUnit.
       *
       * @param theName the testcase's name.
       */
      public TestLinkTag5(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[] {TestLinkTag5.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(TestLinkTag5.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/TestLinkTag5.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 testLinkHref(){
          runMyTest("testLinkHref", "");
      }
  
      public void testLinkHrefAccesskey(){
          runMyTest("testLinkHrefAccesskey", "");
      }
  
      public void testLinkHrefAnchor(){
          runMyTest("testLinkHrefAnchor", "");
      }
  
      public void testLinkHrefIndexedArray(){ 
      	ArrayList lst = new ArrayList();
      	lst.add("Test Message");
      	pageContext.setAttribute("lst", lst, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkHrefIndexedArray", "");
  	}
  
      public void testLinkHrefIndexedArrayProperty(){ 
      	SimpleBeanForTesting sbft = new SimpleBeanForTesting();
      	ArrayList lst = new ArrayList();
      	lst.add("Test Message");
      	sbft.setList(lst);
      	pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkHrefIndexedArrayProperty", "");
  	}
  
      public void testLinkHrefIndexedMap(){ 
      	HashMap map = new HashMap();
      	map.put("tst1", "Test Message");
      	pageContext.setAttribute("lst", map, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkHrefIndexedMap", "");
  	}
  
      public void testLinkHrefIndexedMapProperty(){ 
      	SimpleBeanForTesting sbft = new SimpleBeanForTesting();
      	HashMap map = new HashMap();
      	map.put("tst1", "Test Message");
      	sbft.setMap(map);
      	pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkHrefIndexedMapProperty", "");
  	}
  
      public void testLinkHrefIndexedEnumeration(){ 
      	StringTokenizer st = new StringTokenizer("Test Message");
      	pageContext.setAttribute("lst", st, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkHrefIndexedEnumeration", "");
  	}
  
      public void testLinkHrefIndexedEnumerationProperty(){ 
      	SimpleBeanForTesting sbft = new SimpleBeanForTesting();
      	StringTokenizer st = new StringTokenizer("Test Message");
      	sbft.setEnumeration(st);
      	pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkHrefIndexedEnumerationProperty", "");
  	}
  
  
      public void testLinkHrefIndexedAlternateIdArray(){ 
      	ArrayList lst = new ArrayList();
      	lst.add("Test Message");
      	pageContext.setAttribute("lst", lst, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkHrefIndexedAlternateIdArray", "");
  	}
  
      public void testLinkHrefIndexedAlternateIdArrayProperty(){ 
      	SimpleBeanForTesting sbft = new SimpleBeanForTesting();
      	ArrayList lst = new ArrayList();
      	lst.add("Test Message");
      	sbft.setList(lst);
      	pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkHrefIndexedAlternateIdArrayProperty", "");
  	}
  
      public void testLinkHrefIndexedAlternateIdMap(){ 
      	HashMap map = new HashMap();
      	map.put("tst1", "Test Message");
      	pageContext.setAttribute("lst", map, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkHrefIndexedAlternateIdMap", "");
  	}
  
      public void testLinkHrefIndexedAlternateIdMapProperty(){ 
      	SimpleBeanForTesting sbft = new SimpleBeanForTesting();
      	HashMap map = new HashMap();
      	map.put("tst1", "Test Message");
      	sbft.setMap(map);
      	pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkHrefIndexedAlternateIdMapProperty", "");
  	}
  
      public void testLinkHrefIndexedAlternateIdEnumeration(){ 
      	StringTokenizer st = new StringTokenizer("Test Message");
      	pageContext.setAttribute("lst", st, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkHrefIndexedAlternateIdEnumeration", "");
  	}
  
      public void testLinkHrefIndexedAlternateIdEnumerationProperty(){ 
      	SimpleBeanForTesting sbft = new SimpleBeanForTesting();
      	StringTokenizer st = new StringTokenizer("Test Message");
      	sbft.setEnumeration(st);
      	pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkHrefIndexedAlternateIdEnumerationProperty", "");
  	}
  
      public void testLinkHrefLinkName(){
         runMyTest("testLinkHrefLinkName", "");
      }
  
      public void testLinkHrefNameNoScope(){
   		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("testLinkHrefNameNoScope", "");
      }
  
      public void testLinkHrefNamePropertyNoScope(){
   		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("testLinkHrefNamePropertyNoScope", "");
      }
  
      public void testLinkHrefNameApplicationScope(){
   		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("testLinkHrefNameApplicationScope", "");
      }
  
      public void testLinkHrefNamePropertyApplicationScope(){
   		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("testLinkHrefNamePropertyApplicationScope", "");
      }
  
      public void testLinkHrefNameSessionScope(){
   		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("testLinkHrefNameSessionScope", "");
      }
  
      public void testLinkHrefNamePropertySessionScope(){
   		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("testLinkHrefNamePropertySessionScope", "");
      }
  
      public void testLinkHrefNameRequestScope(){
   		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("testLinkHrefNameRequestScope", "");
      }
  
      public void testLinkHrefNamePropertyRequestScope(){
   		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("testLinkHrefNamePropertyRequestScope", "");
      }
  
  }
  
  
  
  1.1                  jakarta-struts/src/test/org/apache/struts/taglib/html/TestLinkTag6.java
  
  Index: TestLinkTag6.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/test/org/apache/struts/taglib/html/TestLinkTag6.java,v 1.1 2003/03/14 01:20:02 jmitchell Exp $
   * $Revision: 1.1 $
   * $Date: 2003/03/14 01:20:02 $
   * 
   * ====================================================================
   * 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 apache@apache.org.
   *
   * 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 TestLinkTag6 extends JspTestCase {
  
      /**
       * Defines the testcase name for JUnit.
       *
       * @param theName the testcase's name.
       */
      public TestLinkTag6(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[] {TestLinkTag6.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(TestLinkTag6.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/TestLinkTag6.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 testLinkHrefOnblur(){
          runMyTest("testLinkHrefOnblur", "");
      }
  
      public void testLinkHrefOnclick(){
          runMyTest("testLinkHrefOnclick", "");
      }
  
      public void testLinkHrefOndblclick(){
          runMyTest("testLinkHrefOndblclick", "");
      }
  
      public void testLinkHrefOnfocus(){
          runMyTest("testLinkHrefOnfocus", "");
      }
  
      public void testLinkHrefOnkeydown(){
          runMyTest("testLinkHrefOnkeydown", "");
      }
  
      public void testLinkHrefOnkeypress(){
          runMyTest("testLinkHrefOnkeypress", "");
      }
  
      public void testLinkHrefOnkeyup(){
          runMyTest("testLinkHrefOnkeyup", "");
      }
  
      public void testLinkHrefOnmousedown(){
          runMyTest("testLinkHrefOnmousedown", "");
      }
  
      public void testLinkHrefOnmousemove(){
          runMyTest("testLinkHrefOnmousemove", "");
      }
  
      public void testLinkHrefOnmouseout(){
          runMyTest("testLinkHrefOnmouseout", "");
      }
  
      public void testLinkHrefOnmouseover(){
          runMyTest("testLinkHrefOnmouseover", "");
      }
  
      public void testLinkHrefOnmouseup(){
          runMyTest("testLinkHrefOnmouseup", "");
      }
  
      public void testLinkHrefParamIdParamNameNoScope(){
  		pageContext.setAttribute("paramName", "paramValue", PageContext.REQUEST_SCOPE);
          runMyTest("testLinkHrefParamIdParamNameNoScope", "");
      }
  
      public void testLinkHrefParamIdParamNameParamPropertyNoScope(){
      	SimpleBeanForTesting sbft = new SimpleBeanForTesting("paramPropertyValue");
  		pageContext.setAttribute("testingParamProperty", sbft, PageContext.REQUEST_SCOPE);
          runMyTest("testLinkHrefParamIdParamNameParamPropertyNoScope", "");
      }
  
      public void testLinkHrefParamIdParamNameApplicationScope(){
  		pageContext.setAttribute("paramName", "paramValue", PageContext.APPLICATION_SCOPE);
          runMyTest("testLinkHrefParamIdParamNameApplicationScope", "");
      }
  
      public void testLinkHrefParamIdParamNameParamPropertyApplicationScope(){
      	SimpleBeanForTesting sbft = new SimpleBeanForTesting("paramPropertyValue");
  		pageContext.setAttribute("testingParamProperty", sbft, PageContext.APPLICATION_SCOPE);
          runMyTest("testLinkHrefParamIdParamNameParamPropertyApplicationScope", "");
      }
  
      public void testLinkHrefParamIdParamNameSessionScope(){
  		pageContext.setAttribute("paramName", "paramValue", PageContext.SESSION_SCOPE);
          runMyTest("testLinkHrefParamIdParamNameSessionScope", "");
      }
  
      public void testLinkHrefParamIdParamNameParamPropertySessionScope(){
      	SimpleBeanForTesting sbft = new SimpleBeanForTesting("paramPropertyValue");
  		pageContext.setAttribute("testingParamProperty", sbft, PageContext.SESSION_SCOPE);
          runMyTest("testLinkHrefParamIdParamNameParamPropertySessionScope", "");
      }
  
      public void testLinkHrefParamIdParamNameRequestScope(){
  		pageContext.setAttribute("paramName", "paramValue", PageContext.REQUEST_SCOPE);
          runMyTest("testLinkHrefParamIdParamNameRequestScope", "");
      }
  
      public void testLinkHrefParamIdParamNameParamPropertyRequestScope(){
      	SimpleBeanForTesting sbft = new SimpleBeanForTesting("paramPropertyValue");
  		pageContext.setAttribute("testingParamProperty", sbft, PageContext.REQUEST_SCOPE);
          runMyTest("testLinkHrefParamIdParamNameParamPropertyRequestScope", "");
      }
  
  
      public void testLinkHrefStyle(){
          runMyTest("testLinkHrefStyle", "");
      }
  
      public void testLinkHrefStyleClass(){
          runMyTest("testLinkHrefStyleClass", "");
      }
  
      public void testLinkHrefStyleId(){
          runMyTest("testLinkHrefStyleId", "");
      }
  
      public void testLinkHrefTabIndex(){
          runMyTest("testLinkHrefTabIndex", "");
      }
  
      public void testLinkHrefTarget(){
          runMyTest("testLinkHrefTarget", "");
      }
  
  
  
  
  
  
  
      public void testLinkHrefTitle(){
          runMyTest("testLinkHrefTitle", "");
      }
  
      public void testLinkHrefTitleKey(){
          runMyTest("testLinkHrefTitleKey", "");
      }
  
      public void testLinkHrefTransaction(){
      	pageContext.setAttribute(Globals.TRANSACTION_TOKEN_KEY, "Some_Token_Here", PageContext.SESSION_SCOPE);
          runMyTest("testLinkHrefTransaction", "");
      }
  
  
  
  
  	
  }
  
  
  
  1.1                  jakarta-struts/src/test/org/apache/struts/taglib/html/TestLinkTag7.java
  
  Index: TestLinkTag7.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/test/org/apache/struts/taglib/html/TestLinkTag7.java,v 1.1 2003/03/14 01:20:02 jmitchell Exp $
   * $Revision: 1.1 $
   * $Date: 2003/03/14 01:20:02 $
   * 
   * ====================================================================
   * 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 apache@apache.org.
   *
   * 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 TestLinkTag7 extends JspTestCase {
  
      /**
       * Defines the testcase name for JUnit.
       *
       * @param theName the testcase's name.
       */
      public TestLinkTag7(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[] {TestLinkTag7.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(TestLinkTag7.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/TestLinkTag7.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 testLinkPage(){
          runMyTest("testLinkPage", "");
      }
  
      public void testLinkPageAccesskey(){
          runMyTest("testLinkPageAccesskey", "");
      }
  
      public void testLinkPageAnchor(){
          runMyTest("testLinkPageAnchor", "");
      }
  
      public void testLinkPageIndexedArray(){ 
      	ArrayList lst = new ArrayList();
      	lst.add("Test Message");
      	pageContext.setAttribute("lst", lst, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkPageIndexedArray", "");
  	}
  
      public void testLinkPageIndexedArrayProperty(){ 
      	SimpleBeanForTesting sbft = new SimpleBeanForTesting();
      	ArrayList lst = new ArrayList();
      	lst.add("Test Message");
      	sbft.setList(lst);
      	pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkPageIndexedArrayProperty", "");
  	}
  
      public void testLinkPageIndexedMap(){ 
      	HashMap map = new HashMap();
      	map.put("tst1", "Test Message");
      	pageContext.setAttribute("lst", map, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkPageIndexedMap", "");
  	}
  
      public void testLinkPageIndexedMapProperty(){ 
      	SimpleBeanForTesting sbft = new SimpleBeanForTesting();
      	HashMap map = new HashMap();
      	map.put("tst1", "Test Message");
      	sbft.setMap(map);
      	pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkPageIndexedMapProperty", "");
  	}
  
      public void testLinkPageIndexedEnumeration(){ 
      	StringTokenizer st = new StringTokenizer("Test Message");
      	pageContext.setAttribute("lst", st, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkPageIndexedEnumeration", "");
  	}
  
      public void testLinkPageIndexedEnumerationProperty(){ 
      	SimpleBeanForTesting sbft = new SimpleBeanForTesting();
      	StringTokenizer st = new StringTokenizer("Test Message");
      	sbft.setEnumeration(st);
      	pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkPageIndexedEnumerationProperty", "");
  	}
  
  
      public void testLinkPageIndexedAlternateIdArray(){ 
      	ArrayList lst = new ArrayList();
      	lst.add("Test Message");
      	pageContext.setAttribute("lst", lst, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkPageIndexedAlternateIdArray", "");
  	}
  
      public void testLinkPageIndexedAlternateIdArrayProperty(){ 
      	SimpleBeanForTesting sbft = new SimpleBeanForTesting();
      	ArrayList lst = new ArrayList();
      	lst.add("Test Message");
      	sbft.setList(lst);
      	pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkPageIndexedAlternateIdArrayProperty", "");
  	}
  
      public void testLinkPageIndexedAlternateIdMap(){ 
      	HashMap map = new HashMap();
      	map.put("tst1", "Test Message");
      	pageContext.setAttribute("lst", map, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkPageIndexedAlternateIdMap", "");
  	}
  
      public void testLinkPageIndexedAlternateIdMapProperty(){ 
      	SimpleBeanForTesting sbft = new SimpleBeanForTesting();
      	HashMap map = new HashMap();
      	map.put("tst1", "Test Message");
      	sbft.setMap(map);
      	pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkPageIndexedAlternateIdMapProperty", "");
  	}
  
      public void testLinkPageIndexedAlternateIdEnumeration(){ 
      	StringTokenizer st = new StringTokenizer("Test Message");
      	pageContext.setAttribute("lst", st, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkPageIndexedAlternateIdEnumeration", "");
  	}
  
      public void testLinkPageIndexedAlternateIdEnumerationProperty(){ 
      	SimpleBeanForTesting sbft = new SimpleBeanForTesting();
      	StringTokenizer st = new StringTokenizer("Test Message");
      	sbft.setEnumeration(st);
      	pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
      	runMyTest("testLinkPageIndexedAlternateIdEnumerationProperty", "");
  	}
  
      public void testLinkPageLinkName(){
         runMyTest("testLinkPageLinkName", "");
      }
  
      public void testLinkPageNameNoScope(){
   		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("testLinkPageNameNoScope", "");
      }
  
      public void testLinkPageNamePropertyNoScope(){
   		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("testLinkPageNamePropertyNoScope", "");
      }
  
      public void testLinkPageNameApplicationScope(){
   		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("testLinkPageNameApplicationScope", "");
      }
  
      public void testLinkPageNamePropertyApplicationScope(){
   		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("testLinkPageNamePropertyApplicationScope", "");
      }
  
      public void testLinkPageNameSessionScope(){
   		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("testLinkPageNameSessionScope", "");
      }
  
      public void testLinkPageNamePropertySessionScope(){
   		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("testLinkPageNamePropertySessionScope", "");
      }
  
      public void testLinkPageNameRequestScope(){
   		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("testLinkPageNameRequestScope", "");
      }
  
      public void testLinkPageNamePropertyRequestScope(){
   		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("testLinkPageNamePropertyRequestScope", "");
      }
  
  }
  
  
  
  1.1                  jakarta-struts/src/test/org/apache/struts/taglib/html/TestLinkTag8.java
  
  Index: TestLinkTag8.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/test/org/apache/struts/taglib/html/TestLinkTag8.java,v 1.1 2003/03/14 01:20:02 jmitchell Exp $
   * $Revision: 1.1 $
   * $Date: 2003/03/14 01:20:02 $
   * 
   * ====================================================================
   * 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 apache@apache.org.
   *
   * 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 TestLinkTag8 extends JspTestCase {
  
      /**
       * Defines the testcase name for JUnit.
       *
       * @param theName the testcase's name.
       */
      public TestLinkTag8(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[] {TestLinkTag8.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(TestLinkTag8.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/TestLinkTag8.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 testLinkPageOnblur(){
          runMyTest("testLinkPageOnblur", "");
      }
  
      public void testLinkPageOnclick(){
          runMyTest("testLinkPageOnclick", "");
      }
  
      public void testLinkPageOndblclick(){
          runMyTest("testLinkPageOndblclick", "");
      }
  
      public void testLinkPageOnfocus(){
          runMyTest("testLinkPageOnfocus", "");
      }
  
      public void testLinkPageOnkeydown(){
          runMyTest("testLinkPageOnkeydown", "");
      }
  
      public void testLinkPageOnkeypress(){
          runMyTest("testLinkPageOnkeypress", "");
      }
  
      public void testLinkPageOnkeyup(){
          runMyTest("testLinkPageOnkeyup", "");
      }
  
      public void testLinkPageOnmousedown(){
          runMyTest("testLinkPageOnmousedown", "");
      }
  
      public void testLinkPageOnmousemove(){
          runMyTest("testLinkPageOnmousemove", "");
      }
  
      public void testLinkPageOnmouseout(){
          runMyTest("testLinkPageOnmouseout", "");
      }
  
      public void testLinkPageOnmouseover(){
          runMyTest("testLinkPageOnmouseover", "");
      }
  
      public void testLinkPageOnmouseup(){
          runMyTest("testLinkPageOnmouseup", "");
      }
  
      public void testLinkPageParamIdParamNameNoScope(){
  		pageContext.setAttribute("paramName", "paramValue", PageContext.REQUEST_SCOPE);
          runMyTest("testLinkPageParamIdParamNameNoScope", "");
      }
  
      public void testLinkPageParamIdParamNameParamPropertyNoScope(){
      	SimpleBeanForTesting sbft = new SimpleBeanForTesting("paramPropertyValue");
  		pageContext.setAttribute("testingParamProperty", sbft, PageContext.REQUEST_SCOPE);
          runMyTest("testLinkPageParamIdParamNameParamPropertyNoScope", "");
      }
  
      public void testLinkPageParamIdParamNameApplicationScope(){
  		pageContext.setAttribute("paramName", "paramValue", PageContext.APPLICATION_SCOPE);
          runMyTest("testLinkPageParamIdParamNameApplicationScope", "");
      }
  
      public void testLinkPageParamIdParamNameParamPropertyApplicationScope(){
      	SimpleBeanForTesting sbft = new SimpleBeanForTesting("paramPropertyValue");
  		pageContext.setAttribute("testingParamProperty", sbft, PageContext.APPLICATION_SCOPE);
          runMyTest("testLinkPageParamIdParamNameParamPropertyApplicationScope", "");
      }
  
      public void testLinkPageParamIdParamNameSessionScope(){
  		pageContext.setAttribute("paramName", "paramValue", PageContext.SESSION_SCOPE);
          runMyTest("testLinkPageParamIdParamNameSessionScope", "");
      }
  
      public void testLinkPageParamIdParamNameParamPropertySessionScope(){
      	SimpleBeanForTesting sbft = new SimpleBeanForTesting("paramPropertyValue");
  		pageContext.setAttribute("testingParamProperty", sbft, PageContext.SESSION_SCOPE);
          runMyTest("testLinkPageParamIdParamNameParamPropertySessionScope", "");
      }
  
      public void testLinkPageParamIdParamNameRequestScope(){
  		pageContext.setAttribute("paramName", "paramValue", PageContext.REQUEST_SCOPE);
          runMyTest("testLinkPageParamIdParamNameRequestScope", "");
      }
  
      public void testLinkPageParamIdParamNameParamPropertyRequestScope(){
      	SimpleBeanForTesting sbft = new SimpleBeanForTesting("paramPropertyValue");
  		pageContext.setAttribute("testingParamProperty", sbft, PageContext.REQUEST_SCOPE);
          runMyTest("testLinkPageParamIdParamNameParamPropertyRequestScope", "");
      }
  
  
      public void testLinkPageStyle(){
          runMyTest("testLinkPageStyle", "");
      }
  
      public void testLinkPageStyleClass(){
          runMyTest("testLinkPageStyleClass", "");
      }
  
      public void testLinkPageStyleId(){
          runMyTest("testLinkPageStyleId", "");
      }
  
      public void testLinkPageTabIndex(){
          runMyTest("testLinkPageTabIndex", "");
      }
  
      public void testLinkPageTarget(){
          runMyTest("testLinkPageTarget", "");
      }
  
  
  
  
  
  
  
      public void testLinkPageTitle(){
          runMyTest("testLinkPageTitle", "");
      }
  
      public void testLinkPageTitleKey(){
          runMyTest("testLinkPageTitleKey", "");
      }
  
      public void testLinkPageTransaction(){
      	pageContext.setAttribute(Globals.TRANSACTION_TOKEN_KEY, "Some_Token_Here", PageContext.SESSION_SCOPE);
          runMyTest("testLinkPageTransaction", "");
      }
  
  
  
  
  	
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org