You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by st...@apache.org on 2003/04/19 18:10:33 UTC
cvs commit: cocoon-2.1/src/test/org/apache/cocoon/transformation TraxTransformerTestCase.java TraxTransformerTestCase.xtest traxtest-input.xml traxtest-result.xml traxtest-style.xsl AbstractTransformerTestCase.java
stephan 2003/04/19 09:10:33
Modified: src/test/org/apache/cocoon/transformation
AbstractTransformerTestCase.java
Added: src/test/org/apache/cocoon/transformation
TraxTransformerTestCase.java
TraxTransformerTestCase.xtest traxtest-input.xml
traxtest-result.xml traxtest-style.xsl
Log:
Add testcase for the traxtransformer especially to find a hidden memory
leak. But everything runs fine.
Revision Changes Path
1.5 +4 -4 cocoon-2.1/src/test/org/apache/cocoon/transformation/AbstractTransformerTestCase.java
Index: AbstractTransformerTestCase.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/test/org/apache/cocoon/transformation/AbstractTransformerTestCase.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AbstractTransformerTestCase.java 16 Apr 2003 13:47:59 -0000 1.4
+++ AbstractTransformerTestCase.java 19 Apr 2003 16:10:32 -0000 1.5
@@ -139,11 +139,11 @@
transformer = (Transformer) selector.select(type);
assertNotNull("Test lookup of transformer", transformer);
- DOMBuilder builder = new DOMBuilder();
- transformer.setConsumer(new WhitespaceFilter(builder));
-
transformer.setup(new SourceResolverAdapter(resolver, this.manager),
objectmodel, source, parameters);
+
+ DOMBuilder builder = new DOMBuilder();
+ transformer.setConsumer(new WhitespaceFilter(builder));
assertNotNull("Test if input document is not null", input);
DOMStreamer streamer = new DOMStreamer(transformer);
1.1 cocoon-2.1/src/test/org/apache/cocoon/transformation/TraxTransformerTestCase.java
Index: TraxTransformerTestCase.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" 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 name, without prior written permission of the
Apache Software Foundation.
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 (INCLU-
DING, 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 and was originally created by
Stefano Mazzocchi <st...@apache.org>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.transformation;
import java.util.HashMap;
import org.apache.avalon.framework.parameters.Parameters;
import org.w3c.dom.Document;
/**
*
*
* @author <a href="mailto:stephan@apache.org">Stephan Michels </a>
* @version CVS $Id: TraxTransformerTestCase.java,v 1.1 2003/04/19 16:10:32 stephan Exp $
*/
public class TraxTransformerTestCase extends AbstractTransformerTestCase {
public TraxTransformerTestCase(String name) {
super(name);
}
public void testFunctionForXalan() {
String src = "resource://org/apache/cocoon/transformation/traxtest-style.xsl";
Parameters parameters = new Parameters();
String input = "resource://org/apache/cocoon/transformation/traxtest-input.xml";
String result = "resource://org/apache/cocoon/transformation/traxtest-result.xml";
assertEqual(load(result), transform("xalan", src, parameters, load(input)));
}
public void testStressForXalan() {
String src = "resource://org/apache/cocoon/transformation/traxtest-style.xsl";
Parameters parameters = new Parameters();
String input = "resource://org/apache/cocoon/transformation/traxtest-input.xml";
Document document = load(input);
for(int i=0; i<100; i++)
transform("xalan", src, parameters, document);
}
public void testFunctionForXSLTC() {
String src = "resource://org/apache/cocoon/transformation/traxtest-style.xsl";
Parameters parameters = new Parameters();
String input = "resource://org/apache/cocoon/transformation/traxtest-input.xml";
String result = "resource://org/apache/cocoon/transformation/traxtest-result.xml";
assertEqual(load(result), transform("xsltc", src, parameters, load(input)));
}
public void testStressForXSLTC() {
String src = "resource://org/apache/cocoon/transformation/traxtest-style.xsl";
Parameters parameters = new Parameters();
String input = "resource://org/apache/cocoon/transformation/traxtest-input.xml";
Document document = load(input);
for(int i=0; i<100; i++)
transform("xsltc", src, parameters, document);
}
}
1.1 cocoon-2.1/src/test/org/apache/cocoon/transformation/TraxTransformerTestCase.xtest
Index: TraxTransformerTestCase.xtest
===================================================================
<?xml version="1.0" ?>
<testcase>
<annotation>
Test Cases: TraxTransformer
</annotation>
<logkit>
<factories>
<factory type="stream" class="org.apache.avalon.excalibur.logger.factory.StreamTargetFactory"/>
</factories>
<targets>
<stream id="root">
<stream>System.out</stream>
<format type="extended">
%7.7{priority} %5.5{time} [%9.9{category}] (%{context}): %{message}\n%{throwable}
</format>
</stream>
</targets>
<categories>
<category name="test" log-level="WARN">
<log-target id-ref="root"/>
</category>
</categories>
</logkit>
<context/>
<roles>
<role name="org.apache.excalibur.xml.sax.SAXParser"
shorthand="xml-parser"
default-class="org.apache.excalibur.xml.impl.JaxpParser"/>
<role name="org.apache.excalibur.xmlizer.XMLizer"
shorthand="xmlizer"
default-class="org.apache.excalibur.xmlizer.DefaultXMLizer"/>
<role name="org.apache.excalibur.xml.xslt.XSLTProcessor"
shorthand="xslt-processor"
default-class="org.apache.excalibur.xml.xslt.XSLTProcessorImpl"/>
<role name="org.apache.excalibur.source.SourceFactorySelector"
shorthand="source-factories"
default-class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector"/>
<role name="org.apache.excalibur.source.SourceResolver"
shorthand="source-resolver"
default-class="org.apache.excalibur.source.impl.SourceResolverImpl"/>
<role name="org.apache.cocoon.transformation.TransformerSelector"
shorthand="transformers"
default-class="org.apache.cocoon.sitemap.DefaultSitemapComponentSelector"/>
<role name="org.apache.excalibur.store.Store/TransientStore"
shorthand="transient-store"
default-class="org.apache.excalibur.store.impl.MemoryStore"/>
<role name="org.apache.excalibur.store.Store"
shorthand="persistent-store"
default-class="org.apache.excalibur.store.impl.MemoryStore"/>
</roles>
<components>
<xml-parser class="org.apache.excalibur.xml.impl.JaxpParser">
<parameter name="validate" value="false"/>
<parameter name="namespace-prefixes" value="false"/>
<parameter name="stop-on-warning" value="true"/>
<parameter name="stop-on-recoverable-error" value="true"/>
<parameter name="reuse-parsers" value="false"/>
</xml-parser>
<xmlizer/>
<transient-store/>
<persistent-store/>
<source-factories>
<component-instance class="org.apache.excalibur.source.impl.ResourceSourceFactory" name="resource"/>
<component-instance class="org.apache.excalibur.source.impl.URLSourceFactory" name="*"/>
</source-factories>
<source-resolver class="org.apache.excalibur.source.impl.SourceResolverImpl"/>
<xslt-processor logger="core.xslt-processor">
<parameter name="use-store" value="true"/>
<parameter name="incremental-processing" value="true"/>
</xslt-processor>
<transformers logger="test">
<component-instance class="org.apache.cocoon.transformation.TraxTransformer"
name="xalan">
<use-request-parameters>false</use-request-parameters>
<use-session-parameters>false</use-session-parameters>
<use-cookie-parameters>false</use-cookie-parameters>
<transformer-factory>org.apache.xalan.processor.TransformerFactoryImpl</transformer-factory>
</component-instance>
<component-instance name="xsltc"
class="org.apache.cocoon.transformation.TraxTransformer">
<use-request-parameters>false</use-request-parameters>
<use-session-parameters>false</use-session-parameters>
<use-cookie-parameters>false</use-cookie-parameters>
<transformer-factory>org.apache.xalan.xsltc.trax.TransformerFactoryImpl</transformer-factory>
</component-instance>
</transformers>
</components>
</testcase>
1.1 cocoon-2.1/src/test/org/apache/cocoon/transformation/traxtest-input.xml
Index: traxtest-input.xml
===================================================================
<hello-world>
<title>Title of the example</title>
<some-text>This is a litte test file!</some-text>
<some-text>And will transformed into a HTML page.</some-text>
</hello-world>
1.1 cocoon-2.1/src/test/org/apache/cocoon/transformation/traxtest-result.xml
Index: traxtest-result.xml
===================================================================
<?xml version="1.0"?>
<page>
<tab title="Overview" href="welcome"/>
<row>
<column title="Title of the example">
<p>This is a litte test file!</p>
<p>And will transformed into a HTML page.</p>
</column>
</row>
</page>
1.1 cocoon-2.1/src/test/org/apache/cocoon/transformation/traxtest-style.xsl
Index: traxtest-style.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="hello-world">
<page>
<tab title="Overview" href="welcome"/>
<row>
<column title="{title}">
<xsl:apply-templates select="some-text"/>
</column>
</row>
</page>
</xsl:template>
<xsl:template match="some-text">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
</xsl:stylesheet>