You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by ho...@apache.org on 2004/06/07 23:09:41 UTC
cvs commit: jakarta-taglibs/standard/test/web/org/apache/taglibs/standard/tag/el/core TestSetTag.jsp
horwat 2004/06/07 14:09:41
Modified: standard README_src.txt build.xml
build_sample_standard.properties
Added: standard build-tests.xml
standard/test/conf cactus.properties
standard/test/org/apache/taglibs/standard TestVersion.java
standard/test/org/apache/taglibs/standard/tag/el/core
TestSetTag.java
standard/test/org/apache/taglibs/standard/testutil
TestUtil.java
standard/test/web/WEB-INF web.xml
standard/test/web/org/apache/taglibs/standard/tag/el/core
TestSetTag.jsp
Log:
Initial commit of the unit test framework.
- supports cactus and junit tests
- added documentation to source README file
- fixed build file so cactus tests run successfully
- added unit test passthru targets to build.xml
- updated build.properties file with new unit test properties
Submitted by: Cheng Fang
Revision Changes Path
1.5 +152 -1 jakarta-taglibs/standard/README_src.txt
Index: README_src.txt
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/README_src.txt,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- README_src.txt 28 Aug 2003 16:35:42 -0000 1.4
+++ README_src.txt 7 Jun 2004 21:09:41 -0000 1.5
@@ -190,4 +190,155 @@
See the README file of the binary distribution you have built with these
instructions.
----------------------------------------------------------------------------
\ No newline at end of file
+---------------------------------------------------------------------------
+
+UNIT TESTING THE STANDARD TAG LIBRARY
+
+---------------------------------------------------------------------------
+OVERVIEW OF THE UNIT TEST FRAMEWORK
+
+The Unit test directory hierarchy should mimic the RI implementation hierarchy. This way, you have a mapping between the unit test and the file that it covers.
+
+If there's no appropriate mapping you can put the test in the general test directory:
+
+<JSTL_HOME>/test/org/apache/taglibs/standard
+
+The Test should be written using Junit Test name conventions and start with
+"Test*.java"
+
+Here is the Unit test directory hierarchy:
+
+ <JSTL_HOME>/
+ test/
+ conf/ <-- unit test configuration files
+ web/ <-- unit test web application files
+ WEB-INF/
+ org/
+ apache/
+ taglibs/
+ standard/
+ extra/
+ spath/
+ functions/
+ lang/
+ jstl/
+ resources/
+ tag/
+ common/
+ core/
+ fmt/
+ sql/
+ xml/
+ el/
+ core/
+ fmt/
+ sql/
+ xml/
+ rt/
+ core/
+ fmt/
+ sql/
+ xml/
+ tei/
+ tlv/
+
+
+---------------------------------------------------------------------------
+UNIT TEST BUILD ENVIRONMENT SETUP
+
+In order to build the Standard Unit Test Framework, you will need to set the
+following properties and download the corresponding implementation files. See the "build_sample_standard.properties" for the definitions:
+
+ build.dir Base directory into which we are building
+ the components.
+ build.classes Base JSTL classes directory
+
+ jstl.jar JSTL API jar file
+ standard.jar JSTL implementation jar file
+
+ servlet24.jar Servlet jar
+ jsp20.jar JSP jar
+
+ junit.jar JUnit jar
+
+ cactus.jar Cactus jar
+ cactus.ant.jar Cactus custom Ant tasks jar
+ aspectjrt.jar Cactus AspectJ Language Support jar
+ httpclient.jar Cactus httpclient jar
+ commons-logging.jar Cactus logging jar
+
+ tomcat.home Home directory where Tomcat
+ is installed
+ tomcat.webapps Tomcat webapps directory
+ username Tomcat username with manager role
+ privileges
+ password password for the user with manager
+ privileges
+
+ web.server.host hostname for the running webserver
+ web.server.port port for the running webserver
+
+ compile.debug debug mode for compilation
+ compile.deprecation deprecation mode for compilation
+ compile.optimize optimization mode for compilation
+
+---------------------------------------------------------------------------
+BUILDING THE UNIT TESTS
+
+Some common unit test build targets include:
+ > ant test <-- Build, deploy and run all the tests
+ > ant run.cactus <-- Build, deploy and run the Cactus tests
+ > ant run.junit <-- Build, deploy and run the Junit tests
+
+The following directories and files are created when building the unit tests:
+
+To execute the build-tests.xml unit test targets directly you can do the following:
+
+ > ant -f build-tests.xml <target>
+
+Some examples of targets available in the build-tests.xml file include:
+
+ > ant -f build-tests.xml props <-- Print out test environment properties
+ > ant -f build-tests.xml undeploy <-- Manually undeploy the Cactus
+ Tests web application
+ > ant -f build-tests.xml deploy <-- Manually deploy the Cactus Test
+ web application
+
+The following directories will be created when building the Unit Tests:
+ build/
+ standard/
+ standard/
+ test/
+ WEB-INF/
+ classes/
+ ...
+ lib/
+ org/
+ ...
+
+A Unit Test web application war file will also be created. It is located here:
+ build/standard/standard/jstl_test.war
+
+---------------------------------------------------------------------------
+UNIT TEST RUNTIME SETUP
+
+You will need to have the Tomcat manager administration application enabled in
+order to run the tests. The Unit Test build file uses the Tomcat manager to
+automatically deploy and undeploy the Cactus tests.
+
+The following runtime properties need to be properly set in order to successfully run the unit tests:
+
+ tomcat.webapps Tomcat webapps directory
+ username Tomcat username with manager role
+ privileges
+ password password for the user with manager
+ privileges
+
+ web.server.host hostname for the running webserver
+ web.server.port port for the running webserver
+
+The Tomcat manager application may sometimes get into an unstable state after
+many web application deployments and undeployments. If the Cactus tests start
+failing for unknown reasons, stop your web container and clean out your work
+directory before restarting.
+---------------------------------------------------------------------------
1.42 +18 -2 jakarta-taglibs/standard/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/build.xml,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- build.xml 2 Mar 2004 04:08:52 -0000 1.41
+++ build.xml 7 Jun 2004 21:09:41 -0000 1.42
@@ -13,8 +13,9 @@
<!-- Inherited properties -->
<!-- =================================================================== -->
- <property file="../build.properties"/>
- <property file="${user.home}/build.properties"/>
+ <property file="build.properties"/> <!-- Component local -->
+ <property file="../build.properties"/> <!-- Commons local -->
+ <property file="${user.home}/build.properties"/> <!-- User local -->
<property file="../common.properties"/>
<!-- =================================================================== -->
@@ -468,5 +469,20 @@
<!-- target that does nothing -->
<target name="nop"/>
+
+ <!-- =================================================================== -->
+ <!-- Unit Test PassThru Targets -->
+ <!-- =================================================================== -->
+ <target name="test" depends="build">
+ <ant antfile="build-tests.xml" target="run.test"/>
+ </target>
+
+ <target name="run.cactus" depends="build">
+ <ant antfile="build-tests.xml" target="run.cactus"/>
+ </target>
+
+ <target name="run.junit" depends="build">
+ <ant antfile="build-tests.xml" target="junit"/>
+ </target>
</project>
1.2 +46 -3 jakarta-taglibs/standard/build_sample_standard.properties
Index: build_sample_standard.properties
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/build_sample_standard.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- build_sample_standard.properties 19 Aug 2003 02:10:48 -0000 1.1
+++ build_sample_standard.properties 7 Jun 2004 21:09:41 -0000 1.2
@@ -7,14 +7,15 @@
base.dir=${user.home}/jakarta-taglibs-standard
build.dir = ${base.dir}/build
+build.classes=${build.dir}/standard/standard/classes
dist.dir = ${base.dir}/dist
# Servlet 2.4 and JSP 2.0
-#servlet24.jar=
-#jsp20.jar=
+servlet24.jar=
+jsp20.jar=
-# Standard (JSTL RI) and dbtags require the
+# Standard (JSTL RI) and dbtags require the
# JDBC 2.0 Standard Extensions
# {No need to specify if using J2SE 1.4.2 or higher)
@@ -33,3 +34,45 @@
#xalan.jar=
+
+# ----- Run Control Flags -----
+
+# Define the arguments to give to the jvm to enable debugging
+# If this is commented out, no debugging arguments will be passed.
+# Make sure to uncomment the proper arguments for your platform.
+
+# ----- Unix
+#debug.jvm.args = -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
+
+# ----- Windows
+#debug.jvm.args = -Xdebug -Xrunjdwp:transport=dt_shmem,address=jdbconn,server=y,suspend=n
+
+# ----- Compile Control Flags -----
+
+compile.deprecation = true
+compile.debug = true
+compile.optimize = false
+
+# --------------------------------------------------
+# REQUIRED LIBRARIES FOR UNIT TESTS
+# --------------------------------------------------
+jstl.jar=${build.dir}/standard/standard/lib/jstl.jar
+standard.jar=${build.dir}/standard/standard/lib/standard.jar
+junit.jar=
+
+cactus.home=
+cactus.jar=${cactus.home}/lib/cactus-1.6.1.jar
+cactus.ant.jar=${cactus.home}/lib/cactus-ant-1.6.1.jar
+aspectjrt.jar=${cactus.home}/lib/aspectjrt-1.1.1.jar
+httpclient.jar=${cactus.home}/lib/commons-httpclient-2.0.jar
+commons-logging.jar=${cactus.home}/lib/commons-logging-1.0.3.jar
+
+# --------------------------------------------------
+# RUN-TIME COMPONENTS FOR UNIT TESTS
+# --------------------------------------------------
+tomcat.home=
+tomcat.webapps=${tomcat.home}/webapps
+username=tomcat
+password=tomcat
+web.server.host=localhost
+web.server.port=8080
1.1 jakarta-taglibs/standard/build-tests.xml
Index: build-tests.xml
===================================================================
<project name="JSTL Unit Tests" default="run.test" basedir=".">
<!--
This is a generic build.xml file for Ant that is used to run the
JSTL unit tests.
-->
<!-- ========== Prerequisite Properties =================================== -->
<!--
These properties MUST be set on the "ant" command line, the "antrc"
properties file in your home directory, or from settings in a superior
build.xml script.
build.dir Base directory into which we are building
the components.
build.classes Base JSTL classes directory
jstl.jar JSTL API jar file
standard.jar JSTL implementation jar file
servlet24.jar Servlet 2.4 jar
jsp20.jar JSP 2.0 jar
junit.jar JUnit jar
cactus.jar Cactus jar
cactus.ant.jar Cactus custom Ant tasks jar
aspectjrt.jar Cactus AspectJ Language Support jar
httpclient.jar Cactus httpclient jar
commons-logging.jar Cactus logging jar
tomcat.home Home directory where Tomcat
is installed
tomcat.webapps Tomcat webapps directory
username Tomcat username with manager role
privileges
password password for the user with manager
privileges
web.server.host hostname for the running webserver
web.server.port port for the running webserver
compile.debug debug mode for compilation
compile.deprecation deprecation mode for compilation
compile.optimize optimization mode for compilation
-->
<!-- ========== Initialization Properties ================================= -->
<!-- ========== Derived Properties ======================================== -->
<!--
These property values are derived from values defined above, and
generally should NOT be overridden by command line settings
-->
<property file="build.properties"/> <!-- Component local -->
<property file="../build.properties"/> <!-- Commons local -->
<property file="${user.home}/build.properties"/> <!-- User local -->
<!-- Default value for debugging arguments is no. Override in
build.properties -->
<property name="debug.jvm.args" value=""/>
<!-- Source directory for tests -->
<property name="src.test.dir"
value="${basedir}/test"/>
<!-- Configuration directory for tests -->
<property name="conf.test.dir"
value="test/conf"/>
<!-- Output directory for tests -->
<property name="out.test.dir"
value="${basedir}/build/standard/standard/test"/>
<property name="test.context.path"
value="jstl_test"/>
<property name="test.war"
value="${test.context.path}.war"/>
<!-- all of these properties must have valid values -->
<property name="catalina-ant.jar"
value="${tomcat.home}/server/lib/catalina-ant.jar"/>
<property name="cactus.home"
value="${tomcat.home}/../jakarta-cactus-13-1.4.1"/>
<property name="cactus.ant.jar"
value="${cactus.home}/lib/cactus-ant-1.4.1.jar"/>
<property name="cactus.jar"
value="${cactus.home}/lib/cactus-1.4.1.jar"/>
<property name="aspectjrt.jar"
value="${cactus.home}/lib/aspectjrt-1.0.5.jar"/>
<property name="httpclient.jar"
value="${cactus.home}/lib/commons-httpclient-2.0alpha1-20020606.jar"/>
<property name="junit.jar"
value="${tomcat.home}/../junit3.8.1/junit.jar"/>
<property name="standard.jar"
value="${tomcat.home}/jstl/lib/standard.jar"/>
<property name="username" value="tomcat"/>
<property name="password" value="tomcat"/>
<property name="tomcat.manager.url"
value="http://${web.server.host}:${web.server.port}/manager"/>
<property name="cactus.contextURL"
value="http://${web.server.host}:${web.server.port}/${test.context.path}"/>
<target name="props"
description="Display resolved properties" >
<!-- Info on build environment -->
<echo>---------- Environment Information ----------</echo>
<echo>java.home: ${java.home}</echo>
<echo>ant.java.version: ${ant.java.version}</echo>
<echo>jstl.jar=${jstl.jar}</echo>
<echo>standard.jar=${standard.jar}</echo>
<echo>deprecation: ${compile.deprecation}</echo>
<echo>debug: ${compile.debug}</echo>
<echo>optimize: ${compile.optimize}</echo>
<echo>---------- Dependencies ---------------------</echo>
<echo>tomcat.home=${tomcat.home}</echo>
<echo>servlet24.jar: ${servlet24.jar}</echo>
<echo>jsp20.jar: ${jsp20.jar}</echo>
<echo>junit.jar: ${junit.jar}</echo>
<echo>cactus.home: ${cactus.home}</echo>
<echo>cactus.ant.jar: ${cactus.ant.jar}</echo>
<echo>cactus.jar: ${cactus.jar}</echo>
<echo>aspectjrt.jar: ${aspectjrt.jar}</echo>
<echo>httpclient.jar: ${httpclient.jar}</echo>
<echo>commons-logging.jar: ${commons-logging.jar}</echo>
<echo>---------- Build directories ----------------</echo>
<echo>build.dir: ${build.dir}</echo>
<echo>build.classes: ${build.classes}</echo>
<echo>dist.dir: ${dist.dir}</echo>
<echo>---------- Run-Time ----------------</echo>
<echo>tomcat.webapps: ${tomcat.webapps}</echo>
<echo>username: ${username}</echo>
<echo>password: ${password}</echo>
<echo>web.server.host: ${web.server.host}</echo>
<echo>web.server.port: ${web.server.port}</echo>
</target>
<!-- Compilation Classpath -->
<path id="compile.classpath">
<pathelement location="${jstl.jar}"/>
<pathelement location="${standard.jar}"/>
<pathelement location="${servlet24.jar}"/>
<pathelement location="${jsp20.jar}"/>
<pathelement location="${junit.jar}"/>
<pathelement location="${cactus.jar}"/>
<pathelement location="${httpclient.jar}"/>
<pathelement location="${aspectjrt.jar}"/>
<pathelement location="${build.classes}"/>
<pathelement location="${tomcat.home}/bin/bootstrap.jar"/>
<!-- For cactus.properties -->
<!--
<pathelement location="${conf.test.dir}"/>
-->
</path>
<path id="catalina-ant.classpath">
<pathelement location="${catalina-ant.jar}"/>
</path>
<!-- ========== Custom Tasks Definition ================================== -->
<taskdef name="install" classname="org.apache.catalina.ant.InstallTask">
<classpath>
<pathelement location="${catalina-ant.jar}" />
</classpath>
</taskdef>
<taskdef name="remove" classname="org.apache.catalina.ant.RemoveTask">
<classpath>
<pathelement location="${catalina-ant.jar}" />
</classpath>
</taskdef>
<!-- ========== Executable Targets ======================================== -->
<target name="init">
<uptodate property="skip.build"
targetfile="${out.test.dir}/last-testrun">
<srcfiles dir="${basedir}">
<include name="src/**/*.*"/>
<include name="test/**/*.*"/>
</srcfiles>
</uptodate>
</target>
<!-- ========== Test Preparation ========================================= -->
<!-- Create directories and copy files for the tests -->
<target name="prepare.test"
depends="init">
<!-- Create target directories for classes -->
<mkdir dir="${out.test.dir}/WEB-INF/classes"/>
<!-- Create a lib directory where needed libs for the test war will
be put -->
<mkdir dir="${out.test.dir}/WEB-INF/lib"/>
</target>
<!-- ========== Build and Package Tests =================================== -->
<!-- Compile unit tests -->
<target name="compile.test" depends="prepare.test">
<javac srcdir="${src.test.dir}"
destdir="${out.test.dir}/WEB-INF/classes"
debug="${compile.debug}"
optimize="${compile.optimize}"
deprecation="${compile.deprecation}">
<classpath refid="compile.classpath"/>
</javac>
<copy todir="${out.test.dir}/WEB-INF/classes">
<fileset dir="${src.test.dir}" includes="**/*.properties"
excludes="conf/"/>
</copy>
</target>
<target name="copy-test-data-files">
<!-- Copy Unit test static files. -->
<copy todir="${out.test.dir}">
<fileset dir="${basedir}/test/web"/>
<fileset dir="${cactus.home}/web" includes="jspRedirector.jsp"/>
</copy>
</target>
<target name="war"
description="put the test webapp in the WAR file format in out.test.dir"
depends="compile.test">
<!-- Copy needed libs in /lib -->
<copy file="${jstl.jar}" todir="${out.test.dir}/WEB-INF/lib"/>
<copy file="${standard.jar}" todir="${out.test.dir}/WEB-INF/lib"/>
<copy file="${junit.jar}" todir="${out.test.dir}/WEB-INF/lib"/>
<copy file="${cactus.jar}" todir="${out.test.dir}/WEB-INF/lib"/>
<copy file="${httpclient.jar}" todir="${out.test.dir}/WEB-INF/lib"/>
<copy file="${aspectjrt.jar}" todir="${out.test.dir}/WEB-INF/lib"/>
<!-- copy the all important web.xml -->
<echo message="out.test.dir ${out.test.dir}" />
<filter token="test.root.dir" value="${out.test.dir}"/>
<copy file="${src.test.dir}/web/WEB-INF/web.xml" todir="${out.test.dir}/WEB-INF"
filtering="on"/>
<copy todir="${out.test.dir}/WEB-INF/classes" overwrite="true">
<filterset>
<filter token="cactus.contextURL" value="${cactus.contextURL}"/>
</filterset>
<fileset dir="${src.test.dir}/conf">
<include name="cactus.properties"/>
</fileset>
</copy>
<!-- copy the test data files -->
<antcall target="copy-test-data-files"/>
<jar jarfile="${out.test.dir}/../${test.war}" basedir="${out.test.dir}"/>
</target>
<!-- ========== Server Management Tasks =================================== -->
<target name="deploy" depends="war"
description="Install cactus unit test webapp">
<!-- unreliable in tomcat 5.0.24 -->
<install url="${tomcat.manager.url}"
username="${username}"
password="${password}"
path="/${test.context.path}"
war="file://${out.test.dir}/../${test.war}"/>
</target>
<target name="autodeploy" depends="war">
<copy todir="${tomcat.webapps}" overwrite="true">
<fileset dir="${out.test.dir}/..">
<include name="*.war"/>
</fileset>
</copy>
</target>
<target name="undeploy"
description="Remove cactus unit test webapp">
<remove url="${tomcat.manager.url}"
username="${username}"
password="${password}"
path="/${test.context.path}"/>
</target>
<target name="safe.undeploy"
description="Remove cactus unit test webapp, don't FAIL on error">
<exec executable="ant.bat" os="Windows 2000" failonerror="false">
<arg line="-f build-tests.xml -Dusername=${username} -Dpassword=${password} undeploy"/>
</exec>
<exec executable="ant" os="SunOS,Linux,Mac OS X" failonerror="false">
<arg line="-f build-tests.xml -Dusername=${username} -Dpassword=${password} undeploy"/>
</exec>
</target>
<!-- ========== Cactus Test Task Definitions ============================== -->
<target name="cactus" depends="war">
<antcall target="safe.undeploy"/>
<antcall target="deploy"/>
<touch file="${out.test.dir}/last-testrun"/>
<!-- pause to allow container to finish deployment before running tests -->
<waitfor maxwait="20" maxwaitunit="second">
<http url="${cactus.contextURL}/JspRedirector"/>
</waitfor>
<antcall target="run.cactus"/>
</target>
<target name="cactus.force">
<antcall target="remove.tstamp"/>
<antcall target="cactus"/>
</target>
<target name="remove.tstamp">
<delete file="${out.test.dir}/last-testrun"/>
</target>
<!-- Run the Cactus tests using JUnit test runner -->
<target name="run.cactus">
<junit printsummary="yes" haltonfailure="yes" haltonerror="yes" fork="yes">
<classpath>
<pathelement path="${java.class.path}"/>
<pathelement location="${out.test.dir}/WEB-INF/classes"/>
<!-- For cactus.properties -->
<!--
<pathelement location="${conf.test.dir}"/>
-->
</classpath>
<classpath refid="compile.classpath"/>
<formatter type="plain" usefile="false"/>
<!-- Suite of Cactus tests to be executed -->
<batchtest>
<fileset dir="${src.test.dir}">
<include name="**/tag/**/Test*.java"/>
<exclude name="**/testutil/*.java"/>
</fileset>
</batchtest>
</junit>
</target>
<!-- ========== Junit Test Task Definitions =============================== -->
<target name="junit" depends="compile.test,copy-test-data-files">
<junit printsummary="yes" haltonfailure="yes" haltonerror="yes" fork="yes">
<!-- uncomment the below line to enable attaching a debugger -->
<jvmarg line="${debug.jvm.args}"/>
<classpath>
<pathelement path="${java.class.path}"/>
<pathelement location="${out.test.dir}/WEB-INF/classes"/>
</classpath>
<classpath refid="compile.classpath"/>
<formatter type="plain" usefile="false"/>
<!-- Suite of Junit tests to be executed -->
<batchtest>
<fileset dir="${src.test.dir}">
<include name="**/TestVersion.java"/>
<exclude name="**/testutil/*.java"/>
</fileset>
</batchtest>
</junit>
</target>
<!-- ========== Default Task Definitions =============================== -->
<target name="run.test" depends="junit,cactus"
description="Run all Junit and Cactus tests" >
</target>
<target name="clean">
<delete failonerror="no" includeEmptyDirs="yes">
<fileset dir="${out.test.dir}/..">
<include name="${test.war}"/>
<include name="test/"/>
</fileset>
</delete>
</target>
</project>
1.1 jakarta-taglibs/standard/test/conf/cactus.properties
Index: cactus.properties
===================================================================
# cactus.contextURL is set in the build-tests.xml
cactus.contextURL = @cactus.contextURL@
cactus.enableLogging = false
cactus.filterRedirectorName = FilterRedirector
cactus.jspRedirectorName = JspRedirector
cactus.servletRedirectorName = ServletRedirector
1.1 jakarta-taglibs/standard/test/org/apache/taglibs/standard/TestVersion.java
Index: TestVersion.java
===================================================================
/*
* Copyright 1999,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.taglibs.standard;
import junit.framework.*;
public class TestVersion
extends TestCase {
private Version version = null;
public TestVersion(String name) {
super(name);
}
protected void setUp() throws Exception {
super.setUp();
version = new Version();
}
protected void tearDown() throws Exception {
version = null;
super.tearDown();
}
public void testVersion() {
version = new Version();
}
public void testGetDevelopmentVersionNum() {
int expectedReturn = 0;
int actualReturn = version.getDevelopmentVersionNum();
assertEquals("return value", expectedReturn, actualReturn);
}
public void testGetMaintenanceVersionNum() {
int expectedReturn = 0;
int actualReturn = version.getMaintenanceVersionNum();
assertEquals("return value", expectedReturn, actualReturn);
}
public void testGetMajorVersionNum() {
int expectedReturn = 1;
int actualReturn = version.getMajorVersionNum();
assertEquals("return value", expectedReturn, actualReturn);
}
public void testGetProduct() {
String expectedReturn = "standard-taglib";
String actualReturn = version.getProduct();
assertEquals("return value", expectedReturn, actualReturn);
}
public void testGetReleaseVersionNum() {
int expectedReturn = 1;
int actualReturn = version.getReleaseVersionNum();
assertEquals("return value", expectedReturn, actualReturn);
}
public void testGetVersion() {
String expectedReturn = "standard-taglib 1.1.0";
String actualReturn = version.getVersion();
assertEquals("return value", expectedReturn, actualReturn);
}
public void testMain() {
String[] argv = null;
version.main(argv);
}
}
1.1 jakarta-taglibs/standard/test/org/apache/taglibs/standard/tag/el/core/TestSetTag.java
Index: TestSetTag.java
===================================================================
/*
* Copyright 1999,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.taglibs.standard.tag.el.core;
import javax.servlet.jsp.*;
import org.apache.cactus.*;
import org.apache.taglibs.standard.testutil.TestUtil;
public class TestSetTag
extends JspTestCase {
// private SetTag setTag = null;
public TestSetTag(String name) {
super(name);
}
protected void setUp() throws Exception {
super.setUp();
}
protected void tearDown() throws Exception {
super.tearDown();
}
public void testSetTag() throws Exception {
String var = "var1";
String expected = "value1";
String toInclude = TestUtil.getTestJsp(this);
pageContext.include(toInclude);
String actual = (String) pageContext.getAttribute(var,
PageContext.APPLICATION_SCOPE);
assertEquals(expected, actual);
}
}
1.1 jakarta-taglibs/standard/test/org/apache/taglibs/standard/testutil/TestUtil.java
Index: TestUtil.java
===================================================================
/*
* Copyright 1999,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.taglibs.standard.testutil;
public class TestUtil {
private TestUtil() {}
/**
* Gets the corresponding test jsp for this test case. As a convention,
* test class and test jsp should have the same package and directory
* structure, and the same base name.
* @return a context-relative path to the test jsp.
*/
public static String getTestJsp(Object obj) {
String className = obj.getClass().getName();
String baseName = className.replace('.', '/');
return "/" + baseName + ".jsp";
}
}
1.1 jakarta-taglibs/standard/test/web/WEB-INF/web.xml
Index: web.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<description>jstl test</description>
<display-name>jstl test</display-name>
<!--
<filter>
<filter-name>FilterRedirectory</filter-name>
<filter-class>
org.apache.cactus.server.FilterTestRedirector
</filter-class>
</filter>
<filter-mapping>
<filter-name>FilterRedirector</filter-name>
<url-pattern>/FilterRedirector</url-pattern>
</filter-mapping>
-->
<servlet>
<servlet-name>ServletRedirector</servlet-name>
<servlet-class>
org.apache.cactus.server.ServletTestRedirector
</servlet-class>
</servlet>
<servlet>
<servlet-name>JspRedirector</servlet-name>
<jsp-file>/jspRedirector.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>ServletRedirector</servlet-name>
<url-pattern>/ServletRedirector</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>JspRedirector</servlet-name>
<url-pattern>/JspRedirector</url-pattern>
</servlet-mapping>
</web-app>
1.1 jakarta-taglibs/standard/test/web/org/apache/taglibs/standard/tag/el/core/TestSetTag.jsp
Index: TestSetTag.jsp
===================================================================
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="var1" value="value1" scope="application"/>
<c:out value="${var1}"/>
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org