PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269587 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -6,7 +6,7 @@ | |||
| <!-- ====================================================================== | |||
| Stylesheet to transform an XML file generated by the Ant MAudit task into | |||
| Stylesheet to transform an XML file generated by the Ant JUnit task into | |||
| a set of JavaDoc-like HTML page to make pages more convenient to be browsed. | |||
| It use the Xalan redirect extension to write to multiple output files. | |||
| @@ -14,8 +14,8 @@ | |||
| Note: HTML output can be made much more clean by removing non css attributes | |||
| ====================================================================== --> | |||
| <xsl:output method="html" indent="yes"/> | |||
| <xsl:decimal-format decimal-separator="." grouping-separator="," /> | |||
| <xsl:output method="html" indent="yes"/> | |||
| <xsl:decimal-format decimal-separator="." grouping-separator=","/> | |||
| <!-- | |||
| Xalan redirect extension writes relative file based on the parent directory | |||
| @@ -27,7 +27,7 @@ | |||
| This has to be invoked as follows from the command line: | |||
| java -classpath bsf.jar;xalan.jar;xerces.jar org.apache.xalan.xslt.Process -IN testsuites.xml -XSL maudit.xsl -PARAM output.dir './report' | |||
| java -classpath bsf.jar;xalan.jar;xerces.jar org.apache.xalan.xslt.Process -IN testsuites.xml -XSL junit-frames.xsl -PARAM output.dir './report' | |||
| --> | |||
| <xsl:param name="output.dir" select="'.'"/> | |||
| @@ -98,61 +98,72 @@ | |||
| </xsl:template> | |||
| <xsl:template name="index.html"> | |||
| <HTML> | |||
| <HEAD><TITLE>Unit Test Results.</TITLE></HEAD> | |||
| <FRAMESET cols="20%,80%"> | |||
| <FRAMESET rows="30%,70%"> | |||
| <FRAME src="overview-frame.html" name="packageListFrame"/> | |||
| <FRAME src="allclasses-frame.html" name="classListFrame"/> | |||
| </FRAMESET> | |||
| <FRAME src="overview-summary.html" name="classFrame"/> | |||
| </FRAMESET> | |||
| <html> | |||
| <head> | |||
| <title>Unit Test Results.</title> | |||
| </head> | |||
| <frameset cols="20%,80%"> | |||
| <frameset rows="30%,70%"> | |||
| <frame src="overview-frame.html" name="packageListFrame"/> | |||
| <frame src="allclasses-frame.html" name="classListFrame"/> | |||
| </frameset> | |||
| <frame src="overview-summary.html" name="classFrame"/> | |||
| </frameset> | |||
| <noframes> | |||
| <H2>Frame Alert</H2> | |||
| <P> | |||
| <h2>Frame Alert</h2> | |||
| <p> | |||
| This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. | |||
| </P> | |||
| </p> | |||
| </noframes> | |||
| </HTML> | |||
| </html> | |||
| </xsl:template> | |||
| <!-- this is the stylesheet css to use for nearly everything --> | |||
| <xsl:template name="stylesheet.css"> | |||
| BODY { | |||
| body { | |||
| font:normal 68% verdana,arial,helvetica; | |||
| color:#000000; | |||
| } | |||
| TD { | |||
| FONT-SIZE: 68% | |||
| td { | |||
| font-size: 68% | |||
| } | |||
| P { | |||
| p { | |||
| line-height:1.5em; | |||
| margin-top:0.5em; margin-bottom:1.0em; | |||
| } | |||
| H1 { | |||
| MARGIN: 0px 0px 5px; FONT: 165% verdana,arial,helvetica | |||
| h1 { | |||
| margin: 0px 0px 5px; | |||
| font: 165% verdana,arial,helvetica | |||
| } | |||
| H2 { | |||
| MARGIN-TOP: 1em; MARGIN-BOTTOM: 0.5em; FONT: bold 125% verdana,arial,helvetica | |||
| h2 { | |||
| margin-top: 1em; | |||
| margin-bottom: 0.5em; | |||
| font: bold 125% verdana,arial,helvetica | |||
| } | |||
| H3 { | |||
| MARGIN-BOTTOM: 0.5em; FONT: bold 115% verdana,arial,helvetica | |||
| h3 { | |||
| margin-bottom: 0.5em; | |||
| font: bold 115% verdana,arial,helvetica | |||
| } | |||
| H4 { | |||
| MARGIN-BOTTOM: 0.5em; FONT: bold 100% verdana,arial,helvetica | |||
| h4 { | |||
| margin-bottom: 0.5em; | |||
| font: bold 100% verdana,arial,helvetica | |||
| } | |||
| H5 { | |||
| MARGIN-BOTTOM: 0.5em; FONT: bold 100% verdana,arial,helvetica | |||
| h5 { | |||
| margin-bottom: 0.5em; | |||
| font: bold 100% verdana,arial,helvetica | |||
| } | |||
| H6 { | |||
| MARGIN-BOTTOM: 0.5em; FONT: bold 100% verdana,arial,helvetica | |||
| h6 { | |||
| margin-bottom: 0.5em; | |||
| font: bold 100% verdana,arial,helvetica | |||
| } | |||
| .Error { | |||
| font-weight:bold; color:red; | |||
| font-weight:bold; | |||
| color:red; | |||
| } | |||
| .Failure { | |||
| font-weight:bold; color:purple; | |||
| font-weight:bold; | |||
| color:purple; | |||
| } | |||
| </xsl:template> | |||
| @@ -165,15 +176,15 @@ H6 { | |||
| ====================================================================== --> | |||
| <xsl:template match="testsuite" mode="class.details"> | |||
| <xsl:variable name="package.name" select="@package"/> | |||
| <HTML> | |||
| <HEAD> | |||
| <html> | |||
| <head> | |||
| <xsl:call-template name="create.stylesheet.link"> | |||
| <xsl:with-param name="package.name" select="$package.name"/> | |||
| </xsl:call-template> | |||
| </HEAD> | |||
| <BODY> | |||
| </head> | |||
| <body> | |||
| <xsl:call-template name="pageHeader"/> | |||
| <H3>Class <xsl:if test="not($package.name = '')"><xsl:value-of select="$package.name"/>.</xsl:if><xsl:value-of select="@name"/></H3> | |||
| <h3>Class <xsl:if test="not($package.name = '')"><xsl:value-of select="$package.name"/>.</xsl:if><xsl:value-of select="@name"/></h3> | |||
| <table border="0" cellpadding="5" cellspacing="2" width="95%"> | |||
| @@ -181,7 +192,7 @@ H6 { | |||
| <xsl:apply-templates select="." mode="print.test"/> | |||
| </table> | |||
| <H2>Tests</H2> | |||
| <h2>Tests</h2> | |||
| <p> | |||
| <table border="0" cellpadding="5" cellspacing="2" width="95%"> | |||
| <xsl:call-template name="testcase.test.header"/> | |||
| @@ -189,8 +200,8 @@ H6 { | |||
| </table> | |||
| </p> | |||
| </BODY> | |||
| </HTML> | |||
| </body> | |||
| </html> | |||
| </xsl:template> | |||
| @@ -202,24 +213,24 @@ H6 { | |||
| <!-- list of classes in a package --> | |||
| <xsl:template name="classes.list"> | |||
| <xsl:param name="name"/> | |||
| <HTML> | |||
| <HEAD> | |||
| <html> | |||
| <head> | |||
| <xsl:call-template name="create.stylesheet.link"> | |||
| <xsl:with-param name="package.name" select="$name"/> | |||
| </xsl:call-template> | |||
| </HEAD> | |||
| <BODY> | |||
| </head> | |||
| <body> | |||
| <table width="100%"> | |||
| <tr> | |||
| <td nowrap="nowrap"> | |||
| <H2><a href="package-summary.html" target="classFrame"><xsl:value-of select="$name"/></a></H2> | |||
| <h2><a href="package-summary.html" target="classFrame"><xsl:value-of select="$name"/></a></h2> | |||
| </td> | |||
| </tr> | |||
| </table> | |||
| <H2>Classes</H2> | |||
| <h2>Classes</h2> | |||
| <p> | |||
| <TABLE WIDTH="100%"> | |||
| <table width="100%"> | |||
| <xsl:for-each select="/testsuites/testsuite[./@package = $name]"> | |||
| <xsl:sort select="@name"/> | |||
| <tr> | |||
| @@ -228,10 +239,10 @@ H6 { | |||
| </td> | |||
| </tr> | |||
| </xsl:for-each> | |||
| </TABLE> | |||
| </table> | |||
| </p> | |||
| </BODY> | |||
| </HTML> | |||
| </body> | |||
| </html> | |||
| </xsl:template> | |||
| @@ -260,8 +271,8 @@ H6 { | |||
| </xsl:template> | |||
| <xsl:template match="testsuite" mode="all.classes"> | |||
| <!-- (ancestor::package)[last()] is buggy in MSXML3, fixed in SP1 ? --> | |||
| <xsl:variable name="package.name" select="@package"/> | |||
| <!-- (ancestor::package)[last()] is buggy in MSXML3, fixed in SP1? --> | |||
| <xsl:variable name="package.name" select="@package"/> | |||
| <tr> | |||
| <td nowrap="nowrap"> | |||
| <a target="classFrame"> | |||
| @@ -295,7 +306,7 @@ H6 { | |||
| <p> | |||
| <table width="100%"> | |||
| <xsl:apply-templates select="testsuite[not(./@package = preceding-sibling::testsuite/@package)]" mode="all.packages"> | |||
| <xsl:sort select="@name"/> | |||
| <xsl:sort select="@package"/> | |||
| </xsl:apply-templates> | |||
| </table> | |||
| </p> | |||
| @@ -321,7 +332,7 @@ H6 { | |||
| <xsl:with-param name="package.name"/> | |||
| </xsl:call-template> | |||
| </head> | |||
| <body onload="open('allclasses-frame.html','classListFrame')"> | |||
| <body> | |||
| <xsl:call-template name="pageHeader"/> | |||
| <h2>Summary</h2> | |||
| <xsl:variable name="testCount" select="sum(testsuite/@tests)"/> | |||
| @@ -331,20 +342,20 @@ H6 { | |||
| <xsl:variable name="successRate" select="($testCount - $failureCount - $errorCount) div $testCount"/> | |||
| <table border="0" cellpadding="5" cellspacing="2" width="95%"> | |||
| <tr bgcolor="#A6CAF0" valign="top"> | |||
| <td><b>Tests</b></td> | |||
| <td><b>Failures</b></td> | |||
| <td><b>Errors</b></td> | |||
| <td><b>Success rate</b></td> | |||
| <td><b>Time</b></td> | |||
| <td><strong>Tests</strong></td> | |||
| <td><strong>Failures</strong></td> | |||
| <td><strong>Errors</strong></td> | |||
| <td><strong>Success rate</strong></td> | |||
| <td><strong>Time</strong></td> | |||
| </tr> | |||
| <tr bgcolor="#EEEEE" valign="top"> | |||
| <xsl:attribute name="class"> | |||
| <xsl:choose> | |||
| <xsl:when test="$failureCount > 0">Failure</xsl:when> | |||
| <xsl:when test="$errorCount > 0">Error</xsl:when> | |||
| <xsl:otherwise>Pass</xsl:otherwise> | |||
| </xsl:choose> | |||
| </xsl:attribute> | |||
| <xsl:attribute name="class"> | |||
| <xsl:choose> | |||
| <xsl:when test="$errorCount > 0">Error</xsl:when> | |||
| <xsl:when test="$failureCount > 0">Failure</xsl:when> | |||
| <xsl:otherwise>Pass</xsl:otherwise> | |||
| </xsl:choose> | |||
| </xsl:attribute> | |||
| <td><xsl:value-of select="$testCount"/></td> | |||
| <td><xsl:value-of select="$failureCount"/></td> | |||
| <td><xsl:value-of select="$errorCount"/></td> | |||
| @@ -364,7 +375,7 @@ H6 { | |||
| <table border="0" width="95%"> | |||
| <tr> | |||
| <td style="text-align: justify;"> | |||
| Note: <i>failures</i> are anticipated and checked for with assertions while <i>errors</i> are unanticipated. | |||
| Note: <em>failures</em> are anticipated and checked for with assertions while <em>errors</em> are unanticipated. | |||
| </td> | |||
| </tr> | |||
| </table> | |||
| @@ -377,13 +388,14 @@ H6 { | |||
| <!-- get the node set containing all testsuites that have the same package --> | |||
| <xsl:variable name="insamepackage" select="/testsuites/testsuite[./@package = current()/@package]"/> | |||
| <tr bgcolor="#EEEEE" valign="top"> | |||
| <!-- display a failure if there is any failure/error in the package --> | |||
| <xsl:attribute name="class"> | |||
| <xsl:choose> | |||
| <xsl:when test="sum($insamepackage/@errors) + sum($insamepackage/@failures) > 0">Failure</xsl:when> | |||
| <xsl:otherwise>Pass</xsl:otherwise> | |||
| </xsl:choose> | |||
| </xsl:attribute> | |||
| <!-- display a failure if there is any failure/error in the package --> | |||
| <xsl:attribute name="class"> | |||
| <xsl:choose> | |||
| <xsl:when test="sum($insamepackage/@errors) > 0">Error</xsl:when> | |||
| <xsl:when test="sum($insamepackage/@failures) > 0">Failure</xsl:when> | |||
| <xsl:otherwise>Pass</xsl:otherwise> | |||
| </xsl:choose> | |||
| </xsl:attribute> | |||
| <td><a href="{translate(@package,'.','/')}/package-summary.html"><xsl:value-of select="@package"/></a></td> | |||
| <td><xsl:value-of select="sum($insamepackage/@tests)"/></td> | |||
| <td><xsl:value-of select="sum($insamepackage/@errors)"/></td> | |||
| @@ -403,13 +415,13 @@ H6 { | |||
| <xsl:template name="package.summary"> | |||
| <xsl:param name="name"/> | |||
| <HTML> | |||
| <HEAD> | |||
| <html> | |||
| <head> | |||
| <xsl:call-template name="create.stylesheet.link"> | |||
| <xsl:with-param name="package.name" select="$name"/> | |||
| </xsl:call-template> | |||
| </HEAD> | |||
| <BODY> | |||
| </head> | |||
| <body> | |||
| <xsl:attribute name="onload">open('package-frame.html','classListFrame')</xsl:attribute> | |||
| <xsl:call-template name="pageHeader"/> | |||
| <h3>Package <xsl:value-of select="$name"/></h3> | |||
| @@ -421,7 +433,7 @@ H6 { | |||
| <xsl:variable name="insamepackage" select="/testsuites/testsuite[./@package = $name]"/> | |||
| <xsl:if test="count($insamepackage) > 0"> | |||
| <H2>Classes</H2> | |||
| <h2>Classes</h2> | |||
| <p> | |||
| <table border="0" cellpadding="5" cellspacing="2" width="95%"> | |||
| <xsl:call-template name="testsuite.test.header"/> | |||
| @@ -431,8 +443,8 @@ H6 { | |||
| </table> | |||
| </p> | |||
| </xsl:if> | |||
| </BODY> | |||
| </HTML> | |||
| </body> | |||
| </html> | |||
| </xsl:template> | |||
| @@ -457,7 +469,7 @@ H6 { | |||
| <!-- create the link to the stylesheet based on the package name --> | |||
| <xsl:template name="create.stylesheet.link"> | |||
| <xsl:param name="package.name"/> | |||
| <LINK REL ="stylesheet" TYPE="text/css" TITLE="Style"><xsl:attribute name="href"><xsl:if test="not($package.name = 'unnamed package')"><xsl:call-template name="path"><xsl:with-param name="path" select="$package.name"/></xsl:call-template></xsl:if>stylesheet.css</xsl:attribute></LINK> | |||
| <link rel="stylesheet" type="text/css" title="Style"><xsl:attribute name="href"><xsl:if test="not($package.name = 'unnamed package')"><xsl:call-template name="path"><xsl:with-param name="path" select="$package.name"/></xsl:call-template></xsl:if>stylesheet.css</xsl:attribute></link> | |||
| </xsl:template> | |||
| @@ -476,32 +488,32 @@ H6 { | |||
| <!-- class header --> | |||
| <xsl:template name="testsuite.test.header"> | |||
| <tr bgcolor="#A6CAF0" valign="top"> | |||
| <td width="80%"><b>Name</b></td> | |||
| <td><b>Tests</b></td> | |||
| <td><b>Errors</b></td> | |||
| <td><b>Failures</b></td> | |||
| <td nowrap="nowrap"><b>Time(s)</b></td> | |||
| <td width="80%"><strong>Name</strong></td> | |||
| <td><strong>Tests</strong></td> | |||
| <td><strong>Errors</strong></td> | |||
| <td><strong>Failures</strong></td> | |||
| <td nowrap="nowrap"><strong>Time(s)</strong></td> | |||
| </tr> | |||
| </xsl:template> | |||
| <!-- method header --> | |||
| <xsl:template name="testcase.test.header"> | |||
| <tr bgcolor="#A6CAF0" valign="top"> | |||
| <td><b>Name</b></td> | |||
| <td><b>Status</b></td> | |||
| <td width="80%"><b>Type</b></td> | |||
| <td nowrap="nowrap"><b>Time(s)</b></td> | |||
| <td><strong>Name</strong></td> | |||
| <td><strong>Status</strong></td> | |||
| <td width="80%"><strong>Type</strong></td> | |||
| <td nowrap="nowrap"><strong>Time(s)</strong></td> | |||
| </tr> | |||
| </xsl:template> | |||
| <!-- class information --> | |||
| <xsl:template match="testsuite" mode="print.test"> | |||
| <tr bgcolor="#EEEEE" valign="top"> | |||
| <tr bgcolor="#EEEEE" valign="top"> | |||
| <xsl:attribute name="class"> | |||
| <xsl:choose> | |||
| <xsl:when test="@failures[.> 0]">Failure</xsl:when> | |||
| <xsl:when test="@errors[.> 0]">Error</xsl:when> | |||
| <xsl:when test="@failures[.> 0]">Failure</xsl:when> | |||
| <xsl:otherwise>Pass</xsl:otherwise> | |||
| </xsl:choose> | |||
| </xsl:attribute> | |||
| @@ -520,7 +532,8 @@ H6 { | |||
| <tr bgcolor="#EEEEE" valign="top"> | |||
| <xsl:attribute name="class"> | |||
| <xsl:choose> | |||
| <xsl:when test="failure | error">Error</xsl:when> | |||
| <xsl:when test="error">Error</xsl:when> | |||
| <xsl:when test="failure">Failure</xsl:when> | |||
| <xsl:otherwise>TableRowColor</xsl:otherwise> | |||
| </xsl:choose> | |||
| </xsl:attribute> | |||
| @@ -558,7 +571,7 @@ H6 { | |||
| <xsl:call-template name="display-failures"/> | |||
| </xsl:template> | |||
| <!-- Style for the error and failure in the tescase template --> | |||
| <!-- Style for the error and failure in the testcase template --> | |||
| <xsl:template name="display-failures"> | |||
| <xsl:choose> | |||
| <xsl:when test="not(@message)">N/A</xsl:when> | |||
| @@ -573,7 +586,7 @@ H6 { | |||
| <xsl:with-param name="word" select="."/> | |||
| </xsl:call-template> | |||
| </code> | |||
| <!-- the later is better but might be problematic for non-21" monitors... --> | |||
| <!-- the latter is better but might be problematic for non-21" monitors... --> | |||
| <!--pre><xsl:value-of select="."/></pre--> | |||
| </xsl:template> | |||
| @@ -606,6 +619,5 @@ H6 { | |||
| <xsl:param name="value"/> | |||
| <xsl:value-of select="format-number($value,'0.00%')"/> | |||
| </xsl:template> | |||
| </xsl:stylesheet> | |||
| @@ -0,0 +1,20 @@ | |||
| <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" | |||
| xmlns:lxslt="http://xml.apache.org/xslt" | |||
| xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect" | |||
| extension-element-prefixes="redirect"> | |||
| <!-- | |||
| This is a test to ensure that systemid is set correctly | |||
| for a xsl...the behavior might be dependent on Xalan1 | |||
| and Xalan2...this will be a problem to erase the files :( | |||
| Can take as a systemid the base for the xsl document or | |||
| the base or the JVM working dir just like: new File("xalan-redirect-out.tmp") | |||
| --> | |||
| <xsl:param name="xalan-version" select="'x'"/> | |||
| <xsl:template match="/"> | |||
| <redirect:write file="./xalan{$xalan-version}-redirect-out.tmp"> | |||
| <test>This should be written to the file</test> | |||
| </redirect:write> | |||
| </xsl:template> | |||
| </xsl:stylesheet> | |||
| @@ -0,0 +1,4 @@ | |||
| <?xml version="1.0" encoding="ISO-8859-1"?> | |||
| <root> | |||
| <message>éàèïù</message> | |||
| </root> | |||
| @@ -0,0 +1,10 @@ | |||
| <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | |||
| <xsl:template match="/"> | |||
| <root> | |||
| <xsl:for-each select="/root/message"> | |||
| <message><xsl:value-of select="."/></message> | |||
| </xsl:for-each> | |||
| </root> | |||
| </xsl:template> | |||
| </xsl:stylesheet> | |||
| @@ -0,0 +1,7 @@ | |||
| <?xml version="1.0"?> | |||
| <!DOCTYPE project [ | |||
| <!ENTITY include SYSTEM "xsltliaison-include.xml"> | |||
| ]> | |||
| <project> | |||
| &include; | |||
| </project> | |||
| @@ -0,0 +1,3 @@ | |||
| <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | |||
| <xsl:include href="xsltliaison-include.xsl"/> | |||
| </xsl:stylesheet> | |||
| @@ -0,0 +1,2 @@ | |||
| <!-- to be included by xsltliaison-include.xsl --> | |||
| <task/> | |||
| @@ -0,0 +1,3 @@ | |||
| <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | |||
| <!-- to be included by xsltliaison-in.xsl --> | |||
| </xsl:stylesheet> | |||
| @@ -0,0 +1,37 @@ | |||
| <project name="test" default="new" basedir="."> | |||
| <filterset id="testset.one"> | |||
| <filter token="aaaa" value="1111"/> | |||
| <filter token="bbbb" value="2222"/> | |||
| </filterset> | |||
| <filterset id="testset.two" beginToken="%" endToken="^"> | |||
| <filter token="cccc" value="3333"/> | |||
| <filter token="dddd" value="4444"/> | |||
| </filterset> | |||
| <target name="test1"> | |||
| <delete file="dest1.txt"/> | |||
| <copy file="filterseta.txt" tofile="dest1.txt"> | |||
| <filterset refid="testset.one"/> | |||
| </copy> | |||
| <fixcrlf eol="lf" srcdir="." includes="dest1.txt"/> | |||
| </target> | |||
| <target name="test2"> | |||
| <delete file="dest2.txt"/> | |||
| <copy file="filtersetb.txt" tofile="dest2.txt"> | |||
| <filterset refid="testset.two"/> | |||
| </copy> | |||
| <fixcrlf eol="lf" srcdir="." includes="dest2.txt"/> | |||
| </target> | |||
| <target name="test3"> | |||
| <delete file="dest3.txt"/> | |||
| <copy file="filtersetc.txt" tofile="dest3.txt"> | |||
| <filterset refid="testset.one"/> | |||
| <filterset refid="testset.two"/> | |||
| </copy> | |||
| <fixcrlf eol="lf" srcdir="." includes="dest3.txt"/> | |||
| </target> | |||
| </project> | |||
| @@ -0,0 +1,2 @@ | |||
| This is a test file for filters @aaaa@ | |||
| It has two lines @bbbb@ | |||
| @@ -0,0 +1,5 @@ | |||
| This is a test file for filters with non default markers | |||
| @cccc@ - should not change | |||
| %cccc^ - should change | |||
| ^dddd% - should not change | |||
| %dddd^ - should change | |||
| @@ -0,0 +1,7 @@ | |||
| Combined filter test | |||
| @aaaa@ - should change | |||
| @bbbb@ - should change | |||
| @cccc@ - should not change | |||
| %cccc^ - should change | |||
| ^dddd% - should not change | |||
| %dddd^ - should change | |||
| @@ -0,0 +1,2 @@ | |||
| This is a test file for filters 1111 | |||
| It has two lines 2222 | |||
| @@ -0,0 +1,5 @@ | |||
| This is a test file for filters with non default markers | |||
| @cccc@ - should not change | |||
| 3333 - should change | |||
| ^dddd% - should not change | |||
| 4444 - should change | |||
| @@ -0,0 +1,7 @@ | |||
| Combined filter test | |||
| 1111 - should change | |||
| 2222 - should change | |||
| @cccc@ - should not change | |||
| 3333 - should change | |||
| ^dddd% - should not change | |||
| 4444 - should change | |||
| @@ -69,7 +69,6 @@ import java.util.*; | |||
| * | |||
| * @author duncan@x180.com | |||
| */ | |||
| public class Main { | |||
| /** The default build file name */ | |||
| @@ -132,7 +131,7 @@ public class Main { | |||
| * Entry point allowing for more options from other front ends | |||
| */ | |||
| public static void start(String[] args, Properties additionalUserProperties, | |||
| ClassLoader systemLoader) { | |||
| ClassLoader coreLoader) { | |||
| Main m = null; | |||
| try { | |||
| @@ -151,7 +150,7 @@ public class Main { | |||
| } | |||
| try { | |||
| m.runBuild(systemLoader); | |||
| m.runBuild(coreLoader); | |||
| System.exit(0); | |||
| } catch (BuildException be) { | |||
| if (m.err != System.err) { | |||
| @@ -390,7 +389,7 @@ public class Main { | |||
| /** | |||
| * Executes the build. | |||
| */ | |||
| private void runBuild(ClassLoader systemLoader) throws BuildException { | |||
| private void runBuild(ClassLoader coreLoader) throws BuildException { | |||
| if (!readyToRun) { | |||
| return; | |||
| @@ -403,7 +402,7 @@ public class Main { | |||
| } | |||
| final Project project = new Project(); | |||
| project.setSystemLoader(systemLoader); | |||
| project.setCoreLoader(coreLoader); | |||
| Throwable error = null; | |||
| @@ -433,15 +432,17 @@ public class Main { | |||
| // first use the ProjectHelper to create the project object | |||
| // from the given build file. | |||
| String noParserMessage = | |||
| "No JAXP compliant XML parser found. Please visit http://xml.apache.org for a suitable parser"; | |||
| try { | |||
| Class.forName("javax.xml.parsers.SAXParserFactory"); | |||
| ProjectHelper.configureProject(project, buildFile); | |||
| } catch (NoClassDefFoundError ncdfe) { | |||
| throw new BuildException("No JAXP compliant XML parser found. See http://java.sun.com/xml for the\nreference implementation.", ncdfe); | |||
| throw new BuildException(noParserMessage, ncdfe); | |||
| } catch (ClassNotFoundException cnfe) { | |||
| throw new BuildException("No JAXP compliant XML parser found. See http://java.sun.com/xml for the\nreference implementation.", cnfe); | |||
| throw new BuildException(noParserMessage, cnfe); | |||
| } catch (NullPointerException npe) { | |||
| throw new BuildException("No JAXP compliant XML parser found. See http://java.sun.com/xml for the\nreference implementation.", npe); | |||
| throw new BuildException(noParserMessage, npe); | |||
| } | |||
| // make sure that we have a target to execute | |||
| @@ -59,6 +59,7 @@ import java.util.*; | |||
| import java.text.*; | |||
| import org.apache.tools.ant.types.FilterSet; | |||
| import org.apache.tools.ant.types.FilterSetCollection; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| @@ -108,12 +109,13 @@ public class Project { | |||
| private Hashtable taskClassDefinitions = new Hashtable(); | |||
| private Hashtable targets = new Hashtable(); | |||
| private FilterSet globalFilterSet = new FilterSet(); | |||
| private FilterSetCollection globalFilters = new FilterSetCollection(globalFilterSet); | |||
| private File baseDir; | |||
| private Vector listeners = new Vector(); | |||
| /** The system classloader - may be null */ | |||
| private ClassLoader systemLoader = null; | |||
| /** The Ant core classloader - may be null if using system loader */ | |||
| private ClassLoader coreLoader = null; | |||
| /** Records the latest task on a thread */ | |||
| private Hashtable threadTasks = new Hashtable(); | |||
| @@ -216,12 +218,12 @@ public class Project { | |||
| setSystemProperties(); | |||
| } | |||
| public void setSystemLoader(ClassLoader systemLoader) { | |||
| this.systemLoader = systemLoader; | |||
| public void setCoreLoader(ClassLoader coreLoader) { | |||
| this.coreLoader = coreLoader; | |||
| } | |||
| public ClassLoader getSystemLoader() { | |||
| return systemLoader; | |||
| public ClassLoader getCoreLoader() { | |||
| return coreLoader; | |||
| } | |||
| public void addBuildListener(BuildListener listener) { | |||
| @@ -671,7 +673,7 @@ public class Project { | |||
| */ | |||
| public void copyFile(String sourceFile, String destFile, boolean filtering) | |||
| throws IOException { | |||
| fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilterSet : null); | |||
| fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilters : null); | |||
| } | |||
| /** | |||
| @@ -685,7 +687,7 @@ public class Project { | |||
| */ | |||
| public void copyFile(String sourceFile, String destFile, boolean filtering, | |||
| boolean overwrite) throws IOException { | |||
| fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilterSet : null, overwrite); | |||
| fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilters : null, overwrite); | |||
| } | |||
| /** | |||
| @@ -702,7 +704,7 @@ public class Project { | |||
| public void copyFile(String sourceFile, String destFile, boolean filtering, | |||
| boolean overwrite, boolean preserveLastModified) | |||
| throws IOException { | |||
| fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilterSet : null, | |||
| fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilters : null, | |||
| overwrite, preserveLastModified); | |||
| } | |||
| @@ -728,7 +730,7 @@ public class Project { | |||
| */ | |||
| public void copyFile(File sourceFile, File destFile, boolean filtering) | |||
| throws IOException { | |||
| fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilterSet : null); | |||
| fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilters : null); | |||
| } | |||
| /** | |||
| @@ -742,7 +744,7 @@ public class Project { | |||
| */ | |||
| public void copyFile(File sourceFile, File destFile, boolean filtering, | |||
| boolean overwrite) throws IOException { | |||
| fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilterSet : null, overwrite); | |||
| fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilters : null, overwrite); | |||
| } | |||
| /** | |||
| @@ -759,7 +761,7 @@ public class Project { | |||
| public void copyFile(File sourceFile, File destFile, boolean filtering, | |||
| boolean overwrite, boolean preserveLastModified) | |||
| throws IOException { | |||
| fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilterSet : null, | |||
| fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilters : null, | |||
| overwrite, preserveLastModified); | |||
| } | |||
| @@ -73,7 +73,8 @@ public class Log4jListener implements BuildListener { | |||
| public Log4jListener() { | |||
| initialized = false; | |||
| Category cat = Category.getInstance("org.apache.tools.ant"); | |||
| if (!(cat.getAllAppenders() instanceof NullEnumeration)) { | |||
| Category rootCat = Category.getRoot(); | |||
| if (!(rootCat.getAllAppenders() instanceof NullEnumeration)) { | |||
| initialized = true; | |||
| } | |||
| else { | |||
| @@ -90,7 +91,7 @@ public class Log4jListener implements BuildListener { | |||
| public void buildFinished(BuildEvent event) { | |||
| if (initialized) { | |||
| Category cat = Category.getInstance(Target.class.getName()); | |||
| Category cat = Category.getInstance(Project.class.getName()); | |||
| if (event.getException() == null) { | |||
| cat.info("Build finished."); | |||
| } | |||
| @@ -365,14 +365,14 @@ public class Copy extends Task { | |||
| try { | |||
| log("Copying " + fromFile + " to " + toFile, verbosity); | |||
| FilterSet executionFilterSet = new FilterSet(); | |||
| FilterSetCollection executionFilters = new FilterSetCollection(); | |||
| if (filtering) { | |||
| executionFilterSet.addFilterSet(project.getGlobalFilterSet()); | |||
| executionFilters.addFilterSet(project.getGlobalFilterSet()); | |||
| } | |||
| for (Enumeration filterEnum = filterSets.elements(); filterEnum.hasMoreElements();) { | |||
| executionFilterSet.addFilterSet((FilterSet)filterEnum.nextElement()); | |||
| executionFilters.addFilterSet((FilterSet)filterEnum.nextElement()); | |||
| } | |||
| fileUtils.copyFile(fromFile, toFile, executionFilterSet, | |||
| fileUtils.copyFile(fromFile, toFile, executionFilters, | |||
| forceOverwrite, preserveLastModified); | |||
| } catch (IOException ioe) { | |||
| String msg = "Failed to copy " + fromFile + " to " + toFile | |||
| @@ -187,7 +187,7 @@ public class DependSet extends MatchingTask { | |||
| for (int i = 0; i < targetFiles.length; i++) { | |||
| File dest = new File(targetFS.getDir(project), targetFiles[i]); | |||
| allTargets.add(dest); | |||
| allTargets.addElement(dest); | |||
| if (dest.lastModified() > now) { | |||
| log("Warning: "+targetFiles[i]+" modified in the future.", | |||
| @@ -215,7 +215,7 @@ public class DependSet extends MatchingTask { | |||
| continue; | |||
| } | |||
| else { | |||
| allTargets.add(dest); | |||
| allTargets.addElement(dest); | |||
| } | |||
| if (dest.lastModified() > now) { | |||
| log("Warning: "+targetFiles[i]+" modified in the future.", | |||
| @@ -114,7 +114,7 @@ public class ExecuteJava { | |||
| if (classpath == null) { | |||
| target = Class.forName(classname); | |||
| } else { | |||
| loader = new AntClassLoader(project.getSystemLoader(), project, classpath, false); | |||
| loader = new AntClassLoader(project.getCoreLoader(), project, classpath, false); | |||
| loader.setIsolated(true); | |||
| loader.setThreadContextLoader(); | |||
| target = loader.forceLoadClass(classname); | |||
| @@ -70,7 +70,9 @@ public class Jar extends Zip { | |||
| private File manifestFile; | |||
| private Manifest manifest; | |||
| private Manifest execManifest; | |||
| private Manifest execManifest; | |||
| /** true if a manifest has been specified in the task */ | |||
| private boolean buildFileManifest = false; | |||
| public Jar() { | |||
| @@ -279,15 +281,22 @@ public class Jar extends Zip { | |||
| theZipFile = new java.util.zip.ZipFile(zipFile); | |||
| java.util.zip.ZipEntry entry = theZipFile.getEntry("META-INF/MANIFEST.MF"); | |||
| if (entry == null) { | |||
| log("Updating jar since the current jar has no manifest", Project.MSG_VERBOSE); | |||
| return false; | |||
| } | |||
| Manifest currentManifest = new Manifest(theZipFile.getInputStream(entry)); | |||
| if (manifest == null) { | |||
| manifest = getDefaultManifest(); | |||
| } | |||
| if (!currentManifest.equals(manifest)) { | |||
| log("Updating jar since jar manifest has changed", Project.MSG_VERBOSE); | |||
| return false; | |||
| } | |||
| } | |||
| catch (Exception e) { | |||
| // any problems and we will rebuild | |||
| log("Updating jar since cannot read current jar manifest: " + e.getClass().getName() + e.getMessage(), | |||
| Project.MSG_VERBOSE); | |||
| return false; | |||
| } | |||
| finally { | |||
| @@ -115,6 +115,7 @@ public class Javac extends MatchingTask { | |||
| private boolean includeAntRuntime = true; | |||
| private boolean includeJavaRuntime = false; | |||
| private boolean fork = false; | |||
| private boolean nowarn = false; | |||
| protected boolean failOnError = true; | |||
| protected File[] compileList = new File[0]; | |||
| @@ -410,6 +411,20 @@ public class Javac extends MatchingTask { | |||
| } | |||
| /** | |||
| * Sets whether the -nowarn option should be used. | |||
| */ | |||
| public void setNowarn(boolean flag) { | |||
| this.nowarn = flag; | |||
| } | |||
| /** | |||
| * Should the -nowarn option be used. | |||
| */ | |||
| public boolean getNowarn() { | |||
| return nowarn; | |||
| } | |||
| /** | |||
| * Executes the task. | |||
| */ | |||
| @@ -681,9 +681,10 @@ public class Javadoc extends Task { | |||
| public String getPackages() { | |||
| StringBuffer p = new StringBuffer( "\"" ); | |||
| for (int i = 0; i < packages.size(); i++) { | |||
| p.append( packages.elementAt( i ).toString() ); | |||
| if ( i > 0 ) | |||
| if ( i > 0 ) { | |||
| p.append( ":" ); | |||
| } | |||
| p.append( packages.elementAt(i).toString() ); | |||
| } | |||
| p.append( "\"" ); | |||
| return p.toString(); | |||
| @@ -123,14 +123,14 @@ public class Move extends Copy { | |||
| try { | |||
| log("Moving " + fromFile + " to " + toFile, verbosity); | |||
| FilterSet executionFilterSet = new FilterSet(); | |||
| FilterSetCollection executionFilters = new FilterSetCollection(); | |||
| if (filtering) { | |||
| executionFilterSet.addFilterSet(project.getGlobalFilterSet()); | |||
| executionFilters.addFilterSet(project.getGlobalFilterSet()); | |||
| } | |||
| for (Enumeration filterEnum = getFilterSets().elements(); filterEnum.hasMoreElements();) { | |||
| executionFilterSet.addFilterSet((FilterSet)filterEnum.nextElement()); | |||
| executionFilters.addFilterSet((FilterSet)filterEnum.nextElement()); | |||
| } | |||
| getFileUtils().copyFile(f, d, executionFilterSet, | |||
| getFileUtils().copyFile(f, d, executionFilters, | |||
| forceOverwrite); | |||
| f = new File(fromFile); | |||
| @@ -54,19 +54,51 @@ | |||
| package org.apache.tools.ant.taskdefs; | |||
| import org.apache.tools.ant.*; | |||
| import java.io.File; | |||
| /** | |||
| * Proxy interface for XSLT processors. | |||
| * | |||
| * @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a> | |||
| * @version $Revision$ $Date$ | |||
| * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a> | |||
| * @see #XSLTProcess | |||
| */ | |||
| public interface XSLTLiaison { | |||
| public void setStylesheet(String fileName) throws Exception; | |||
| /** | |||
| * the file protocol prefix for systemid. | |||
| * This file protocol must be appended to an absolute path. | |||
| * Typically: <tt>FILE_PROTOCOL_PREFIX + file.getAbsolutePath()</tt> | |||
| * This is not correct in specification terms since an absolute | |||
| * url in Unix is file:// + file.getAbsolutePath() while it is | |||
| * file:/// + file.getAbsolutePath() under Windows. | |||
| * Whatever, it should not be a problem to put file:/// in every | |||
| * case since most parsers for now incorrectly makes no difference | |||
| * between it.. and users also have problem with that :) | |||
| */ | |||
| public final static String FILE_PROTOCOL_PREFIX = "file:///"; | |||
| /** | |||
| * set the stylesheet to use for the transformation. | |||
| * @param stylesheet the stylesheet to be used for transformation. | |||
| */ | |||
| public void setStylesheet(File stylesheet) throws Exception; | |||
| /** | |||
| * Add a parameter to be set during the XSL transformation. | |||
| * @param name the parameter name. | |||
| * @param expression the parameter value as an expression string. | |||
| * @throws Exception thrown if any problems happens. | |||
| */ | |||
| public void addParam(String name, String expression) throws Exception; | |||
| public void transform(String infile, String outfile) throws Exception; | |||
| /** | |||
| * Perform the transformation of a file into another. | |||
| * @param infile the input file, probably an XML one. :-) | |||
| * @param outfile the output file resulting from the transformation | |||
| * @throws Exception thrown if any problems happens. | |||
| * @see #setStylesheet(File) | |||
| */ | |||
| public void transform(File infile, File outfile) throws Exception; | |||
| } //-- XSLTLiaison | |||
| @@ -100,9 +100,9 @@ public class XSLTProcess extends MatchingTask { | |||
| private String targetExtension = ".html"; | |||
| private Vector params = new Vector(); | |||
| private File inFile = null; | |||
| private File outFile = null; | |||
| private String processor; | |||
| @@ -137,7 +137,7 @@ public class XSLTProcess extends MatchingTask { | |||
| if (baseDir == null) { | |||
| baseDir = project.resolveFile("."); | |||
| } | |||
| liaison = getLiaison(); | |||
| log("Using "+liaison.getClass().toString(), Project.MSG_VERBOSE); | |||
| @@ -178,7 +178,7 @@ public class XSLTProcess extends MatchingTask { | |||
| for (int i = 0;i < list.length; ++i) { | |||
| process( baseDir, list[i], destDir, stylesheet ); | |||
| } | |||
| // Process all the directoried marked for styling | |||
| dirs = scanner.getIncludedDirectories(); | |||
| for (int j = 0;j < dirs.length;++j){ | |||
| @@ -264,15 +264,15 @@ public class XSLTProcess extends MatchingTask { | |||
| */ | |||
| private void resolveProcessor(String proc) throws Exception { | |||
| if (proc.equals("trax")) { | |||
| final Class clazz = | |||
| final Class clazz = | |||
| loadClass("org.apache.tools.ant.taskdefs.optional.TraXLiaison"); | |||
| liaison = (XSLTLiaison)clazz.newInstance(); | |||
| } else if (proc.equals("xslp")) { | |||
| final Class clazz = | |||
| final Class clazz = | |||
| loadClass("org.apache.tools.ant.taskdefs.optional.XslpLiaison"); | |||
| liaison = (XSLTLiaison) clazz.newInstance(); | |||
| } else if (proc.equals("xalan")) { | |||
| final Class clazz = | |||
| final Class clazz = | |||
| loadClass("org.apache.tools.ant.taskdefs.optional.XalanLiaison"); | |||
| liaison = (XSLTLiaison)clazz.newInstance(); | |||
| } else { | |||
| @@ -313,14 +313,14 @@ public class XSLTProcess extends MatchingTask { | |||
| * Processes the given input XML file and stores the result | |||
| * in the given resultFile. | |||
| **/ | |||
| private void process(File baseDir, String xmlFile, File destDir, | |||
| private void process(File baseDir, String xmlFile, File destDir, | |||
| File stylesheet) | |||
| throws BuildException { | |||
| String fileExt=targetExtension; | |||
| File outFile=null; | |||
| File inFile=null; | |||
| try { | |||
| long styleSheetLastModified = stylesheet.lastModified(); | |||
| inFile = new File(baseDir,xmlFile); | |||
| @@ -337,7 +337,7 @@ public class XSLTProcess extends MatchingTask { | |||
| log("Transforming into "+destDir); | |||
| configureLiaison(stylesheet); | |||
| liaison.transform(inFile.toString(), outFile.toString()); | |||
| liaison.transform(inFile, outFile); | |||
| } | |||
| } | |||
| catch (Exception ex) { | |||
| @@ -347,7 +347,7 @@ public class XSLTProcess extends MatchingTask { | |||
| if (outFile != null) { | |||
| outFile.delete(); | |||
| } | |||
| throw new BuildException(ex); | |||
| } | |||
| @@ -365,7 +365,7 @@ public class XSLTProcess extends MatchingTask { | |||
| ensureDirectoryFor( outFile ); | |||
| log("Processing " + inFile + " to " + outFile, Project.MSG_INFO); | |||
| configureLiaison(stylesheet); | |||
| liaison.transform(inFile.toString(), outFile.toString()); | |||
| liaison.transform(inFile, outFile); | |||
| } | |||
| }catch (Exception ex) { | |||
| log("Failed to process " + inFile, Project.MSG_INFO); | |||
| @@ -378,12 +378,12 @@ public class XSLTProcess extends MatchingTask { | |||
| File directory = new File( targetFile.getParent() ); | |||
| if (!directory.exists()) { | |||
| if (!directory.mkdirs()) { | |||
| throw new BuildException("Unable to create directory: " | |||
| throw new BuildException("Unable to create directory: " | |||
| + directory.getAbsolutePath() ); | |||
| } | |||
| } | |||
| } | |||
| protected XSLTLiaison getLiaison() { | |||
| // if processor wasn't specified, see if TraX is available. If not, | |||
| // default it to xslp or xalan, depending on which is in the classpath | |||
| @@ -424,20 +424,20 @@ public class XSLTProcess extends MatchingTask { | |||
| public class Param { | |||
| private String name=null; | |||
| private String expression=null; | |||
| public void setName(String name){ | |||
| this.name = name; | |||
| } | |||
| public void setExpression(String expression){ | |||
| this.expression = expression; | |||
| } | |||
| public String getName() throws BuildException{ | |||
| if(name==null)throw new BuildException("Name attribute is missing."); | |||
| return name; | |||
| } | |||
| public String getExpression() throws BuildException{ | |||
| if(expression==null)throw new BuildException("Expression attribute is missing."); | |||
| return expression; | |||
| @@ -455,7 +455,7 @@ public class XSLTProcess extends MatchingTask { | |||
| try { | |||
| log( "Loading stylesheet " + stylesheet, Project.MSG_INFO); | |||
| liaison.setStylesheet( stylesheet.toString() ); | |||
| liaison.setStylesheet( stylesheet ); | |||
| for(Enumeration e = params.elements();e.hasMoreElements();) { | |||
| Param p = (Param)e.nextElement(); | |||
| liaison.addParam( p.getName(), p.getExpression() ); | |||
| @@ -206,6 +206,10 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { | |||
| protected Commandline setupJavacCommandlineSwitches(Commandline cmd) { | |||
| Path classpath = getCompileClasspath(); | |||
| if (attributes.getNowarn()) { | |||
| cmd.createArgument().setValue("-nowarn"); | |||
| } | |||
| if (deprecation == true) { | |||
| cmd.createArgument().setValue("-deprecation"); | |||
| } | |||
| @@ -173,7 +173,21 @@ public class Jikes extends DefaultCompilerAdapter { | |||
| * warning can be pretty annoying. | |||
| */ | |||
| String warningsProperty = project.getProperty("build.compiler.warnings"); | |||
| if (warningsProperty != null && !Project.toBoolean(warningsProperty)) { | |||
| if (warningsProperty != null) { | |||
| attributes.log("!! the build.compiler.warnings property is deprecated. !!", | |||
| Project.MSG_WARN); | |||
| attributes.log("!! Use the nowarn attribute instead. !!", | |||
| Project.MSG_WARN); | |||
| if (!Project.toBoolean(warningsProperty)) { | |||
| cmd.createArgument().setValue("-nowarn"); | |||
| } | |||
| } if (attributes.getNowarn()) { | |||
| /* | |||
| * FIXME later | |||
| * | |||
| * let the magic property win over the attribute for backwards | |||
| * compatibility | |||
| */ | |||
| cmd.createArgument().setValue("-nowarn"); | |||
| } | |||
| @@ -113,8 +113,8 @@ vsscheckout=org.apache.tools.ant.taskdefs.optional.vss.MSVSSCHECKOUT | |||
| iplanet-ejbc=org.apache.tools.ant.taskdefs.optional.ejb.IPlanetEjbcTask | |||
| jdepend=org.apache.tools.ant.taskdefs.optional.jdepend.JDependTask | |||
| mimemail=org.apache.tools.ant.taskdefs.optional.net.MimeMail | |||
| cccheckin=org.apache.tools.ant.taskdefs.optional.ccm.CCMCheckin | |||
| cccheckout=org.apache.tools.ant.taskdefs.optional.ccm.CCMCheckout | |||
| ccmcheckin=org.apache.tools.ant.taskdefs.optional.ccm.CCMCheckin | |||
| ccmcheckout=org.apache.tools.ant.taskdefs.optional.ccm.CCMCheckout | |||
| ccmcheckintask=org.apache.tools.ant.taskdefs.optional.ccm.CCMCheckinDefault | |||
| ccmreconfigure=org.apache.tools.ant.taskdefs.optional.ccm.CCMReconfigure | |||
| ccmcreatetask=org.apache.tools.ant.taskdefs.optional.ccm.CCMCreateTask | |||
| @@ -54,61 +54,109 @@ | |||
| package org.apache.tools.ant.taskdefs.optional; | |||
| import java.io.File; | |||
| import java.io.FileInputStream; | |||
| import java.io.FileOutputStream; | |||
| import java.io.IOException; | |||
| import org.apache.tools.ant.taskdefs.XSLTLiaison; | |||
| import javax.xml.transform.TransformerFactory; | |||
| import javax.xml.transform.Transformer; | |||
| import javax.xml.transform.Templates; | |||
| import javax.xml.transform.Source; | |||
| import javax.xml.transform.stream.StreamResult; | |||
| import javax.xml.transform.stream.StreamSource; | |||
| /** | |||
| * Concrete liaison for XSLT processor implementing TraX. (ie JAXP 1.1) | |||
| * | |||
| * @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a> | |||
| * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a> | |||
| * @version $Revision$ $Date$ | |||
| * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a> | |||
| */ | |||
| public class TraXLiaison implements XSLTLiaison { | |||
| protected final static String FILEURL = "file:"; | |||
| /** The trax TransformerFactory */ | |||
| private TransformerFactory tfactory = null; | |||
| /** stylesheet stream, close it asap */ | |||
| private FileInputStream xslStream = null; | |||
| /** Stylesheet template */ | |||
| private Templates templates = null; | |||
| /** The trax Transformer itself */ | |||
| private Transformer transformer; | |||
| /** transformer */ | |||
| private Transformer transformer = null; | |||
| public TraXLiaison() throws Exception { | |||
| tfactory = TransformerFactory.newInstance(); | |||
| } | |||
| //------------------- IMPORTANT | |||
| // 1) Don't use the StreamSource(File) ctor. It won't work with | |||
| // xalan prior to 2.2 because of systemid bugs. | |||
| // 2) Use a stream so that you can close it yourself quickly | |||
| // and avoid keeping the handle until the object is garbaged. | |||
| // (always keep control), otherwise you won't be able to delete | |||
| // the file quickly on windows. | |||
| // 3) Always set the systemid to the source for imports, includes... | |||
| // in xsl and xml... | |||
| public void setStylesheet(String fileName) throws Exception { | |||
| templates = tfactory.newTemplates(new StreamSource(normalize(fileName))); | |||
| public void setStylesheet(File stylesheet) throws Exception { | |||
| xslStream = new FileInputStream(stylesheet); | |||
| StreamSource src = new StreamSource(xslStream); | |||
| src.setSystemId(getSystemId(stylesheet)); | |||
| templates = tfactory.newTemplates(src); | |||
| transformer = templates.newTransformer(); | |||
| }; | |||
| } | |||
| public void transform(String infile, String outfile) throws Exception { | |||
| FileOutputStream out = new FileOutputStream(outfile); | |||
| public void transform(File infile, File outfile) throws Exception { | |||
| FileInputStream fis = null; | |||
| FileOutputStream fos = null; | |||
| try { | |||
| transformer.transform(new StreamSource(normalize(infile)), | |||
| new StreamResult(out)); | |||
| fis = new FileInputStream(infile); | |||
| fos = new FileOutputStream(outfile); | |||
| StreamSource src = new StreamSource(fis); | |||
| src.setSystemId(getSystemId(infile)); | |||
| StreamResult res = new StreamResult(fos); | |||
| // not sure what could be the need of this... | |||
| res.setSystemId(getSystemId(outfile)); | |||
| transformer.transform(src, res); | |||
| } finally { | |||
| out.close(); | |||
| // make sure to close all handles, otherwise the garbage | |||
| // collector will close them...whenever possible and | |||
| // Windows may complain about not being able to delete files. | |||
| try { | |||
| if (xslStream != null){ | |||
| xslStream.close(); | |||
| } | |||
| } catch (IOException ignored){} | |||
| try { | |||
| if (fis != null){ | |||
| fis.close(); | |||
| } | |||
| } catch (IOException ignored){} | |||
| try { | |||
| if (fos != null){ | |||
| fos.close(); | |||
| } | |||
| } catch (IOException ignored){} | |||
| } | |||
| } | |||
| protected String normalize(String fileName) { | |||
| if(fileName != null && !fileName.startsWith(FILEURL)) { | |||
| return FILEURL + "///" + fileName; | |||
| } | |||
| return fileName; | |||
| // make sure that the systemid is made of '/' and not '\' otherwise | |||
| // crimson will complain that it cannot resolve relative entities | |||
| // because it grabs the base uri via lastIndexOf('/') without | |||
| // making sure it is really a /'ed path | |||
| protected String getSystemId(File file){ | |||
| String path = file.getAbsolutePath(); | |||
| path = path.replace('\\','/'); | |||
| return FILE_PROTOCOL_PREFIX + path; | |||
| } | |||
| public void addParam(String name, String value){ | |||
| transformer.setParameter(name, value); | |||
| } | |||
| @@ -60,39 +60,70 @@ import org.apache.xalan.xslt.XSLTProcessorFactory; | |||
| import org.apache.xalan.xslt.XSLTProcessor; | |||
| import org.apache.xalan.xslt.XSLTInputSource; | |||
| import org.apache.xalan.xslt.XSLTResultTarget; | |||
| import org.xml.sax.InputSource; | |||
| import java.io.File; | |||
| import java.io.FileInputStream; | |||
| import java.io.FileOutputStream; | |||
| import java.io.IOException; | |||
| /** | |||
| * Concrete liaison for Xalan 1.x API. | |||
| * | |||
| * @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a> | |||
| * @version $Revision$ $Date$ | |||
| * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a> | |||
| */ | |||
| public class XalanLiaison implements XSLTLiaison { | |||
| protected final static String FILEURL = "file:"; | |||
| XSLTProcessor processor; | |||
| XSLTInputSource xslSheet; | |||
| protected XSLTProcessor processor; | |||
| protected File stylesheet; | |||
| public XalanLiaison() throws Exception { | |||
| processor = XSLTProcessorFactory.getProcessor(); | |||
| } | |||
| public void setStylesheet(String fileName) throws Exception { | |||
| xslSheet = new XSLTInputSource (normalize(fileName)); | |||
| }; | |||
| public void transform(String infile, String outfile) throws Exception { | |||
| processor.process(new XSLTInputSource(normalize(infile)), xslSheet, | |||
| new XSLTResultTarget(outfile)); | |||
| public void setStylesheet(File stylesheet) throws Exception { | |||
| this.stylesheet = stylesheet; | |||
| } | |||
| protected String normalize(String fileName) { | |||
| if(fileName != null && !fileName.startsWith(FILEURL)) { | |||
| return FILEURL + fileName; | |||
| public void transform(File infile, File outfile) throws Exception { | |||
| FileInputStream fis = null; | |||
| FileOutputStream fos = null; | |||
| FileInputStream xslStream = null; | |||
| try { | |||
| xslStream = new FileInputStream(stylesheet); | |||
| fis = new FileInputStream(infile); | |||
| fos = new FileOutputStream(outfile); | |||
| // systemid such as file:/// + getAbsolutePath() are considered | |||
| // invalid here... | |||
| XSLTInputSource xslSheet = new XSLTInputSource(xslStream); | |||
| xslSheet.setSystemId(stylesheet.getAbsolutePath()); | |||
| XSLTInputSource src = new XSLTInputSource(fis); | |||
| src.setSystemId(infile.getAbsolutePath()); | |||
| XSLTResultTarget res = new XSLTResultTarget(fos); | |||
| processor.process(src, xslSheet, res); | |||
| } finally { | |||
| // make sure to close all handles, otherwise the garbage | |||
| // collector will close them...whenever possible and | |||
| // Windows may complain about not being able to delete files. | |||
| try { | |||
| if (xslStream != null){ | |||
| xslStream.close(); | |||
| } | |||
| } catch (IOException ignored){} | |||
| try { | |||
| if (fis != null){ | |||
| fis.close(); | |||
| } | |||
| } catch (IOException ignored){} | |||
| try { | |||
| if (fos != null){ | |||
| fos.close(); | |||
| } | |||
| } catch (IOException ignored){} | |||
| } | |||
| return fileName; | |||
| } | |||
| public void addParam(String name, String value){ | |||
| processor.setStylesheetParam(name, value); | |||
| } | |||
| @@ -54,40 +54,45 @@ | |||
| package org.apache.tools.ant.taskdefs.optional; | |||
| import java.io.FileWriter; | |||
| import java.io.*; | |||
| import java.net.URL; | |||
| import org.apache.tools.ant.taskdefs.XSLTLiaison; | |||
| import org.xml.sax.InputSource; | |||
| import com.kvisco.xsl.XSLProcessor; | |||
| import com.kvisco.xsl.XSLReader; | |||
| import com.kvisco.xsl.XSLStylesheet; | |||
| import com.kvisco.xsl.*; | |||
| /** | |||
| * Concrete liaison for XSLP | |||
| * | |||
| * @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a> | |||
| * @version $Revision$ $Date$ | |||
| * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a> | |||
| */ | |||
| public class XslpLiaison implements XSLTLiaison { | |||
| XSLProcessor processor; | |||
| XSLStylesheet xslSheet; | |||
| protected XSLProcessor processor; | |||
| protected XSLStylesheet xslSheet; | |||
| public XslpLiaison() { | |||
| processor = new XSLProcessor(); | |||
| // uh ?! I'm forced to do that otherwise a setProperty crashes with NPE ! | |||
| // I don't understand why the property map is static though... | |||
| // how can we do multithreading w/ multiple identical parameters ? | |||
| processor.getProperty("dummy-to-init-properties-map"); | |||
| } | |||
| public void setStylesheet(String fileName) throws Exception { | |||
| public void setStylesheet(File fileName) throws Exception { | |||
| XSLReader xslReader = new XSLReader(); | |||
| xslSheet = xslReader.read( fileName ); | |||
| }; | |||
| // a file:/// + getAbsolutePath() does not work here | |||
| // it is really the pathname | |||
| xslSheet = xslReader.read( fileName.getAbsolutePath() ); | |||
| } | |||
| public void transform(String infile, String outfile) throws Exception { | |||
| FileWriter out = new FileWriter(outfile); | |||
| try { | |||
| processor.process(infile, xslSheet, out); | |||
| } finally { | |||
| out.close(); | |||
| } | |||
| public void transform(File infile, File outfile) throws Exception { | |||
| FileOutputStream fos = new FileOutputStream(outfile); | |||
| // XSLP does not support encoding...we're in hot water. | |||
| OutputStreamWriter out = new OutputStreamWriter(fos,"UTF8"); | |||
| processor.process(infile.getAbsolutePath(), xslSheet, out); | |||
| } | |||
| public void addParam(String name, String expression){ | |||
| @@ -137,6 +137,12 @@ public class Depend extends MatchingTask { | |||
| /** The classpath to look for additional dependencies */ | |||
| private Path dependClasspath; | |||
| /** | |||
| * constants used with the cache file | |||
| */ | |||
| private final static String CACHE_FILE_NAME = "dependencies.txt"; | |||
| private final static String CLASSNAME_PREPEND = "||:"; | |||
| /** | |||
| * Set the classpath to be used for this dependency check. | |||
| */ | |||
| @@ -169,46 +175,74 @@ public class Depend extends MatchingTask { | |||
| public void setClasspathRef(Reference r) { | |||
| createClasspath().setRefid(r); | |||
| } | |||
| private void writeDependencyList(File depFile, Vector dependencyList) throws IOException { | |||
| // new dependencies so need to write them out to the cache | |||
| PrintWriter pw = null; | |||
| try { | |||
| String parent = depFile.getParent(); | |||
| if (parent != null) { | |||
| new File(parent).mkdirs(); | |||
| } | |||
| pw = new PrintWriter(new FileWriter(depFile)); | |||
| for (Enumeration deps = dependencyList.elements(); deps.hasMoreElements();) { | |||
| pw.println(deps.nextElement()); | |||
| } | |||
| } | |||
| finally { | |||
| if (pw != null) { | |||
| pw.close(); | |||
| /** | |||
| * Read the dependencies from cache file | |||
| */ | |||
| private Hashtable readCachedDependencies() throws IOException{ | |||
| Hashtable dependencyMap = new Hashtable(); | |||
| if (cache != null) { | |||
| File depFile = new File(cache, CACHE_FILE_NAME); | |||
| BufferedReader in = null; | |||
| if (depFile.exists()) { | |||
| try { | |||
| in = new BufferedReader(new FileReader(depFile)); | |||
| String line = null; | |||
| Vector dependencyList = null; | |||
| String className = null; | |||
| int prependLength = CLASSNAME_PREPEND.length(); | |||
| while ((line = in.readLine()) != null) { | |||
| if (line.startsWith(CLASSNAME_PREPEND)) { | |||
| dependencyList = new Vector(); | |||
| className = line.substring(prependLength); | |||
| dependencyMap.put(className, dependencyList); | |||
| } | |||
| else { | |||
| dependencyList.addElement(line); | |||
| } | |||
| } | |||
| } | |||
| finally { | |||
| if (in != null) { | |||
| in.close(); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return dependencyMap; | |||
| } | |||
| private Vector readDependencyList(File depFile) throws IOException { | |||
| Vector dependencyList = null; | |||
| BufferedReader in = null; | |||
| try { | |||
| in = new BufferedReader(new FileReader(depFile)); | |||
| String line = null; | |||
| dependencyList = new Vector(); | |||
| while ((line = in.readLine()) != null) { | |||
| dependencyList.addElement(line); | |||
| /** | |||
| * Write the dependencies to cache file | |||
| */ | |||
| private void writeCachedDependencies(Hashtable dependencyMap) throws IOException{ | |||
| if (cache != null) { | |||
| PrintWriter pw = null; | |||
| try { | |||
| cache.mkdirs(); | |||
| File depFile = new File(cache, CACHE_FILE_NAME); | |||
| pw = new PrintWriter(new FileWriter(depFile)); | |||
| for (Enumeration deps = dependencyMap.keys(); deps.hasMoreElements();) { | |||
| String className = (String)deps.nextElement(); | |||
| pw.println(CLASSNAME_PREPEND + className); | |||
| Vector dependencyList = (Vector)dependencyMap.get(className); | |||
| int size = dependencyList.size(); | |||
| for (int x = 0; x < size; x++) { | |||
| pw.println(dependencyList.elementAt(x)); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| finally { | |||
| if (in != null) { | |||
| in.close(); | |||
| finally { | |||
| if (pw != null) { | |||
| pw.close(); | |||
| } | |||
| } | |||
| } | |||
| return dependencyList; | |||
| } | |||
| @@ -221,7 +255,20 @@ public class Depend extends MatchingTask { | |||
| private void determineDependencies() throws IOException { | |||
| affectedClassMap = new Hashtable(); | |||
| classFileInfoMap = new Hashtable(); | |||
| Hashtable dependencyMap = new Hashtable(); | |||
| boolean cacheDirty = false; | |||
| Hashtable dependencyMap = null; | |||
| File depCacheFile = null; | |||
| boolean depCacheFileExists = true; | |||
| long depCacheFileLastModified = Long.MAX_VALUE; | |||
| // read the dependency cache from the disk | |||
| if (cache != null) { | |||
| dependencyMap = readCachedDependencies(); | |||
| depCacheFile = new File(cache, CACHE_FILE_NAME); | |||
| depCacheFileExists = depCacheFile.exists(); | |||
| depCacheFileLastModified = depCacheFile.lastModified(); | |||
| } | |||
| for (Enumeration e = getClassFiles(destPath).elements(); e.hasMoreElements(); ) { | |||
| ClassFileInfo info = (ClassFileInfo)e.nextElement(); | |||
| log("Adding class info for " + info.className, Project.MSG_DEBUG); | |||
| @@ -230,12 +277,11 @@ public class Depend extends MatchingTask { | |||
| Vector dependencyList = null; | |||
| if (cache != null) { | |||
| // try to read the dependency info from the cache if it is not out of date | |||
| File depFile = new File(cache, info.relativeName + ".dep"); | |||
| if (depFile.exists() && depFile.lastModified() > info.absoluteFile.lastModified()) { | |||
| // try to read the dependency info from the map if it is not out of date | |||
| if (depCacheFileExists && depCacheFileLastModified > info.absoluteFile.lastModified()) { | |||
| // depFile exists and is newer than the class file | |||
| // need to read dependency list from the file. | |||
| dependencyList = readDependencyList(depFile); | |||
| // need to get dependency list from the map. | |||
| dependencyList = (Vector)dependencyMap.get(info.className); | |||
| } | |||
| } | |||
| @@ -248,12 +294,11 @@ public class Depend extends MatchingTask { | |||
| classFile.read(inFileStream); | |||
| dependencyList = classFile.getClassRefs(); | |||
| if (cache != null) { | |||
| // new dependencies so need to write them out to the cache | |||
| File depFile = new File(cache, info.relativeName + ".dep"); | |||
| writeDependencyList(depFile, dependencyList); | |||
| if (dependencyList != null) { | |||
| cacheDirty = true; | |||
| dependencyMap.put(info.className, dependencyList); | |||
| } | |||
| } | |||
| finally { | |||
| if (inFileStream != null) { | |||
| @@ -261,8 +306,7 @@ public class Depend extends MatchingTask { | |||
| } | |||
| } | |||
| } | |||
| dependencyMap.put(info.className, dependencyList); | |||
| // This class depends on each class in the dependency list. For each | |||
| // one of those, add this class into their affected classes list | |||
| for (Enumeration depEnum = dependencyList.elements(); depEnum.hasMoreElements(); ) { | |||
| @@ -326,6 +370,11 @@ public class Depend extends MatchingTask { | |||
| } | |||
| } | |||
| } | |||
| // write the dependency cache to the disk | |||
| if (cache != null && cacheDirty) { | |||
| writeCachedDependencies(dependencyMap); | |||
| } | |||
| } | |||
| private int deleteAllAffectedFiles() { | |||
| @@ -87,6 +87,7 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase { | |||
| * Bunch of constants used for storing entries in a hashtable, and for | |||
| * constructing the filenames of various parts of the ejb jar. | |||
| */ | |||
| private static final String EJB_REF = "ejb-ref"; | |||
| private static final String HOME_INTERFACE = "home"; | |||
| private static final String REMOTE_INTERFACE = "remote"; | |||
| private static final String BEAN_CLASS = "ejb-class"; | |||
| @@ -130,6 +131,8 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase { | |||
| private Hashtable resourceDTDs = new Hashtable(); | |||
| private boolean inEJBRef = false; | |||
| private Hashtable urlDTDs = new Hashtable(); | |||
| /** | |||
| @@ -244,6 +247,7 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase { | |||
| public void startDocument() throws SAXException { | |||
| this.ejbFiles = new Hashtable(10, 1); | |||
| this.currentElement = null; | |||
| inEJBRef = false; | |||
| } | |||
| @@ -258,7 +262,10 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase { | |||
| throws SAXException { | |||
| this.currentElement = name; | |||
| currentText = ""; | |||
| if (parseState == STATE_LOOKING_EJBJAR && name.equals(EJB_JAR)) { | |||
| if (name.equals(EJB_REF)) { | |||
| inEJBRef = true; | |||
| } | |||
| else if (parseState == STATE_LOOKING_EJBJAR && name.equals(EJB_JAR)) { | |||
| parseState = STATE_IN_EJBJAR; | |||
| } | |||
| else if (parseState == STATE_IN_EJBJAR && name.equals(ENTERPRISE_BEANS)) { | |||
| @@ -286,7 +293,10 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase { | |||
| processElement(); | |||
| currentText = ""; | |||
| this.currentElement = ""; | |||
| if (parseState == STATE_IN_ENTITY && name.equals(ENTITY_BEAN )) { | |||
| if (name.equals(EJB_REF)) { | |||
| inEJBRef = false; | |||
| } | |||
| else if (parseState == STATE_IN_ENTITY && name.equals(ENTITY_BEAN )) { | |||
| parseState = STATE_IN_BEANS; | |||
| } | |||
| else if (parseState == STATE_IN_SESSION && name.equals(SESSION_BEAN)) { | |||
| @@ -323,7 +333,8 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase { | |||
| protected void processElement() { | |||
| if (parseState != STATE_IN_ENTITY && parseState != STATE_IN_SESSION) { | |||
| if (inEJBRef || | |||
| (parseState != STATE_IN_ENTITY && parseState != STATE_IN_SESSION)) { | |||
| return; | |||
| } | |||
| @@ -263,12 +263,11 @@ public class WLRun extends Task { | |||
| File propertiesFile = null; | |||
| if (weblogicPropertiesFile == null) { | |||
| propertiesFile = new File(weblogicSystemHome, DEFAULT_PROPERTIES_FILE); | |||
| } | |||
| else { | |||
| propertiesFile = new File(weblogicSystemHome, weblogicPropertiesFile); | |||
| weblogicPropertiesFile = DEFAULT_PROPERTIES_FILE; | |||
| } | |||
| propertiesFile = new File(weblogicSystemHome, weblogicPropertiesFile); | |||
| if (!propertiesFile.exists()) { | |||
| // OK, properties file may be absolute | |||
| propertiesFile = project.resolveFile(weblogicPropertiesFile); | |||
| @@ -176,8 +176,8 @@ public class FilterSet extends DataType { | |||
| /** The default token end string */ | |||
| public static final String DEFAULT_TOKEN_END = "@"; | |||
| private String startOftoken = DEFAULT_TOKEN_START; | |||
| private String endOftoken = DEFAULT_TOKEN_END; | |||
| private String startOfToken = DEFAULT_TOKEN_START; | |||
| private String endOfToken = DEFAULT_TOKEN_END; | |||
| /** | |||
| * List of ordered filters and filter files. | |||
| @@ -245,9 +245,17 @@ public class FilterSet extends DataType { | |||
| if (isReference()) { | |||
| throw tooManyAttributes(); | |||
| } | |||
| startOftoken = startOfToken; | |||
| this.startOfToken = startOfToken; | |||
| } | |||
| public String getBeginToken() { | |||
| if (isReference()) { | |||
| return getRef().getBeginToken(); | |||
| } | |||
| return startOfToken; | |||
| } | |||
| /** | |||
| * The string used to id the end of a token. | |||
| * | |||
| @@ -257,9 +265,17 @@ public class FilterSet extends DataType { | |||
| if (isReference()) { | |||
| throw tooManyAttributes(); | |||
| } | |||
| endOftoken = endOfToken; | |||
| this.endOfToken = endOfToken; | |||
| } | |||
| public String getEndToken() { | |||
| if (isReference()) { | |||
| return getRef().getEndToken(); | |||
| } | |||
| return endOfToken; | |||
| } | |||
| /** | |||
| * Read the filters from the given file. | |||
| * | |||
| @@ -268,6 +284,10 @@ public class FilterSet extends DataType { | |||
| * file. | |||
| */ | |||
| public void readFiltersFromFile(File filtersFile) throws BuildException { | |||
| if (isReference()) { | |||
| throw tooManyAttributes(); | |||
| } | |||
| if (filtersFile.isFile()) { | |||
| log("Reading filters from " + filtersFile, Project.MSG_VERBOSE ); | |||
| FileInputStream in = null; | |||
| @@ -310,7 +330,9 @@ public class FilterSet extends DataType { | |||
| * @return The string with the tokens replaced. | |||
| */ | |||
| public String replaceTokens(String line) { | |||
| int index = line.indexOf(startOftoken); | |||
| String beginToken = getBeginToken(); | |||
| String endToken = getEndToken(); | |||
| int index = line.indexOf(beginToken); | |||
| if (index > -1) { | |||
| Hashtable tokens = getFilterHash(); | |||
| @@ -321,24 +343,24 @@ public class FilterSet extends DataType { | |||
| String value = null; | |||
| do { | |||
| int endIndex = line.indexOf(endOftoken, index + startOftoken.length() + 1 ); | |||
| int endIndex = line.indexOf(endToken, index + beginToken.length() + 1 ); | |||
| if (endIndex == -1) { | |||
| break; | |||
| } | |||
| token = line.substring(index + startOftoken.length(), endIndex ); | |||
| token = line.substring(index + beginToken.length(), endIndex ); | |||
| b.append(line.substring(i, index)); | |||
| if (tokens.containsKey(token)) { | |||
| value = (String)tokens.get(token); | |||
| log( "Replacing: " + startOftoken + token + endOftoken + " -> " + value, Project.MSG_VERBOSE ); | |||
| log( "Replacing: " + beginToken + token + endToken + " -> " + value, Project.MSG_VERBOSE ); | |||
| b.append(value); | |||
| i = index + startOftoken.length() + token.length() + endOftoken.length(); | |||
| i = index + beginToken.length() + token.length() + endToken.length(); | |||
| } | |||
| else { | |||
| // just append startOftoken and search further | |||
| b.append(startOftoken); | |||
| i = index + startOftoken.length(); | |||
| // just append beginToken and search further | |||
| b.append(beginToken); | |||
| i = index + beginToken.length(); | |||
| } | |||
| } while ((index = line.indexOf( startOftoken, i )) > -1 ); | |||
| } while ((index = line.indexOf( beginToken, i )) > -1 ); | |||
| b.append(line.substring(i)); | |||
| return b.toString(); | |||
| @@ -0,0 +1,127 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 1999 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", "Ant", 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.tools.ant.types; | |||
| // java io classes | |||
| import java.io.File; | |||
| import java.io.FileInputStream; | |||
| import java.io.IOException; | |||
| // java util classes | |||
| import java.util.Enumeration; | |||
| import java.util.Hashtable; | |||
| import java.util.Properties; | |||
| import java.util.Vector; | |||
| // ant classes | |||
| import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.Task; | |||
| /** | |||
| * A FilterSetCollection is a collection of filtersets each of which may have | |||
| * a different start/end token settings. | |||
| * | |||
| * @author <A href="mailto:conor@apache.org">Conor MacNeill</A> | |||
| */ | |||
| public class FilterSetCollection { | |||
| private Vector filterSets = new Vector(); | |||
| public FilterSetCollection() { | |||
| } | |||
| public FilterSetCollection(FilterSet filterSet) { | |||
| addFilterSet(filterSet); | |||
| } | |||
| public void addFilterSet(FilterSet filterSet) { | |||
| filterSets.addElement(filterSet); | |||
| } | |||
| /** | |||
| * Does replacement on the given string with token matching. | |||
| * This uses the defined starttoken and endtoken values which default to @ for both. | |||
| * | |||
| * @param line The line to process the tokens in. | |||
| * @return The string with the tokens replaced. | |||
| */ | |||
| public String replaceTokens(String line) { | |||
| String replacedLine = line; | |||
| for (Enumeration e = filterSets.elements(); e.hasMoreElements();) { | |||
| FilterSet filterSet = (FilterSet)e.nextElement(); | |||
| replacedLine = filterSet.replaceTokens(replacedLine); | |||
| } | |||
| return replacedLine; | |||
| } | |||
| /** | |||
| * Test to see if this filter set it empty. | |||
| * | |||
| * @return Return true if there are filter in this set otherwise false. | |||
| */ | |||
| public boolean hasFilters() { | |||
| for (Enumeration e = filterSets.elements(); e.hasMoreElements();) { | |||
| FilterSet filterSet = (FilterSet)e.nextElement(); | |||
| if (filterSet.hasFilters()) { | |||
| return true; | |||
| } | |||
| } | |||
| return false; | |||
| } | |||
| } | |||
| @@ -61,7 +61,7 @@ import java.util.Stack; | |||
| import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.types.FilterSet; | |||
| import org.apache.tools.ant.types.FilterSetCollection; | |||
| /** | |||
| * This class also encapsulates methods which allow Files to be | |||
| @@ -106,10 +106,10 @@ public class FileUtils { | |||
| * | |||
| * @throws IOException | |||
| */ | |||
| public void copyFile(String sourceFile, String destFile, FilterSet filterSet) | |||
| public void copyFile(String sourceFile, String destFile, FilterSetCollection filters) | |||
| throws IOException | |||
| { | |||
| copyFile(new File(sourceFile), new File(destFile), filterSet, false, false); | |||
| copyFile(new File(sourceFile), new File(destFile), filters, false, false); | |||
| } | |||
| /** | |||
| @@ -119,9 +119,9 @@ public class FileUtils { | |||
| * | |||
| * @throws IOException | |||
| */ | |||
| public void copyFile(String sourceFile, String destFile, FilterSet filterSet, | |||
| public void copyFile(String sourceFile, String destFile, FilterSetCollection filters, | |||
| boolean overwrite) throws IOException { | |||
| copyFile(new File(sourceFile), new File(destFile), filterSet, | |||
| copyFile(new File(sourceFile), new File(destFile), filters, | |||
| overwrite, false); | |||
| } | |||
| @@ -134,10 +134,10 @@ public class FileUtils { | |||
| * | |||
| * @throws IOException | |||
| */ | |||
| public void copyFile(String sourceFile, String destFile, FilterSet filterSet, | |||
| public void copyFile(String sourceFile, String destFile, FilterSetCollection filters, | |||
| boolean overwrite, boolean preserveLastModified) | |||
| throws IOException { | |||
| copyFile(new File(sourceFile), new File(destFile), filterSet, | |||
| copyFile(new File(sourceFile), new File(destFile), filters, | |||
| overwrite, preserveLastModified); | |||
| } | |||
| @@ -157,9 +157,9 @@ public class FileUtils { | |||
| * | |||
| * @throws IOException | |||
| */ | |||
| public void copyFile(File sourceFile, File destFile, FilterSet filterSet) | |||
| public void copyFile(File sourceFile, File destFile, FilterSetCollection filters) | |||
| throws IOException { | |||
| copyFile(sourceFile, destFile, filterSet, false, false); | |||
| copyFile(sourceFile, destFile, filters, false, false); | |||
| } | |||
| /** | |||
| @@ -169,9 +169,9 @@ public class FileUtils { | |||
| * | |||
| * @throws IOException | |||
| */ | |||
| public void copyFile(File sourceFile, File destFile, FilterSet filterSet, | |||
| public void copyFile(File sourceFile, File destFile, FilterSetCollection filters, | |||
| boolean overwrite) throws IOException { | |||
| copyFile(sourceFile, destFile, filterSet, overwrite, false); | |||
| copyFile(sourceFile, destFile, filters, overwrite, false); | |||
| } | |||
| /** | |||
| @@ -183,7 +183,7 @@ public class FileUtils { | |||
| * | |||
| * @throws IOException | |||
| */ | |||
| public void copyFile(File sourceFile, File destFile, FilterSet filterSet, | |||
| public void copyFile(File sourceFile, File destFile, FilterSetCollection filters, | |||
| boolean overwrite, boolean preserveLastModified) | |||
| throws IOException { | |||
| @@ -201,7 +201,7 @@ public class FileUtils { | |||
| parent.mkdirs(); | |||
| } | |||
| if (filterSet != null && filterSet.hasFilters()) { | |||
| if (filters != null && filters.hasFilters()) { | |||
| BufferedReader in = new BufferedReader(new FileReader(sourceFile)); | |||
| BufferedWriter out = new BufferedWriter(new FileWriter(destFile)); | |||
| @@ -212,7 +212,7 @@ public class FileUtils { | |||
| if (line.length() == 0) { | |||
| out.newLine(); | |||
| } else { | |||
| newline = filterSet.replaceTokens(line); | |||
| newline = filters.replaceTokens(line); | |||
| out.write(newline); | |||
| out.newLine(); | |||
| } | |||
| @@ -0,0 +1,128 @@ | |||
| package org.apache.tools.ant.taskdefs.optional; | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 1999 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", "Jakarta-Regexp", 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/>. | |||
| * | |||
| */ | |||
| import junit.framework.TestCase; | |||
| import org.apache.tools.ant.taskdefs.XSLTLiaison; | |||
| import org.w3c.dom.Document; | |||
| import javax.xml.parsers.DocumentBuilder; | |||
| import javax.xml.parsers.DocumentBuilderFactory; | |||
| import java.io.File; | |||
| import java.net.URL; | |||
| /** | |||
| * Abtract testcase for XSLTLiaison. | |||
| * Override createLiaison for each XSLTLiaison. | |||
| * | |||
| * <a href="sbailliez@apache.org">Stephane Bailliez</a> | |||
| */ | |||
| public abstract class AbstractXSLTLiaisonTest extends TestCase { | |||
| protected XSLTLiaison liaison; | |||
| protected AbstractXSLTLiaisonTest(String name){ | |||
| super(name); | |||
| } | |||
| protected void setUp() throws Exception { | |||
| liaison = createLiaison(); | |||
| } | |||
| // to override | |||
| protected abstract XSLTLiaison createLiaison() throws Exception ; | |||
| protected File getFile(String name){ | |||
| URL url = getClass().getResource(name); | |||
| return new File(url.getFile()); | |||
| } | |||
| /** keep it simple stupid */ | |||
| public void testTransform() throws Exception { | |||
| File xsl = getFile("/taskdefs/optional/xsltliaison-in.xsl"); | |||
| liaison.setStylesheet(xsl); | |||
| liaison.addParam("param", "value"); | |||
| File in = getFile("/taskdefs/optional/xsltliaison-in.xml"); | |||
| File out = new File("xsltliaison.tmp"); | |||
| try { | |||
| liaison.transform(in, out); | |||
| } finally { | |||
| out.delete(); | |||
| } | |||
| } | |||
| public void testEncoding() throws Exception { | |||
| File xsl = getFile("/taskdefs/optional/xsltliaison-encoding-in.xsl"); | |||
| liaison.setStylesheet(xsl); | |||
| File in = getFile("/taskdefs/optional/xsltliaison-encoding-in.xml"); | |||
| File out = new File("xsltliaison-encoding.tmp"); | |||
| try { | |||
| liaison.transform(in, out); | |||
| Document doc = parseXML(out); | |||
| assertEquals("root",doc.getDocumentElement().getNodeName()); | |||
| assertEquals("message",doc.getDocumentElement().getFirstChild().getNodeName()); | |||
| assertEquals("\u00E9\u00E0\u00E8\u00EF\u00F9",doc.getDocumentElement().getFirstChild().getFirstChild().getNodeValue()); | |||
| } finally { | |||
| out.delete(); | |||
| } | |||
| } | |||
| public Document parseXML(File file) throws Exception { | |||
| DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance(); | |||
| DocumentBuilder dbuilder = dbfactory.newDocumentBuilder(); | |||
| return dbuilder.parse(file); | |||
| } | |||
| } | |||
| @@ -0,0 +1,87 @@ | |||
| package org.apache.tools.ant.taskdefs.optional; | |||
| import org.apache.tools.ant.taskdefs.XSLTLiaison; | |||
| import java.io.File; | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 1999 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", "Jakarta-Regexp", 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/>. | |||
| * | |||
| */ | |||
| /** | |||
| * TraX XSLTLiaison testcase | |||
| * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a> | |||
| */ | |||
| public class TraXLiaisonTest extends AbstractXSLTLiaisonTest { | |||
| public TraXLiaisonTest(String name){ | |||
| super(name); | |||
| } | |||
| public XSLTLiaison createLiaison() throws Exception { | |||
| return new TraXLiaison(); | |||
| } | |||
| public void testXalan2Redirect() throws Exception { | |||
| File xsl = getFile("/taskdefs/optional/xalan-redirect-in.xsl"); | |||
| liaison.setStylesheet(xsl); | |||
| File out = new File("xalan2-redirect-out-dummy.tmp"); | |||
| File in = getFile("/taskdefs/optional/xsltliaison-in.xsl"); | |||
| try { | |||
| liaison.addParam("xalan-version", "2"); | |||
| liaison.transform(in, out); | |||
| } finally { | |||
| out.delete(); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,88 @@ | |||
| package org.apache.tools.ant.taskdefs.optional; | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 1999 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", "Jakarta-Regexp", 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/>. | |||
| * | |||
| */ | |||
| import org.apache.tools.ant.taskdefs.XSLTLiaison; | |||
| import java.io.File; | |||
| /** | |||
| * Xalan Liaison testcase | |||
| * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a> | |||
| */ | |||
| public class XalanLiaisonTest extends AbstractXSLTLiaisonTest { | |||
| public XalanLiaisonTest(String name){ | |||
| super(name); | |||
| } | |||
| protected XSLTLiaison createLiaison() throws Exception { | |||
| return new XalanLiaison(); | |||
| } | |||
| public void testXalan1Redirect() throws Exception { | |||
| File xsl = getFile("/taskdefs/optional/xalan-redirect-in.xsl"); | |||
| liaison.setStylesheet(xsl); | |||
| File out = new File("xalan1-redirect-out-dummy.tmp"); | |||
| File in = getFile("/taskdefs/optional/xsltliaison-in.xsl"); | |||
| try { | |||
| liaison.addParam("xalan-version", "1"); | |||
| liaison.transform(in, out); | |||
| } finally { | |||
| out.delete(); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,72 @@ | |||
| package org.apache.tools.ant.taskdefs.optional; | |||
| import org.apache.tools.ant.taskdefs.XSLTLiaison; | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 1999 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", "Jakarta-Regexp", 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/>. | |||
| * | |||
| */ | |||
| /** | |||
| * XSLP Liaison testcase | |||
| * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a> | |||
| */ | |||
| public class XslpLiaisonTest extends AbstractXSLTLiaisonTest { | |||
| public XslpLiaisonTest(String name){ | |||
| super(name); | |||
| } | |||
| protected XSLTLiaison createLiaison() throws Exception { | |||
| return new XslpLiaison(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,144 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| * modification, are permitted provided that the following conditions | |||
| * are met: | |||
| * | |||
| * 1. Redistributions of source code must retain the above copyright | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * | |||
| * 2. Redistributions in binary form must reproduce the above copyright | |||
| * notice, this list of conditions and the following disclaimer in | |||
| * the documentation and/or other materials provided with the | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * Apache Software Foundation (http://www.apache.org/)." | |||
| * Alternately, this acknowlegement may appear in the software itself, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", 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.tools.ant.types; | |||
| import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.taskdefs.TaskdefsTest; | |||
| import junit.framework.TestCase; | |||
| import junit.framework.AssertionFailedError; | |||
| import java.io.*; | |||
| /** | |||
| * FilterSet testing | |||
| * | |||
| * @author <a href="mailto:conor@apache.org">Conor MacNeill</a> | |||
| */ | |||
| public class FilterSetTest extends TaskdefsTest { | |||
| static private final int BUF_SIZE = 32768; | |||
| private Project project; | |||
| public FilterSetTest(String name) { | |||
| super(name); | |||
| } | |||
| public void setUp() { | |||
| configureProject("src/etc/testcases/types/filterset.xml"); | |||
| } | |||
| public void test1() { | |||
| executeTarget("test1"); | |||
| assertTrue("Filterset 1 failed", compareFiles("src/etc/testcases/types/gold/filterset1.txt", | |||
| "src/etc/testcases/types/dest1.txt")); | |||
| } | |||
| public void test2() { | |||
| executeTarget("test2"); | |||
| assertTrue("Filterset 2 failed", compareFiles("src/etc/testcases/types/gold/filterset2.txt", | |||
| "src/etc/testcases/types/dest2.txt")); | |||
| } | |||
| public void test3() { | |||
| executeTarget("test3"); | |||
| assertTrue("Filterset 3 failed", compareFiles("src/etc/testcases/types/gold/filterset3.txt", | |||
| "src/etc/testcases/types/dest3.txt")); | |||
| } | |||
| private boolean compareFiles(String name1, String name2) { | |||
| File file1 = new File(name1); | |||
| File file2 = new File(name2); | |||
| try { | |||
| if (!file1.exists() || !file2.exists()) { | |||
| System.out.println("One or both files do not exist:" + name1 + ", " + name2); | |||
| return false; | |||
| } | |||
| if (file1.length() != file2.length()) { | |||
| System.out.println("File size mismatch:" + name1 + "(" + file1.length() + "), " + | |||
| name2 + "(" + file2.length() + ")"); | |||
| return false; | |||
| } | |||
| // byte - byte compare | |||
| byte[] buffer1 = new byte[BUF_SIZE]; | |||
| byte[] buffer2 = new byte[BUF_SIZE]; | |||
| FileInputStream fis1 = new FileInputStream(file1); | |||
| FileInputStream fis2 = new FileInputStream(file2); | |||
| int index = 0; | |||
| int read = 0; | |||
| while ((read = fis1.read(buffer1)) != -1) { | |||
| fis2.read(buffer2); | |||
| for (int i = 0; i < read; ++i, ++index) { | |||
| if (buffer1[i] != buffer2[i]) { | |||
| System.out.println("Bytes mismatch:" + name1 + ", " + name2 + | |||
| " at byte " + index); | |||
| return false; | |||
| } | |||
| } | |||
| } | |||
| return true; | |||
| } | |||
| catch (IOException e) { | |||
| System.out.println("IOException comparing files: " + name1 + ", " + name2); | |||
| return false; | |||
| } | |||
| } | |||
| } | |||
| @@ -77,7 +77,8 @@ public class FileUtilsTest extends TestCase { | |||
| public void setUp() { | |||
| fu = FileUtils.newFileUtils(); | |||
| root = new File(File.separator).getAbsolutePath(); | |||
| // Windows adds the drive letter in uppercase, unless you run Cygnus | |||
| root = new File(File.separator).getAbsolutePath().toUpperCase(); | |||
| } | |||
| public void tearDown() { | |||