maven-plugins/latka/plugin.jelly
2003-02-15 14:47:39 +00:00

101 lines
3.5 KiB
XML

<?xml version="1.0"?>
<project xmlns:j="jelly:core"
xmlns:u="jelly:util"
xmlns:x="jelly:xml">
<goal name="latka" description="Run the project's latka tests">
<attainGoal name="latka:test" />
</goal>
<!-- run all Latka tests in the project -->
<goal name="latka:test" description="Run the project's latka tests">
<j:set var="latkaSrcDir" value="${maven.latka.src.dir}"/>
<u:available file="${latkaSrcDir}">
<j:set var="latkaSrcDirExists" value="true" />
</u:available>
<j:if test="${latkaSrcDirExists}">
<fileScanner var="latkaFiles">
<fileset dir="${latkaSrcDir}">
<patternset>
<include name="**/*.latka"/>
</patternset>
</fileset>
</fileScanner>
<echo>executing latka tests from: ${latkaSrcDir}</echo>
<!-- Major hack - set jaxp properties as they are foobared -->
${systemScope.setProperty('javax.xml.transform.TransformerFactory','org.apache.xalan.processor.TransformerFactoryImpl')}
<j:forEach var="file" items="${latkaFiles.iterator()}">
<echo>Executing ${file}</echo>
<j:import file="${file.canonicalPath}" inherit="true"/>
</j:forEach>
</j:if>
<j:if test="${!latkaSrcDirExists}"><echo>No Latka source directory found</echo></j:if>
</goal>
<goal name="latka:single"
description="Execute a single test defined using the 'testcase' variable">
<j:choose>
<j:when test="${empty(testcase)}">
<echo>
You must define the test case to run via -Dtestcase=classname
Example: maven -Dtestcase=MyTest latka:single
</echo>
</j:when>
<j:otherwise>
<j:set var="latkaSrcDir" value="${maven.latka.src.dir}"/>
<u:available file="${latkaSrcDir}/${testcase}">
<j:set var="testExists" value="true" />
</u:available>
<j:if test="${testExists}">
<echo>Running test ${latkaSrcDir}/${testcase}</echo>
<!-- Major hack - set jaxp properties as they are foobared -->
${systemScope.setProperty('javax.xml.transform.TransformerFactory','org.apache.xalan.processor.TransformerFactoryImpl')}
<u:file var="singleTestCase" name="${latkaSrcDir}/${testcase}"/>
<j:import file="${latkaSrcDir}/${testcase}" inherit="true"/>
</j:if>
</j:otherwise>
</j:choose>
</goal>
<!-- convert a jmeter set of requests to a latka suite -->
<goal name="latka:jmeter-convert"
description="Convert a jmeter jmx file to a latka suite">
<u:available file="${jmeterFile}">
<j:set var="outFileName">${maven.build.dir}/latka/jmeter-suite.latka</j:set>
<echo>Converting ${jmeterFile} to a latka test suite</echo>
<!-- Major hack - set jaxp properties as they are foobared -->
${systemScope.setProperty('javax.xml.transform.TransformerFactory','org.apache.xalan.processor.TransformerFactoryImpl')}
<u:file var="jmeterAsFile" name="${jmeterFile}" />
<x:parse xml="${jmeterAsFile}" var="jmeter"/>
<mkdir dir="${maven.build.dir}/latka" />
<j:file name="${outFileName}" prettyPrint="true">
<x:element name="j:jelly">
<x:attribute name="xmlns:j">jelly:core</x:attribute>
<x:attribute name="xmlns">jelly:org.apache.commons.latka.jelly.LatkaTagLibrary</x:attribute>
<j:import file="${plugin.resources}/jmeter2suite.jelly" inherit="true"/>
</x:element>
</j:file>
<echo>Latka test suite '${outFileName}' created</echo>
</u:available>
</goal>
</project>