[Yanel-commits] rev 20821 - in public/yanel/trunk/src/resources: .
testing-control testing-control/src testing-control/src/build
testing-control/src/java testing-control/src/java/org
testing-control/src/java/org/wyona
testing-control/src/java/org/wyona/yanel
testing-control/src/java/org/wyona/yanel/impl
testing-control/src/java/org/wyona/yanel/impl/resources
testing-control/xslt
michi at wyona.com
michi at wyona.com
Wed Dec 13 17:33:14 CET 2006
Author: michi
Date: 2006-12-13 17:33:13 +0100 (Wed, 13 Dec 2006)
New Revision: 20821
Added:
public/yanel/trunk/src/resources/testing-control/
public/yanel/trunk/src/resources/testing-control/build.xml
public/yanel/trunk/src/resources/testing-control/resource.xml
public/yanel/trunk/src/resources/testing-control/src/
public/yanel/trunk/src/resources/testing-control/src/build/
public/yanel/trunk/src/resources/testing-control/src/build/build.properties
public/yanel/trunk/src/resources/testing-control/src/build/dependencies.xml
public/yanel/trunk/src/resources/testing-control/src/java/
public/yanel/trunk/src/resources/testing-control/src/java/org/
public/yanel/trunk/src/resources/testing-control/src/java/org/wyona/
public/yanel/trunk/src/resources/testing-control/src/java/org/wyona/yanel/
public/yanel/trunk/src/resources/testing-control/src/java/org/wyona/yanel/impl/
public/yanel/trunk/src/resources/testing-control/src/java/org/wyona/yanel/impl/resources/
public/yanel/trunk/src/resources/testing-control/src/java/org/wyona/yanel/impl/resources/ResultAggregator.java
public/yanel/trunk/src/resources/testing-control/src/java/org/wyona/yanel/impl/resources/TestingControlResource.java
public/yanel/trunk/src/resources/testing-control/test.config.xml
public/yanel/trunk/src/resources/testing-control/xslt/
public/yanel/trunk/src/resources/testing-control/xslt/copyOutput.xsl
public/yanel/trunk/src/resources/testing-control/xslt/result2html.xsl
public/yanel/trunk/src/resources/testing-control/xslt/unittests.xsl
Log:
testing resource added
Added: public/yanel/trunk/src/resources/testing-control/build.xml
===================================================================
--- public/yanel/trunk/src/resources/testing-control/build.xml 2006-12-13 16:09:00 UTC (rev 20820)
+++ public/yanel/trunk/src/resources/testing-control/build.xml 2006-12-13 16:33:13 UTC (rev 20821)
@@ -0,0 +1,76 @@
+<?xml version="1.0"?>
+
+<project name="yanel-resource" default="compile">
+
+ <import file="src/build/dependencies.xml"/>
+
+ <target name="init" description="Initialize build" depends="dependencies">
+ <echo>Initialize build</echo>
+
+ <dirname property="resource.home.dir" file="${ant.file}"/>
+ <echo>Resource Home Directory: ${resource.home.dir}</echo>
+
+ <property file="${resource.home.dir}/src/build/local.build.properties"/>
+ <property file="${resource.home.dir}/src/build/build.properties"/>
+
+ <path id="classpath">
+ <pathelement path="${maven2.cp}"/>
+ <pathelement path="${maven2.resource.cp}"/>
+ </path>
+ <property name="resource.build.dir" value="${resource.home.dir}/build"/>
+ <property name="resource.classes.dir" value="${resource.build.dir}/classes"/>
+ <property name="resource.lib.dir" value="${resource.build.dir}/lib"/>
+ <property name="resource.java.dir" value="${resource.home.dir}/src/java"/>
+ <property name="testframework.dir" value="${yanel.home.dir}/src/test"/>
+ <property name="junit.build.dir" value="${yanel.home.dir}/build/test/junit"/>
+ <property name="htmlunit.build.dir" value="${yanel.home.dir}/build/test/htmlunit"/>
+ <property name="test.results.dir" value="${yanel.home.dir}/src/test/test-result"/>
+
+ </target>
+
+
+
+ <target name="compile" description="Compile Java classes" depends="init">
+
+ <mkdir dir="${resource.classes.dir}"/>
+ <javac srcdir="${resource.java.dir}" destdir="${resource.classes.dir}"
+ classpathref="classpath"
+ debug="true"
+ />
+ <mkdir dir="${resource.lib.dir}"/>
+ <jar destfile="${resource.lib.dir}/yanel-resource-${resource.name}-${resource.version}.jar"
+ basedir="${resource.classes.dir}"
+ />
+ </target>
+
+ <target name="build-testframework-test" description="builds tests" depends="init">
+ <ant dir="${testframework.dir}" target="build" inheritall="false"/>
+ </target>
+
+ <target name="test2webapp" depends="build-testframework-test">
+ <copy todir="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes">
+ <fileset dir="${junit.build.dir}"/>
+ </copy>
+ <copy todir="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes">
+ <fileset dir="${htmlunit.build.dir}"/>
+ </copy>
+ <copy file="test.config.xml" todir="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes"/>
+ <replace file="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes/test.config.xml" value="${yanel.home.dir}">
+ <replacetoken>@YANELHOMEDIR@</replacetoken>
+ </replace>
+ </target>
+
+ <target name="clean" depends="init">
+ <delete dir="${resource.build.dir}"/>
+ </target>
+
+ <target name="copy-dependencies" depends="test2webapp">
+ <echo>${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/lib</echo>
+ <copy todir="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/lib">
+ <fileset refid="maven2.resource.fileset"/>
+ <mapper type="flatten"/>
+ </copy>
+ <!-- <antcall target="build-testframework-test"/>
+ <antcall target="test2webapp"/> -->
+ </target>
+</project>
Added: public/yanel/trunk/src/resources/testing-control/resource.xml
===================================================================
--- public/yanel/trunk/src/resources/testing-control/resource.xml 2006-12-13 16:09:00 UTC (rev 20820)
+++ public/yanel/trunk/src/resources/testing-control/resource.xml 2006-12-13 16:33:13 UTC (rev 20821)
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+
+<resource xmlns="http://www.wyona.org/yanel/1.0"
+ name="testing-control"
+ namespace="http://www.wyona.org/yanel/resource/1.0"
+ class="org.wyona.yanel.impl.resources.TestingControlResource"
+ >
+<description>
+Webinterface for controling the testframework
+</description>
+
+<!--
+<rtd>
+ <property name="xslt"/>
+ <property name="mime-type"/>
+ <property name="feed-title"/>
+ <property name="entries-path"/>
+</rtd>
+-->
+</resource>
Added: public/yanel/trunk/src/resources/testing-control/src/build/build.properties
===================================================================
--- public/yanel/trunk/src/resources/testing-control/src/build/build.properties 2006-12-13 16:09:00 UTC (rev 20820)
+++ public/yanel/trunk/src/resources/testing-control/src/build/build.properties 2006-12-13 16:33:13 UTC (rev 20821)
@@ -0,0 +1,4 @@
+resource.name=testing-control
+resource.version=0.0.1-dev-rXXX
+yanel.home.dir=/home/michi/src/wyona/public/yanel/trunk
+#yanel.home.dir=/home/simon/src/yanel
Added: public/yanel/trunk/src/resources/testing-control/src/build/dependencies.xml
===================================================================
--- public/yanel/trunk/src/resources/testing-control/src/build/dependencies.xml 2006-12-13 16:09:00 UTC (rev 20820)
+++ public/yanel/trunk/src/resources/testing-control/src/build/dependencies.xml 2006-12-13 16:33:13 UTC (rev 20821)
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+
+<project name="test-dependencies" xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <target name="dependencies" description="Dependencies">
+ <!-- INFO: http://maven.apache.org/ant-tasks.html -->
+ <artifact:remoteRepository id="wyona.remote.repository" url="http://www.wyona.org/maven2/"/>
+
+ <artifact:dependencies pathId="maven2.classpath" filesetId="maven2.fileset">
+ <remoteRepository refid="wyona.remote.repository"/>
+ <dependency groupId="javax.servlet" artifactId="servlet-api" version="2.3"
+ scope="provided"/>
+ <dependency groupId="log4j" artifactId="log4j" version="1.2.8"/>
+ <dependency groupId="wyona-org-yanel" artifactId="yanel-core"
+ version="${yanel.source.version}"/>
+ <dependency groupId="yarep" artifactId="yarep" version="0.0.1-dev-r17381"/>
+ <dependency groupId="wyona-org-commons" artifactId="wyona-org-commons"
+ version="0.0.1-dev-r17376"/>
+ </artifact:dependencies>
+
+ <artifact:dependencies pathId="maven2.resource.classpath" filesetId="maven2.resource.fileset">
+ <remoteRepository refid="wyona.remote.repository"/>
+ <dependency groupId="apache-jakarta-commons" artifactId="apache-jakarta-commons-codec" version="1.3"/>
+ <dependency groupId="apache-jakarta-commons" artifactId="apache-jakarta-commons-collections" version="3.2"/>
+ <dependency groupId="apache-jakarta-commons" artifactId="apache-jakarta-commons-configuration" version="1.1"/>
+ <dependency groupId="apache-jakarta-commons" artifactId="apache-jakarta-commons-httpclient" version="3.0.1"/>
+ <dependency groupId="apache-jakarta-commons" artifactId="apache-jakarta-commons-io" version="1.2"/>
+ <dependency groupId="apache-jakarta-commons" artifactId="apache-jakarta-commons-lang" version="2.1"/>
+ <dependency groupId="apache-jakarta-commons" artifactId="apache-jakarta-commons-logging" version="1.0.4"/>
+ <dependency groupId="htmlunit" artifactId="htmlunit" version="1.10"/>
+ <dependency groupId="junit" artifactId="junit" version="3.8.1"/>
+ <dependency groupId="jaxen" artifactId="jaxen" version="1.1-beta-10"/>
+ <dependency groupId="rhino" artifactId="rhino" version="1.6R2"/>
+ <dependency groupId="nekohtml" artifactId="nekohtml" version="0.9.5"/>
+ <dependency groupId="avalon-framework" artifactId="avalon-framework-impl" version="4.1.5"/>
+ <dependency groupId="avalon-framework" artifactId="avalon-framework-api" version="4.1.5"/>
+ <dependency groupId="ant" artifactId="ant" version="1.6.5"/>
+ <dependency groupId="ant" artifactId="ant-launcher" version="1.6.5"/>
+ <dependency groupId="ant" artifactId="ant-junit" version="1.6.5"/>
+ </artifact:dependencies>
+
+ <property name="maven2.cp" refid="maven2.classpath"/>
+ <!--<echo>Maven2 classpath: ${maven2.cp}</echo>-->
+ <property name="maven2.resource.cp" refid="maven2.resource.classpath"/>
+ </target>
+
+</project>
Added: public/yanel/trunk/src/resources/testing-control/src/java/org/wyona/yanel/impl/resources/ResultAggregator.java
===================================================================
--- public/yanel/trunk/src/resources/testing-control/src/java/org/wyona/yanel/impl/resources/ResultAggregator.java 2006-12-13 16:09:00 UTC (rev 20820)
+++ public/yanel/trunk/src/resources/testing-control/src/java/org/wyona/yanel/impl/resources/ResultAggregator.java 2006-12-13 16:33:13 UTC (rev 20821)
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2006 Wyona
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.wyona.org/licenses/APACHE-LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.wyona.yanel.impl.resources;
+
+import org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class ResultAggregator extends XMLResultAggregator{
+
+ /**
+ * Aggregate all testsuites into a single document return it as a dom doucment
+ * @return an aggregation of all testsuites as dom document
+ */
+ public Document getDocument() {
+ Element rootElement = createDocument();
+ Document doc;
+ doc = rootElement.getOwnerDocument();
+
+ return doc;
+ }
+}
\ No newline at end of file
Added: public/yanel/trunk/src/resources/testing-control/src/java/org/wyona/yanel/impl/resources/TestingControlResource.java
===================================================================
--- public/yanel/trunk/src/resources/testing-control/src/java/org/wyona/yanel/impl/resources/TestingControlResource.java 2006-12-13 16:09:00 UTC (rev 20820)
+++ public/yanel/trunk/src/resources/testing-control/src/java/org/wyona/yanel/impl/resources/TestingControlResource.java 2006-12-13 16:33:13 UTC (rev 20821)
@@ -0,0 +1,569 @@
+/*
+ * Copyright 2006 Wyona
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.wyona.org/licenses/APACHE-LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.wyona.yanel.impl.resources;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileReader;
+import java.io.StringBufferInputStream;
+import java.io.StringReader;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.List;
+import java.util.Calendar;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.Servlet;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import org.w3c.dom.Document;
+import org.xml.sax.XMLReader;
+import org.xml.sax.InputSource;
+
+import org.apache.log4j.Category;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.types.PatternSet;
+import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.taskdefs.optional.junit.*;
+import org.apache.tools.ant.taskdefs.Copy;
+import org.apache.tools.ant.taskdefs.Tstamp;
+import org.apache.tools.ant.taskdefs.Delete;
+import org.apache.tools.ant.taskdefs.optional.junit.AggregateTransformer.Format;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
+
+import org.wyona.yanel.core.Path;
+import org.wyona.yanel.core.Resource;
+import org.wyona.yanel.core.ResourceTypeDefinition;
+import org.wyona.yanel.core.ResourceTypeRegistry;
+import org.wyona.yanel.core.api.attributes.ViewableV1;
+import org.wyona.yanel.core.attributes.viewable.View;
+import org.wyona.yanel.core.attributes.viewable.ViewDescriptor;
+import org.wyona.yanel.core.map.Realm;
+import org.wyona.yanel.core.util.ResourceAttributeHelper;
+import org.wyona.yarep.core.NoSuchNodeException;
+import org.wyona.yarep.core.Repository;
+import org.wyona.yarep.core.RepositoryFactory;
+import org.wyona.yarep.util.RepoPath;
+import org.wyona.yarep.util.YarepUtil;
+import org.wyona.yanel.impl.resources.ResultAggregator;
+
+/**
+ *
+ */
+public class TestingControlResource extends Resource implements ViewableV1 {
+
+ private static final String DEFAULT_CONFIGURATION_FILE = "test.config.xml";
+ private static Category log = Category.getInstance(TestingControlResource.class);
+ private String YanelHomeDir;
+
+ /**
+ *
+ */
+ public TestingControlResource() {
+ URL propertiesURL = TestingControlResource.class.getClassLoader()
+ .getResource(DEFAULT_CONFIGURATION_FILE);
+ if (propertiesURL == null) {
+ log.error("No such resource: " + DEFAULT_CONFIGURATION_FILE);
+ }
+ try {
+ DefaultConfigurationBuilder configbuilder = new DefaultConfigurationBuilder();
+ File configfile = new File(propertiesURL.getFile());
+ Configuration config = configbuilder.buildFromFile(configfile);
+ YanelHomeDir = config.getChild("yanel-home-dir").getValue();
+ } catch (Exception e) {
+ log.error(e);
+ }
+ }
+
+ /**
+ *
+ */
+ public ViewDescriptor[] getViewDescriptors() {
+ return null;
+ }
+
+ /**
+ *
+ */
+ public View getView(Path path, String viewId) {
+ View defaultView = new View();
+ defaultView.setMimeType("application/xml");
+ StringBuffer sb = new StringBuffer("<?xml version=\"1.0\"?>");
+ defaultView.setInputStream(new java.io.StringBufferInputStream(sb.toString()));
+ return defaultView;
+ }
+
+ /**
+ * @throws Exception
+ *
+ */
+ public View getView(HttpServletRequest request, String viewId) throws Exception {
+ Path path = new Path(request.getServletPath());
+ String submit = request.getParameter("submit");
+ String type = request.getParameter("type");
+ String archive = request.getParameter("archive");
+ String[] testnames = request.getParameterValues("testnames");
+ View defaultView = new View();
+ if (submit == null) {
+ return plainRequest(path, defaultView);
+ } else {
+ if (type.equals("test")) {
+ return executeTests(path, defaultView, testnames);
+ }
+ if (type.equals("show")) {
+ return showArchive(path, defaultView, archive);
+ }
+ }
+ return null;
+ }
+
+ private View plainRequest(Path path, View defaultView) throws Exception,
+ TransformerConfigurationException, TransformerFactoryConfigurationError,
+ NoSuchNodeException, TransformerException {
+ Repository contentRepo;
+ RepoPath rp = contentRepo(path);
+ contentRepo = rp.getRepo();
+
+ StringBuffer sb = new StringBuffer("<?xml version=\"1.0\"?>");
+ sb.append("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
+ sb.append("<head>");
+ sb.append("<title>Testing Control</title>");
+ sb.append("</head>");
+ sb.append("<body>");
+ sb.append("<div id=\"contenBody\">");
+ sb.append("<h1>Testing Control</h1>");
+ sb.append("<form>");
+ sb.append("<p>Following htmlunit tests are available:</p>");
+ sb.append("<p>Number of Test: " + getAllTestNames("htmlunit").length + "</p>");
+
+ for (int i = 0; i < this.getAllTestNames("htmlunit").length; i++) {
+ sb.append("<p>"
+ + this.getAllTestNames("htmlunit")[i].substring(this.getAllTestNames("htmlunit")[i].lastIndexOf("/") + 1));
+ sb.append("<input type=\"checkbox\" name=\"testnames\" value=\""
+ + this.getAllTestNames("htmlunit")[i] + "\"/></p>");
+ }
+
+ sb.append("<p>Following junit tests are available:</p>");
+ sb.append("<p>Number of Test: " + getAllTestNames("junit").length + "</p>");
+
+ for (int i = 0; i < this.getAllTestNames("junit").length; i++) {
+ sb.append("<p>"
+ + this.getAllTestNames("junit")[i].substring(this.getAllTestNames("junit")[i].lastIndexOf("/") + 1));
+ sb.append("<input type=\"checkbox\" name=\"testnames\" value=\""
+ + this.getAllTestNames("junit")[i] + "\"/></p>");
+ }
+
+ sb.append("<input type=\"hidden\" name=\"type\" value=\"test\"/>");
+ sb.append("<input type=\"submit\" name=\"submit\" value=\"Test\"/>");
+ sb.append("</form>");
+
+ sb.append("<form>");
+ sb.append("<br/>Archived Test-Results: <select name=\"archive\">");
+ File testResultArchiveDir = new File(YanelHomeDir + "/src/test/test-results-archive");
+ String[] archivedTests = testResultArchiveDir.list();
+ for (int i = 0; i < archivedTests.length; i++) {
+ if (archivedTests[i].matches("[\\d]{4,4}[-][\\d]{2,2}[-][\\d]{2,2}[-][\\d]{2,2}[-][\\d]{2,2}[-][\\d]{2,2}[-]tests\\.xml")) {
+ sb.append("<option value=\"" + archivedTests[i] + "\">" + archivedTests[i]
+ + "</option>");
+ }
+ }
+ sb.append("</select>");
+ sb.append("<input type=\"hidden\" name=\"type\" value=\"show\"/>");
+ sb.append("<input type=\"submit\" name=\"submit\" value=\"Show\"/>");
+ sb.append("</form>");
+
+ sb.append("</div>");
+ sb.append("</body>");
+ sb.append("</html>");
+
+ Transformer transformer = TransformerFactory.newInstance()
+ .newTransformer(getXSLTStreamSource(path, contentRepo));
+ transformer.setParameter("yanel.path.name", path.getName());
+ transformer.setParameter("yanel.path", path.toString());
+ transformer.setParameter("yanel.back2context", backToRoot(path, ""));
+ transformer.setParameter("yarep.back2realm",
+ backToRoot(new org.wyona.yanel.core.Path(rp.getPath().toString()), ""));
+ // TODO: Is this the best way to generate an InputStream from an
+ // OutputStream?
+ java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
+ transformer.transform(new StreamSource(new java.io.StringBufferInputStream(sb.toString())),
+ new StreamResult(baos));
+ defaultView.setMimeType("application/xhtml+xml");
+ defaultView.setInputStream(new java.io.ByteArrayInputStream(baos.toByteArray()));
+ return defaultView;
+ }
+
+ private View executeTests(Path path, View defaultView, String[] testnames) throws Exception,
+ TransformerConfigurationException, TransformerFactoryConfigurationError,
+ NoSuchNodeException, TransformerException {
+ Repository contentRepo;
+ RepoPath rp = contentRepo(path);
+ contentRepo = rp.getRepo();
+
+ // delete the resultdir before making new tests
+ emptyResultDir();
+
+ // executing the tests
+ this.executeTests(testnames, "htmlunit");
+ this.executeTests(testnames, "junit");
+
+ // geting the test results
+ DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document result = builder.newDocument();
+
+ File testResultDir = new File(YanelHomeDir + "/src/test/test-results");
+ File testResultArchiveDir = new File(YanelHomeDir + "/src/test/test-results-archive");
+
+ Project project = new Project();
+
+ try {
+ ResultAggregator junitreport = new ResultAggregator();
+ junitreport.setTaskName("JUnitReport");
+ junitreport.setProject(project);
+
+ FileSet fs_report = new FileSet();
+ fs_report.setDir(testResultDir);
+ fs_report.setProject(project);
+
+ PatternSet.NameEntry ne = fs_report.createInclude();
+ ne.setName("**/TEST-*.xml");
+ junitreport.addFileSet(fs_report);
+
+ junitreport.setTodir(testResultArchiveDir);
+ junitreport.setTofile(getTime() + "-tests.xml");
+
+ junitreport.init();
+ // archives an aggregation of test-results in test-result-archives
+ junitreport.execute();
+ //get the result to show for this request
+ result = junitreport.getDocument();
+ } catch (Exception e) {
+ log.error(e);
+ }
+
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ File result2htmlXsltFile = org.wyona.commons.io.FileUtil.file(rtd.getConfigFile()
+ .getParentFile()
+ .getAbsolutePath(), "xslt" + File.separator + "result2html.xsl");
+ Transformer transResult2html = TransformerFactory.newInstance()
+ .newTransformer(new StreamSource(result2htmlXsltFile));
+ transResult2html.transform(new DOMSource(result), new StreamResult(byteArrayOutputStream));
+
+ Transformer transformer = TransformerFactory.newInstance()
+ .newTransformer(getXSLTStreamSource(path, contentRepo));
+ transformer.setParameter("yanel.path.name", path.getName());
+ transformer.setParameter("yanel.path", path.toString());
+ transformer.setParameter("yanel.back2context", backToRoot(path, ""));
+ transformer.setParameter("yarep.back2realm",
+ backToRoot(new org.wyona.yanel.core.Path(rp.getPath().toString()), ""));
+ // TODO: Is this the best way to generate an InputStream from an
+ // OutputStream?
+ java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
+ transformer.transform(new StreamSource(new ByteArrayInputStream(byteArrayOutputStream.toByteArray())),
+ new StreamResult(baos));
+ defaultView.setMimeType("application/xhtml+xml");
+ defaultView.setInputStream(new java.io.ByteArrayInputStream(baos.toByteArray()));
+ return defaultView;
+ }
+
+ private View showArchive(Path path, View defaultView, String archive) throws Exception,
+ TransformerConfigurationException, TransformerFactoryConfigurationError,
+ NoSuchNodeException, TransformerException {
+ Repository contentRepo;
+ RepoPath rp = contentRepo(path);
+ contentRepo = rp.getRepo();
+
+ File ResultArchive = new File(YanelHomeDir + "/src/test/test-results-archive/"+archive);
+
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ File result2htmlXsltFile = org.wyona.commons.io.FileUtil.file(rtd.getConfigFile()
+ .getParentFile()
+ .getAbsolutePath(), "xslt" + File.separator + "result2html.xsl");
+ Transformer transResult2html = TransformerFactory.newInstance()
+ .newTransformer(new StreamSource(result2htmlXsltFile));
+
+ FileReader archfile = new FileReader(ResultArchive);
+ transResult2html.transform(new StreamSource(archfile), new StreamResult(byteArrayOutputStream));
+
+ Transformer transformer = TransformerFactory.newInstance()
+ .newTransformer(getXSLTStreamSource(path, contentRepo));
+ transformer.setParameter("yanel.path.name", path.getName());
+ transformer.setParameter("yanel.path", path.toString());
+ transformer.setParameter("yanel.back2context", backToRoot(path, ""));
+ transformer.setParameter("yarep.back2realm",
+ backToRoot(new org.wyona.yanel.core.Path(rp.getPath().toString()), ""));
+ // TODO: Is this the best way to generate an InputStream from an
+ // OutputStream?
+ java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
+ transformer.transform(new StreamSource(new ByteArrayInputStream(byteArrayOutputStream.toByteArray())),
+ new StreamResult(baos));
+ defaultView.setMimeType("application/xhtml+xml");
+ defaultView.setInputStream(new java.io.ByteArrayInputStream(baos.toByteArray()));
+ return defaultView;
+ }
+
+ private RepoPath contentRepo(Path path) throws Exception {
+ return new YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(path.toString()),
+ getRepositoryFactory());
+ }
+
+ private Transformer prepareTransformer(Path path) throws Exception,
+ TransformerConfigurationException, TransformerFactoryConfigurationError,
+ NoSuchNodeException {
+ Repository contentRepo;
+ RepoPath rp = contentRepo(path);
+ contentRepo = rp.getRepo();
+ Transformer transformer = TransformerFactory.newInstance()
+ .newTransformer(getXSLTStreamSource(path, contentRepo));
+ transformer.setParameter("yanel.path.name", path.getName());
+ transformer.setParameter("yanel.path", path.toString());
+ return transformer;
+ }
+
+ /**
+ *
+ */
+ private StreamSource getXSLTStreamSource(Path path, Repository repo) throws NoSuchNodeException {
+ Path xsltPath = getXSLTPath(path);
+ if (xsltPath != null) {
+ return new StreamSource(repo.getInputStream(new org.wyona.yarep.core.Path(getXSLTPath(path).toString())));
+ } else {
+ File xsltFile = org.wyona.commons.io.FileUtil.file(rtd.getConfigFile()
+ .getParentFile()
+ .getAbsolutePath(), "xslt" + File.separator + "copyOutput.xsl");
+ log.error("DEBUG: XSLT file: " + xsltFile);
+ return new StreamSource(xsltFile);
+ }
+ }
+
+ /**
+ *
+ */
+ private Path getXSLTPath(Path path) {
+ String xsltPath = null;
+ try {
+ // TODO: Get yanel RTI yarep properties file name from framework
+ // resp. use MapFactory ...!
+ RepoPath rpRTI = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(path.toString()),
+ getRTIRepositoryFactory());
+ java.io.BufferedReader br = new java.io.BufferedReader(rpRTI.getRepo()
+ .getReader(new org.wyona.yarep.core.Path(new Path(rpRTI.getPath().toString()).getRTIPath()
+ .toString())));
+
+ while ((xsltPath = br.readLine()) != null) {
+ if (xsltPath.indexOf("xslt:") == 0) {
+ xsltPath = xsltPath.substring(6);
+ log.debug("XSLT Path: " + xsltPath);
+ return new Path(xsltPath);
+ }
+ }
+ log.error("No XSLT Path within: " + rpRTI.getPath());
+ } catch (Exception e) {
+ log.warn(e);
+ }
+
+ return null;
+ }
+
+ /**
+ *
+ * @return
+ */
+ protected RepositoryFactory getRepositoryFactory() {
+ return yanel.getRepositoryFactory("DefaultRepositoryFactory");
+ }
+
+ /**
+ *
+ * @return
+ */
+ protected RepositoryFactory getRTIRepositoryFactory() {
+ return yanel.getRepositoryFactory("RTIRepositoryFactory");
+ }
+
+ /**
+ *
+ */
+ private String backToRoot(Path path, String backToRoot) {
+ org.wyona.commons.io.Path parent = path.getParent();
+ if (parent != null && !isRoot(parent)) {
+ return backToRoot(new Path(parent.toString()), backToRoot + "../");
+ }
+ return backToRoot;
+ }
+
+ /**
+ *
+ */
+ private boolean isRoot(org.wyona.commons.io.Path path) {
+ if (path.toString().equals(File.separator))
+ return true;
+ return false;
+ }
+
+ /**
+ * get Tests.
+ * @param htmlOrJunit type of tests should be selected. can be htmlunit or junit.
+ * @return an array with the aviable tests.
+ */
+ private String[] getAllTestNames(String htmlOrJunit) {
+
+ File basedir = new File(YanelHomeDir + "/build/test/" + htmlOrJunit);
+ File resultdir = new File(YanelHomeDir + "/src/test/test-result");
+
+ Project project = new Project();
+
+ try {
+ JUnitTask junit = new JUnitTask();
+
+ BatchTest batchTest = junit.createBatchTest();
+
+ org.apache.tools.ant.types.FileSet fileset = new org.apache.tools.ant.types.FileSet();
+
+ fileset.setProject(project);
+ fileset.setDir(basedir);
+ fileset.setIncludes("**/*Test.class");
+ fileset.setExcludes("**/Abstract*.class");
+
+ batchTest.setTodir(resultdir);
+ batchTest.addFileSet(fileset);
+
+ DirectoryScanner directoryscanner = fileset.getDirectoryScanner(project);
+
+ String[] files = directoryscanner.getIncludedFiles();
+
+ return files;
+ } catch (Exception e) {
+ log.error(e);
+ }
+ return null;
+ }
+
+ /**
+ * Executes Tests.
+ * @param testnames which should be executed.
+ * @param htmlOrJunit type of tests which should be executed. can be htmlunit or junit.
+ */
+ private void executeTests(String[] testnames, String htmlOrJunit) throws Exception {
+
+ File basedir = new File(YanelHomeDir + "/build/test/" + htmlOrJunit);
+ File resultdir = new File(YanelHomeDir + "/src/test/test-results");
+
+ Project project = new Project();
+ project.init();
+
+ try {
+ JUnitTask junit = new JUnitTask();
+ junit.setProject(project);
+
+ FileSet fileset = new FileSet();
+ fileset.setProject(project);
+ fileset.setDir(basedir);
+
+ String includes = "";
+ for (int i = 0; i < testnames.length; i++) {
+ includes = includes + testnames[i] + ",";
+ }
+ fileset.setIncludes(includes);
+
+ BatchTest batchTest = junit.createBatchTest();
+ batchTest.setTodir(resultdir);
+ batchTest.addFileSet(fileset);
+
+ DirectoryScanner directoryscanner = fileset.getDirectoryScanner(project);
+ String[] files = directoryscanner.getIncludedFiles();
+
+ FormatterElement formatter = new FormatterElement();
+ formatter.setUseFile(true);
+ FormatterElement.TypeAttribute typeattribute = new FormatterElement.TypeAttribute();
+ typeattribute.setValue("xml");
+ formatter.setType(typeattribute);
+
+ junit.addFormatter(formatter);
+ junit.setFork(false);
+
+ JUnitTask.SummaryAttribute summaryattr = new JUnitTask.SummaryAttribute();
+ summaryattr.setValue("true");
+ junit.setPrintsummary(summaryattr);
+
+ org.apache.tools.ant.types.Commandline.Argument cmdline = junit.createJvmarg();
+ cmdline.setValue("-Djunit.base.dir=" + YanelHomeDir + "/build/test/" + htmlOrJunit);
+
+ junit.setHaltonerror(false);
+ junit.setHaltonfailure(false);
+
+ junit.init();
+ junit.execute();
+
+ } catch (Exception e) {
+ log.error(e);
+ }
+ }
+
+ /**
+ * remove old test from the result-dir
+ */
+ private void emptyResultDir() {
+ File testResultDir = new File(YanelHomeDir + "/src/test/test-results");
+
+ Project project = new Project();
+ project.init();
+
+ try {
+ FileSet fileset = new FileSet();
+ fileset.setProject(project);
+ fileset.setDir(testResultDir);
+
+ final Delete task = (Delete) project.createTask("delete");
+ task.setTaskName("delete old tests");
+ task.addFileset(fileset);
+ task.init();
+ task.execute();
+
+ } catch (Exception e) {
+ log.error(e);
+ }
+ }
+
+ /**
+ * get time as string
+ * @return timestamp (yyyy-MM-dd-HH-mm-ss)
+ */
+ private String getTime() {
+ Calendar cal = Calendar.getInstance(java.util.TimeZone.getDefault());
+ String DATE_FORMAT = "yyyy-MM-dd-HH-mm-ss";
+ java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT);
+ sdf.setTimeZone(java.util.TimeZone.getDefault());
+ String time = sdf.format(cal.getTime());
+ return time;
+ }
+}
Added: public/yanel/trunk/src/resources/testing-control/test.config.xml
===================================================================
--- public/yanel/trunk/src/resources/testing-control/test.config.xml 2006-12-13 16:09:00 UTC (rev 20820)
+++ public/yanel/trunk/src/resources/testing-control/test.config.xml 2006-12-13 16:33:13 UTC (rev 20821)
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<config>
+ <yanel-home-dir>@YANELHOMEDIR@</yanel-home-dir>
+</config>
\ No newline at end of file
Added: public/yanel/trunk/src/resources/testing-control/xslt/copyOutput.xsl
===================================================================
--- public/yanel/trunk/src/resources/testing-control/xslt/copyOutput.xsl 2006-12-13 16:09:00 UTC (rev 20820)
+++ public/yanel/trunk/src/resources/testing-control/xslt/copyOutput.xsl 2006-12-13 16:33:13 UTC (rev 20821)
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:xhtml="http://www.w3.org/1999/xhtml"
+ xmlns:dir="http://apache.org/cocoon/directory/2.0"
+ xmlns:yanel="http://www.wyona.org/yanel/resource/directory/1.0"
+>
+
+<xsl:output method="xhtml"/>
+<!-- NOTE: Must correspond with the mime-type delivered by the server. See src/java/org/wyona/yanel/impl/resources/DirectoryResource.java -->
+<!--
+<xsl:output method="html"/>
+-->
+
+<xsl:template match="/">
+
+ <xsl:apply-templates/>
+
+</xsl:template>
+
+
+
+ <xsl:template match="@*|node()" priority="-2">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+
+</xsl:stylesheet>
Added: public/yanel/trunk/src/resources/testing-control/xslt/result2html.xsl
===================================================================
--- public/yanel/trunk/src/resources/testing-control/xslt/result2html.xsl 2006-12-13 16:09:00 UTC (rev 20820)
+++ public/yanel/trunk/src/resources/testing-control/xslt/result2html.xsl 2006-12-13 16:33:13 UTC (rev 20821)
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+ <xsl:output method="html"/>
+
+ <xsl:variable name="testsuite.list" select="//testsuite"/>
+
+ <xsl:template match="/">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>Testing Results</title>
+ </head>
+ <body>
+ <div id="contenBody">
+ <xsl:apply-templates/>
+ </div>
+ </body>
+ </html>
+ </xsl:template>
+
+ <xsl:template match="testsuite">
+ <p>
+ Name: <xsl:value-of select="@name"/>
+ Errors: <xsl:value-of select="@errors"/>
+ Failures: <xsl:value-of select="@failures"/>
+ Packagesname: <xsl:value-of select="@package"/>
+ Execution Time: <xsl:value-of select="@time"/>
+ <xsl:apply-templates/>
+ </p>
+ </xsl:template>
+
+ <xsl:template match="system-out">
+ <p>System-out:
+ <xsl:value-of select="."/>
+ </p>
+ </xsl:template>
+
+ <xsl:template match="system-err">
+ <p>System-error:
+ <xsl:value-of select="."/>
+ </p>
+ </xsl:template>
+
+</xsl:stylesheet>
+
Added: public/yanel/trunk/src/resources/testing-control/xslt/unittests.xsl
===================================================================
--- public/yanel/trunk/src/resources/testing-control/xslt/unittests.xsl 2006-12-13 16:09:00 UTC (rev 20820)
+++ public/yanel/trunk/src/resources/testing-control/xslt/unittests.xsl 2006-12-13 16:33:13 UTC (rev 20821)
@@ -0,0 +1,292 @@
+<?xml version="1.0"?>
+<!--********************************************************************************
+ * CruiseControl, a Continuous Integration Toolkit
+ * Copyright (c) 2001, ThoughtWorks, Inc.
+ * 651 W Washington Ave. Suite 600
+ * Chicago, IL 60661 USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * + Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * + 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.
+ *
+ * + Neither the name of ThoughtWorks, Inc., CruiseControl, nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS 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 REGENTS OR
+ * 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.
+ ********************************************************************************-->
+<xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+ xmlns:lxslt="http://xml.apache.org/xslt">
+
+ <xsl:output method="html"/>
+
+ <xsl:variable name="testsuite.list" select="//testsuite"/>
+ <xsl:variable name="testsuite.error.count" select="count($testsuite.list/error)"/>
+ <xsl:variable name="testcase.list" select="$testsuite.list/testcase"/>
+ <xsl:variable name="testcase.error.list" select="$testcase.list/error"/>
+ <xsl:variable name="testcase.failure.list" select="$testcase.list/failure"/>
+ <xsl:variable name="totalErrorsAndFailures" select="count($testcase.error.list) + count($testcase.failure.list) + $testsuite.error.count"/>
+
+ <xsl:template match="/" mode="unittests">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>Example Resource</title>
+ </head>
+ <body>
+ <div id="contenBody">
+ <table align="center" cellpadding="2" cellspacing="0" border="0" width="98%">
+
+ <!-- Unit Tests -->
+ <tr>
+ <td class="unittests-sectionheader" colspan="4">
+  Unit Tests: (<xsl:value-of select="count($testcase.list)"/>)
+ </td>
+ </tr>
+
+ <xsl:choose>
+ <xsl:when test="count($testsuite.list) = 0">
+ <tr>
+ <td colspan="2" class="unittests-data">
+ No Tests Run
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" class="unittests-error">
+ This project doesn't have any tests
+ </td>
+ </tr>
+ </xsl:when>
+
+ <xsl:when test="$totalErrorsAndFailures = 0">
+ <tr>
+ <td colspan="2" class="unittests-data">
+ All Tests Passed
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <tr>
+ <td>
+ <table align="center" cellpadding="2" cellspacing="0" border="0" width="98%">
+ <xsl:apply-templates select="$testcase.error.list" mode="unittests"/>
+ <xsl:apply-templates select="$testcase.failure.list" mode="unittests"/>
+ </table>
+ </td>
+ </tr>
+ <tr/>
+ <tr><td colspan="2"> </td></tr>
+
+ <!-- <xsl:if test="$totalErrorsAndFailures > 0"> -->
+
+ <tr>
+ <td class="unittests-sectionheader" colspan="4">
+  Unit Test Error Details: (<xsl:value-of select="$totalErrorsAndFailures"/>)
+ </td>
+ </tr>
+
+ <!-- (PENDING) Why doesn't this work if set up as variables up top? -->
+ <xsl:call-template name="testdetail">
+ <xsl:with-param name="detailnodes" select="//testsuite/testcase[.//error]"/>
+ </xsl:call-template>
+
+ <xsl:call-template name="testdetail">
+ <xsl:with-param name="detailnodes" select="//testsuite/testcase[.//failure]"/>
+ </xsl:call-template>
+ <!-- </xsl:if> -->
+ </table>
+ </div>
+ </body>
+ </html>
+ </xsl:template>
+
+ <!-- UnitTest Errors -->
+ <xsl:template match="error" mode="unittests">
+ <tr>
+ <xsl:if test="position() mod 2 = 0">
+ <xsl:attribute name="class">unittests-oddrow</xsl:attribute>
+ </xsl:if>
+
+ <td class="unittests-data" width="50">
+ error
+ </td>
+ <td class="unittests-data" width="300">
+ <xsl:value-of select="../@name"/>
+ </td>
+ <td class="unittests-data" width="400">
+ <xsl:value-of select="..//..//@name"/>
+ </td>
+ </tr>
+ </xsl:template>
+
+ <!-- UnitTest Failures -->
+ <xsl:template match="failure" mode="unittests">
+ <tr>
+ <xsl:if test="($testsuite.error.count + position()) mod 2 = 0">
+ <xsl:attribute name="class">unittests-oddrow</xsl:attribute>
+ </xsl:if>
+
+ <td class="unittests-data" width="50">
+ failure
+ </td>
+ <td class="unittests-data" width="300">
+ <xsl:value-of select="../@name"/>
+ </td>
+ <td class="unittests-data" width="400">
+ <xsl:value-of select="..//..//@name"/>
+ </td>
+ </tr>
+ </xsl:template>
+
+ <!-- UnitTest Errors And Failures Detail Template -->
+ <xsl:template name="testdetail">
+ <xsl:param name="detailnodes"/>
+
+ <xsl:for-each select="$detailnodes">
+ <tr>
+ <td colspan="2">
+ <table width="100%" border="0" cellspacing="0">
+
+ <tr class="unittests-title">
+ <td width="50">Test: </td>
+ <td>
+ <xsl:value-of select="@name"/>
+ </td>
+ </tr>
+ <tr class="unittests-data">
+ <td>Class: </td>
+ <td>
+ <xsl:value-of select="..//@name"/>
+ </td>
+ </tr>
+
+ <xsl:if test="error">
+ <xsl:call-template name="test-data">
+ <xsl:with-param name="word" select="error"/>
+ <xsl:with-param name="type" select="'error'"/>
+ </xsl:call-template>
+ </xsl:if>
+
+ <xsl:if test="failure">
+ <xsl:call-template name="test-data">
+ <xsl:with-param name="word" select="failure"/>
+ <xsl:with-param name="type" select="'failure'"/>
+ </xsl:call-template>
+ </xsl:if>
+
+ </table>
+ </td>
+ </tr>
+
+ </xsl:for-each>
+ </xsl:template>
+
+ <xsl:template name="test-data">
+ <xsl:param name="word"/>
+ <xsl:param name="type"/>
+ <tr>
+ <td/>
+ <td>
+ <xsl:call-template name="stack-trace">
+ <xsl:with-param name="word" select="$word"/>
+ <xsl:with-param name="type" select="$type"/>
+ </xsl:call-template>
+ </td>
+ </tr>
+ </xsl:template>
+
+ <xsl:template name="stack-trace">
+ <xsl:param name="word"/>
+ <xsl:param name="type"/>
+ <table width="100%" border="1" cellspacing="0" cellpadding="2">
+ <tr>
+ <td>
+ <table width="100%" border="0" cellspacing="0" cellpadding="0">
+ <xsl:call-template name="br-replace">
+ <xsl:with-param name="word" select="$word"/>
+ <xsl:with-param name="type" select="$type"/>
+ <xsl:with-param name="count" select="0"/>
+ </xsl:call-template>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </xsl:template>
+
+ <xsl:template name="br-replace">
+ <xsl:param name="word"/>
+ <xsl:param name="type"/>
+ <xsl:param name="count"/>
+<!-- </xsl:text> on next line on purpose to get newline -->
+<xsl:variable name="stackstart"><xsl:text> at</xsl:text></xsl:variable>
+<xsl:variable name="cr"><xsl:text>
+</xsl:text></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="contains($word,$cr)">
+ <tr>
+ <xsl:attribute name="class">unittests-<xsl:value-of select="$type"/></xsl:attribute>
+ <xsl:if test="$count mod 2 != 0">
+ <xsl:attribute name="bgcolor">#EEEEEE</xsl:attribute>
+ </xsl:if>
+ <xsl:if test="$count != 0 and starts-with($word,$stackstart)">
+ <td width="30"/>
+ <td>
+ <xsl:value-of select="substring-before($word,$cr)"/> 
+ </td>
+ </xsl:if>
+ <xsl:if test="$count != 0 and not(starts-with($word,$stackstart))">
+ <td colspan="2">
+ <xsl:value-of select="substring-before($word,$cr)"/> 
+ </td>
+ </xsl:if>
+ <xsl:if test="$count = 0">
+ <td colspan="2">
+ <xsl:value-of select="substring-before($word,$cr)"/> 
+ </td>
+ </xsl:if>
+ </tr>
+ <xsl:call-template name="br-replace">
+ <xsl:with-param name="word" select="substring-after($word,$cr)"/>
+ <xsl:with-param name="type" select="$type"/>
+ <xsl:with-param name="count" select="$count + 1"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <tr>
+ <xsl:attribute name="class">unittests-<xsl:value-of select="$type"/></xsl:attribute>
+ <xsl:if test="$count mod 2 != 0">
+ <xsl:attribute name="bgcolor">#EEEEEE</xsl:attribute>
+ </xsl:if>
+ <td width="30"/>
+ <td>
+ <xsl:value-of select="$word"/>
+ </td>
+ </tr>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="/">
+ <xsl:apply-templates select="." mode="unittests"/>
+ </xsl:template>
+</xsl:stylesheet>
More information about the Yanel-commits
mailing list