cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hu...@apache.org
Subject cvs commit: cocoon-2.1/src/test/org/apache/cocoon/transformation AugmentTransformerTestCase.java AugmentTransformerTestCase.xtest EncodeURLTransformerTestCase.java EncodeURLTransformerTestCase.xtest augment-input-1.xml augment-result-1.xml encodeurl-input-1.xml encodeurl-input-2.xml encodeurl-result-1.xml encodeurl-result-2.xml
Date Sun, 04 Jul 2004 18:01:40 GMT
huber       2004/07/04 11:01:39

  Added:       src/test/org/apache/cocoon/transformation
                        AugmentTransformerTestCase.java
                        AugmentTransformerTestCase.xtest
                        EncodeURLTransformerTestCase.java
                        EncodeURLTransformerTestCase.xtest
                        augment-input-1.xml augment-result-1.xml
                        encodeurl-input-1.xml encodeurl-input-2.xml
                        encodeurl-result-1.xml encodeurl-result-2.xml
  Log:
  junit test for augment, and encode url transformers
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.1                  cocoon-2.1/src/test/org/apache/cocoon/transformation/AugmentTransformerTestCase.java
  
  Index: AugmentTransformerTestCase.java
  ===================================================================
  /*
   * Copyright 1999-2004 The Apache Software Foundation.
   * 
   * 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.apache.org/licenses/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.apache.cocoon.transformation;
  
  import junit.framework.Test;
  import junit.framework.TestSuite;
  import junit.textui.TestRunner;
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.cocoon.Processor;
  import org.apache.cocoon.SitemapComponentTestCase;
  import org.apache.cocoon.components.container.ComponentManagerWrapper;
  import org.apache.cocoon.environment.internal.EnvironmentHelper;
  import org.apache.cocoon.environment.mock.MockEnvironment;
  import org.w3c.dom.Document;
  
  
  /**
   * A simple testcase for AugmentTransformer.
   *
   * @author <a href="mailto:huber@apache.org">Bernhard Huber</a>
   * @version CVS $Id: AugmentTransformerTestCase.java,v 1.1 2004/07/04 18:01:39 huber Exp
$
   */
  public class AugmentTransformerTestCase extends SitemapComponentTestCase {
      
      /** Create new testcase
       * @param name of testase
       */
      public AugmentTransformerTestCase(String name) {
          super(name);
      }
      
      /**
       * Run this test suite from commandline
       *
       * @param args commandline arguments (ignored)
       */
      public static void main( String[] args ) {
          TestRunner.run(suite());
      }
      
      /** Create a test suite.
       * This test suite contains all test cases of this class.
       * @return the Test object containing all test cases.
       */
      public static Test suite() {
          TestSuite suite = new TestSuite(AugmentTransformerTestCase.class);
          return suite;
      }
      
      /** Testcase for augment transformation
       *
       * @throws Exception iff ComponentManager enterEnvironment fails
       */
      public void testAugment1() throws Exception {
          getLogger().debug("testAugment1");
          
          Parameters parameters = new Parameters();
          parameters.setParameter( "mount", "portal1/sect1/" );
          
          String input = "resource://org/apache/cocoon/transformation/augment-input-1.xml";
          String result = "resource://org/apache/cocoon/transformation/augment-result-1.xml";
          String src =  null;
          
          // enter & leave environment, as a manager is looked up using
          // the processing context stack
          MockEnvironment env = new MockEnvironment();
          Processor processor = (Processor)this.manager.lookup(Processor.ROLE);
          
          EnvironmentHelper.enterProcessor(processor, new ComponentManagerWrapper(this.manager),
env);
          
          Document resultDocument = load(result);
          Document inputDocument = load(input);
          Document transformDocument = transform("augment", src, parameters, inputDocument
);
          
          printDocs( resultDocument, inputDocument, transformDocument );
          
          assertIdentical( resultDocument, transformDocument );
          
          EnvironmentHelper.leaveProcessor();
      }
      
      /**
       * print documents to System.out
       *
       * @param resultDocument the expected result document
       * @param inputDocument the input document
       * @param transformDocument  the transformed input document
       */
      protected void printDocs( Document resultDocument, Document inputDocument, Document
transformDocument ) {
          System.out.println( "resultDocument" );
          this.print( resultDocument );
          System.out.println( "inputDocument" );
          this.print( inputDocument );
          System.out.println( "transformDocument" );
          this.print( transformDocument );
      }
  }
  
  
  
  1.1                  cocoon-2.1/src/test/org/apache/cocoon/transformation/AugmentTransformerTestCase.xtest
  
  Index: AugmentTransformerTestCase.xtest
  ===================================================================
  <?xml version="1.0" ?>
  <testcase>
   <annotation>
    Test Cases: AugmentTransformer
   </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="DEBUG">
      <log-target id-ref="root"/>
     </category>
    </categories>
   </logkit>
  
   <context>
     <entry name="root-url" value="/"/>
   </context>
  
   <roles>
    <role name="org.apache.cocoon.Processor"
          shorthand="sitemap"
          default-class="org.apache.cocoon.components.treeprocessor.TreeProcessor"/>
    <role name="org.apache.excalibur.xml.dom.DOMParser"
          shorthand="dom-parser"
          default-class="org.apache.excalibur.xml.impl.JaxpParser"/>
    <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.xml.xpath.XPathProcessor"
          shorthand="xpath-processor"
          default-class="org.apache.excalibur.xml.xpath.XPathProcessorImpl"/>
  
    <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.components.ExtendedComponentSelector"/>
          
    <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>
    <sitemap check-reload="yes" 
      file="context://sitemap.xmap" 
      logger="sitemap"/>
  
    <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.AugmentTransformer" 
                         name="augment">
     </component-instance>
  
    </transformers>
   </components>
  
  </testcase>
  
  
  
  1.1                  cocoon-2.1/src/test/org/apache/cocoon/transformation/EncodeURLTransformerTestCase.java
  
  Index: EncodeURLTransformerTestCase.java
  ===================================================================
  /*
   * Copyright 1999-2004 The Apache Software Foundation.
   *
   * 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.apache.org/licenses/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.apache.cocoon.transformation;
  
  import junit.framework.Test;
  import junit.framework.TestSuite;
  import junit.textui.TestRunner;
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.cocoon.Processor;
  import org.apache.cocoon.SitemapComponentTestCase;
  import org.apache.cocoon.components.container.ComponentManagerWrapper;
  import org.apache.cocoon.environment.internal.EnvironmentHelper;
  import org.apache.cocoon.environment.mock.MockEnvironment;
  import org.apache.cocoon.environment.mock.MockRequest;
  import org.apache.cocoon.environment.mock.MockResponse;
  import org.apache.cocoon.environment.mock.MockSession;
  import org.w3c.dom.Document;
  
  
  /**
   * A simple testcase for FilterTransformer.
   *
   * @author <a href="mailto:stephan@apache.org">Stephan Michels </a>
   * @version CVS $Id: EncodeURLTransformerTestCase.java,v 1.1 2004/07/04 18:01:39 huber Exp
$
   */
  public class EncodeURLTransformerTestCase extends SitemapComponentTestCase {
      
      /** Create new testcase
       * @param name of testase
       */
      public EncodeURLTransformerTestCase(String name) {
          super(name);
      }
      
      /**
       * Run this test suite from commandline
       *
       * @param args commandline arguments (ignored)
       */
      public static void main( String[] args ) {
          TestRunner.run(suite());
      }
      
      /** Create a test suite.
       * This test suite contains all test cases of this class.
       * @return the Test object containing all test cases.
       */
      public static Test suite() {
          TestSuite suite = new TestSuite(EncodeURLTransformerTestCase.class);
          return suite;
      }
      
      /** Testcase for encode url transformation
       *
       * @throws Exception iff ComponentManager enterEnvironment fails
       */
      public void testEncodeURL1() throws Exception {
          getLogger().debug("testEncodeURL1");
          
          Parameters parameters = new Parameters();
          
          String input = "resource://org/apache/cocoon/transformation/encodeurl-input-1.xml";
          String result = "resource://org/apache/cocoon/transformation/encodeurl-result-1.xml";
          String src =  null;
          
          // enter & leave environment, as a manager is looked up using
          // the processing context stack
          // enter & leave environment, as a manager is looked up using
          // the processing context stack
          MockEnvironment env = new MockEnvironment();
          Processor processor = (Processor)this.manager.lookup(Processor.ROLE);
          
          EnvironmentHelper.enterProcessor(processor, new ComponentManagerWrapper(this.manager),
env);
          
          Document inputDocument = load(input);
          Document resultDocument = load(result);
          Document transformDocument = transform("encodeurl", src, parameters, inputDocument);
          
          printDocs( resultDocument, inputDocument, transformDocument );
          
          assertIdentical( resultDocument, transformDocument );
          
          EnvironmentHelper.leaveProcessor();
      }
      
      /** Testcase for encode url transformation
       *
       * @throws Exception iff ComponentManager enterEnvironment fails
       */
      public void testEncodeURL2() throws Exception {
          getLogger().debug("testEncodeURL2");
          
          Parameters parameters = new Parameters();
          
          String input = "resource://org/apache/cocoon/transformation/encodeurl-input-2.xml";
          String result = "resource://org/apache/cocoon/transformation/encodeurl-result-2.xml";
          String src =  null;
          
          // force that sessionId is added to an URL
          MockRequest request = getRequest();
          MockSession session = (MockSession)request.getSession();
          MockResponse response = getResponse();
          
          response.setSession(session);
          getRequest().setIsRequestedSessionIdFromURL( true );
  
          session.setIsNew(true);
          
          // enter & leave environment, as a manager is looked up using
          // the processing context stack
          // enter & leave environment, as a manager is looked up using
          // the processing context stack
          MockEnvironment env = new MockEnvironment();
          Processor processor = (Processor)this.manager.lookup(Processor.ROLE);
          
          EnvironmentHelper.enterProcessor(processor, new ComponentManagerWrapper(this.manager),
env);
          
          Document inputDocument = load(input);
          Document resultDocument = load(result);
          Document transformDocument = transform("encodeurl", src, parameters, inputDocument);
          
          printDocs( resultDocument, inputDocument, transformDocument );
          assertIdentical( resultDocument, transformDocument );
          
          EnvironmentHelper.leaveProcessor();
      }
      
      /**
       * print documents to System.out
       *
       * @param resultDocument the expected result document
       * @param inputDocument the input document
       * @param transformDocument  the transformed input document
       */
      protected void printDocs( Document resultDocument, Document inputDocument, Document
transformDocument ) {
          System.out.println( "resultDocument" );
          this.print( resultDocument );
          System.out.println( "inputDocument" );
          this.print( inputDocument );
          System.out.println( "transformDocument" );
          this.print( transformDocument );
      }
      
  }
  
  
  
  1.1                  cocoon-2.1/src/test/org/apache/cocoon/transformation/EncodeURLTransformerTestCase.xtest
  
  Index: EncodeURLTransformerTestCase.xtest
  ===================================================================
  <?xml version="1.0" ?>
  <testcase>
   <annotation>
    Test Cases: CIncludeTransformer
   </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="DEBUG">
      <log-target id-ref="root"/>
     </category>
    </categories>
   </logkit>
  
   <context>
     <entry name="root-url" value="/"/>
   </context>
  
   <roles>
    <role name="org.apache.cocoon.Processor"
          shorthand="sitemap"
          default-class="org.apache.cocoon.components.treeprocessor.TreeProcessor"/>
    <role name="org.apache.excalibur.xml.dom.DOMParser"
          shorthand="dom-parser"
          default-class="org.apache.excalibur.xml.impl.JaxpParser"/>
    <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.xml.xpath.XPathProcessor"
          shorthand="xpath-processor"
          default-class="org.apache.excalibur.xml.xpath.XPathProcessorImpl"/>
  
    <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.components.ExtendedComponentSelector"/>
  
    <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>
    <sitemap check-reload="yes" 
      file="context://sitemap.xmap" 
      logger="sitemap"/>
  
    <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.EncodeURLTransformer"

                         name="encodeurl">
     </component-instance>
  
    </transformers>
   </components>
  
  </testcase>
  
  
  
  1.1                  cocoon-2.1/src/test/org/apache/cocoon/transformation/augment-input-1.xml
  
  Index: augment-input-1.xml
  ===================================================================
  <?xml version="1.0" ?>
  
  <root>
    <x>X</x>
    <a>A</a>
    <a b="c">d</a>
    <a href="x">x</a>
  </root>
  
  
  1.1                  cocoon-2.1/src/test/org/apache/cocoon/transformation/augment-result-1.xml
  
  Index: augment-result-1.xml
  ===================================================================
  <?xml version="1.0" ?>
  
  <root>
    <x>X</x>
    <a>A</a>
    <a b="c">d</a>
    <a href="http://nullnull/portal1/sect1/x">x</a>
  </root>
  
  
  
  1.1                  cocoon-2.1/src/test/org/apache/cocoon/transformation/encodeurl-input-1.xml
  
  Index: encodeurl-input-1.xml
  ===================================================================
  <?xml version="1.0" ?>
  
  <root>
    <x>X</x>
    <a>A</a>
    <a b="c">d</a>
    <a href="x">x</a>
  </root>
  
  
  1.1                  cocoon-2.1/src/test/org/apache/cocoon/transformation/encodeurl-input-2.xml
  
  Index: encodeurl-input-2.xml
  ===================================================================
  <?xml version="1.0" ?>
  
  <root>
    <x>X</x>
    <a>A</a>
    <a b="c">d</a>
    <a href="x">x</a>
  </root>
  
  
  1.1                  cocoon-2.1/src/test/org/apache/cocoon/transformation/encodeurl-result-1.xml
  
  Index: encodeurl-result-1.xml
  ===================================================================
  <?xml version="1.0" ?>
  
  <root>
    <x>X</x>
    <a>A</a>
    <a b="c">d</a>
    <a href="x">x</a>
  </root>
  
  
  
  1.1                  cocoon-2.1/src/test/org/apache/cocoon/transformation/encodeurl-result-2.xml
  
  Index: encodeurl-result-2.xml
  ===================================================================
  <?xml version="1.0" ?>
  
  <root>
    <x>X</x>
    <a>A</a>
    <a b="c">d</a>
    <a href="x?JSESSIONID=MockSession">x</a>
  </root>
  
  
  

Mime
View raw message