jstrachan 2003/01/21 07:49:29
Added: jelly/jelly-tags/junit/src/test/org/apache/commons/jelly/tags/junit
TestJUnit.java suite.jelly runSuite.jelly
jelly/jelly-tags/junit build.xml
Log:
Added the auto-generated Ant build file so that Gump can build this library. Also
moved over the unit test cases to here
Revision Changes Path
1.1
jakarta-commons-sandbox/jelly/jelly-tags/junit/src/test/org/apache/commons/jelly/tags/junit/TestJUnit.java
Index: TestJUnit.java
===================================================================
/*
*
/home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/junit/src/test/org/apache/commons/jelly/tags/junit/TestJUnit.java,v
1.1 2003/01/21 15:49:29 jstrachan Exp
* 1.1
* 2003/01/21 15:49:29
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 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", "Commons", 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/>.
*
* TestJUnit.java,v 1.1 2003/01/21 15:49:29 jstrachan Exp
*/
package org.apache.commons.jelly.tags.junit;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
/**
* A helper class to run jelly test cases as part of Ant's JUnit tests
*
* @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
* @version 1.1
*/
public class TestJUnit extends JellyTestSuite {
public static void main( String[] args ) throws Exception {
TestRunner.run( suite() );
}
public static TestSuite suite() throws Exception {
return createTestSuite(TestJUnit.class, "suite.jelly");
}
}
1.1
jakarta-commons-sandbox/jelly/jelly-tags/junit/src/test/org/apache/commons/jelly/tags/junit/suite.jelly
Index: suite.jelly
===================================================================
<?xml version="1.0"?>
<test:suite xmlns:j="jelly:core"
xmlns:test="jelly:junit">
<test:case name="assertTests">
<test:assert test="${2 == 2}">This should never fail</test:assert>
<j:catch var="ex">
<test:assert test="${2 != 2}">This should always
fail</test:assert>
</j:catch>
<test:assert test="${ex != null}">We should have created an
exception</test:assert>
The exception was: ${ex.message}
</test:case>
<test:case name="failTests">
<j:catch var="ex">
<test:fail>This should always fail</test:fail>
</j:catch>
<test:assert test="${ex != null}">We should have created an
exception</test:assert>
The exception was: ${ex.message}
<j:catch var="ex">
<test:fail message="This should always fail"/>
</j:catch>
<test:assert test="${ex != null}">We should have created an
exception</test:assert>
The exception was: ${ex.message}
</test:case>
<test:case name="assertEqualTests">
<j:set var="foo" value="abc"/>
<test:assertEquals actual="${foo}" expected="abc">This should never
fail</test:assertEquals>
<j:catch var="ex">
<test:assertEquals actual="${foo}" expected="def">This should always
fail</test:assertEquals>
</j:catch>
<test:assert test="${ex != null}">We should have created an
exception</test:assert>
The exception was: ${ex.message}
</test:case>
<test:case name="assertThrowsTests">
<!-- test using var attribute -->
<test:assertThrows var="ex">
<test:fail message="This exeption should be exported"/>
</test:assertThrows>
<test:assert test="${ex != null}">No exception exported</test:assert>
<!-- test using superclass of expected throwable -->
<test:assertThrows expected="java.lang.Error">
<test:fail message="This should always fail"/>
</test:assertThrows>
<!-- test using non exception class -->
<test:assertThrows expected="java.lang.Class">
<test:fail message="This should always fail"/>
</test:assertThrows>
<!-- test using undefined class -->
<test:assertThrows expected="java.lang.ClassNotFoundException">
<test:assertThrows expected="foo.bar.Baz">
<test:fail message="This should always fail"/>
</test:assertThrows>
</test:assertThrows>
<!-- test using other exception class -->
<j:catch var="ex">
<test:assertThrows expected="java.io.IOException">
<test:fail message="This should always fail"/>
</test:assertThrows>
</j:catch>
<test:assert test="${ex != null}">We should have created an
exception</test:assert>
<!-- test with no exception from body -->
<j:catch var="ex">
<test:assertThrows>
</test:assertThrows>
</j:catch>
<test:assert test="${ex != null}">assertThrows should fail when
nothing is thrown from within it</test:assert>
<test:assert test="${ex.message.startsWith('No exception was thrown.')}"/>
<test:assertEquals actual="${ex.elementName}" expected="test:assertThrows"/>
<test:assert test="${ex.fileName != null}">fileName not set</test:assert>
<test:assert test="${ex.lineNumber gt 0}">lineNumber not set</test:assert>
<test:assert test="${ex.columnNumber gt 0}">columnNumber not set</test:assert>
</test:case>
<!--
#### uncomment when assertEquals supports type conversions
<test:case name="assertEqualsConversion">
<test:assertEquals expected="${4}" actual="${2+2}"/>
</test:case>
-->
</test:suite>
1.1
jakarta-commons-sandbox/jelly/jelly-tags/junit/src/test/org/apache/commons/jelly/tags/junit/runSuite.jelly
Index: runSuite.jelly
===================================================================
<?xml version="1.0"?>
<j:jelly xmlns:j="jelly:core" xmlns:test="jelly:junit">
<!-- lets define a test suite -->
<test:suite var="suite">
<j:include uri="suite.jelly"/>
</test:suite>
Lets run the test suite.
<test:run test="${suite}"/>
Tests finished.
</j:jelly>
1.1 jakarta-commons-sandbox/jelly/jelly-tags/junit/build.xml
Index: build.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<project default="jar" name="commons-jelly-tags-junit" basedir=".">
<property name="defaulttargetdir" value="target">
</property>
<property name="classesdir" value="target/classes">
</property>
<property name="testclassesdir" value="target/test-classes">
</property>
<property name="testreportdir" value="target/test-reports">
</property>
<property name="distdir" value="dist">
</property>
<property name="javadocdir" value="target/docs/apidocs">
</property>
<property name="final.name" value="commons-jelly-tags-junit-1.0-SNAPSHOT">
</property>
<target name="init" description="o Initializes some properties">
<mkdir dir="lib">
</mkdir>
<condition property="noget">
<equals arg2="only" arg1="${build.sysclasspath}">
</equals>
</condition>
</target>
<target name="compile" description="o Compile the code" depends="get-deps">
<mkdir dir="${classesdir}">
</mkdir>
<javac destdir="${classesdir}" deprecation="true" debug="true" optimize="false"
excludes="**/package.html">
<src>
<pathelement location="src/java">
</pathelement>
</src>
<classpath>
<fileset dir="lib">
<include name="*.jar">
</include>
</fileset>
</classpath>
</javac>
<copy todir="${classesdir}">
<fileset dir="src/java">
<include name="**/*.properties">
</include>
</fileset>
</copy>
<copy todir="${testclassesdir}">
<fileset dir="src/test">
<include name="**/*.jelly">
</include>
<include name="**/*.xml">
</include>
<include name="**/*.xsl">
</include>
<include name="**/*.rng">
</include>
<include name="**/*.dtd">
</include>
<include name="**/*.properties">
</include>
<include name="**/*.html">
</include>
</fileset>
</copy>
</target>
<target name="jar" description="o Create the jar" depends="compile,test">
<jar jarfile="target/${final.name}.jar" excludes="**/package.html"
basedir="${classesdir}">
</jar>
</target>
<target name="clean" description="o Clean up the generated directories">
<delete dir="${defaulttargetdir}">
</delete>
<delete dir="${distdir}">
</delete>
</target>
<target name="dist" description="o Create a distribution" depends="jar, javadoc">
<mkdir dir="dist">
</mkdir>
<copy todir="dist">
<fileset dir="${defaulttargetdir}">
</fileset>
</copy>
</target>
<target name="test" description="o Run the test cases" if="test.failure"
depends="internal-test">
<fail message="There were test failures.">
</fail>
</target>
<target name="internal-test" depends="compile-tests">
</target>
<target name="compile-tests" depends="compile">
</target>
<target name="javadoc" description="o Generate javadoc" depends="jar">
<mkdir dir="${javadocdir}">
</mkdir>
<tstamp>
<format pattern="2002-yyyy" property="year">
</format>
</tstamp>
<property name="copyright" value="Copyright &copy; Apache Software
Foundation. All Rights Reserved.">
</property>
<property name="title" value="commons-jelly-tags-junit 1.0-SNAPSHOT API">
</property>
<javadoc use="true" private="true" destdir="${javadocdir}" author="true"
version="true" sourcepath="src/java"
packagenames="org.apache.commons.jelly.tags.junit.*">
<classpath>
<fileset dir="lib">
<include name="*.jar">
</include>
</fileset>
<pathelement location="target/${final.name}.jar">
</pathelement>
</classpath>
</javadoc>
</target>
<target name="get-deps" unless="noget" depends="init">
<get dest="lib/commons-jexl-1.0-beta-1.jar" usetimestamp="true"
ignoreerrors="true"
src="http://www.ibiblio.org/maven/commons-jexl/jars/commons-jexl-1.0-beta-1.jar">
</get>
<get dest="lib/xml-apis-1.0.b2.jar" usetimestamp="true" ignoreerrors="true"
src="http://www.ibiblio.org/maven/xml-apis/jars/xml-apis-1.0.b2.jar">
</get>
<get dest="lib/commons-beanutils-SNAPSHOT.jar" usetimestamp="true"
ignoreerrors="true"
src="http://www.ibiblio.org/maven/commons-beanutils/jars/commons-beanutils-SNAPSHOT.jar">
</get>
<get dest="lib/commons-collections-2.1.jar" usetimestamp="true"
ignoreerrors="true"
src="http://www.ibiblio.org/maven/commons-collections/jars/commons-collections-2.1.jar">
</get>
<get dest="lib/commons-logging-1.0.jar" usetimestamp="true" ignoreerrors="true"
src="http://www.ibiblio.org/maven/commons-logging/jars/commons-logging-1.0.jar">
</get>
<get dest="lib/dom4j-1.4-dev-8.jar" usetimestamp="true" ignoreerrors="true"
src="http://www.ibiblio.org/maven/dom4j/jars/dom4j-1.4-dev-8.jar">
</get>
<get dest="lib/xerces-2.2.1.jar" usetimestamp="true" ignoreerrors="true"
src="http://www.ibiblio.org/maven/xerces/jars/xerces-2.2.1.jar">
</get>
<get dest="lib/commons-jelly-SNAPSHOT.jar" usetimestamp="true"
ignoreerrors="true"
src="http://www.ibiblio.org/maven/commons-jelly/jars/commons-jelly-SNAPSHOT.jar">
</get>
<get dest="lib/junit-3.8.1.jar" usetimestamp="true" ignoreerrors="true"
src="http://www.ibiblio.org/maven/junit/jars/junit-3.8.1.jar">
</get>
<get dest="lib/junit-3.8.1.jar" usetimestamp="true" ignoreerrors="true"
src="http://www.ibiblio.org/maven/junit/jars/junit-3.8.1.jar">
</get>
<get dest="lib/ant-1.5.jar" usetimestamp="true" ignoreerrors="true"
src="http://www.ibiblio.org/maven/ant/jars/ant-1.5.jar">
</get>
<get dest="lib/ant-optional-1.5.jar" usetimestamp="true" ignoreerrors="true"
src="http://www.ibiblio.org/maven/ant/jars/ant-optional-1.5.jar">
</get>
</target>
<target name="install-maven">
<get dest="${user.home}/maven-install-latest.jar" usetimestamp="true"
src="${maven.repo.remote}/maven/maven-install-latest.jar">
</get>
<unjar dest="${maven.home}" src="${user.home}/maven-install-latest.jar">
</unjar>
</target>
</project>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>