You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by an...@apache.org on 2006/05/28 04:58:53 UTC

svn commit: r409912 - in /cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation: XIncludeTransformerTestCase.java xinclude-input-fallbackTest.xml xinclude-result-fallbackTest.xml

Author: antonio
Date: Sat May 27 19:58:52 2006
New Revision: 409912

URL: http://svn.apache.org/viewvc?rev=409912&view=rev
Log:
Add testcase for COCOON-1489 XInclude transformer does not handle fallback correctly.

Added:
    cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/xinclude-input-fallbackTest.xml   (with props)
    cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/xinclude-result-fallbackTest.xml   (with props)
Modified:
    cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/XIncludeTransformerTestCase.java

Modified: cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/XIncludeTransformerTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/XIncludeTransformerTestCase.java?rev=409912&r1=409911&r2=409912&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/XIncludeTransformerTestCase.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/XIncludeTransformerTestCase.java Sat May 27 19:58:52 2006
@@ -31,10 +31,10 @@
  * A simple testcase for FilterTransformer.
  *
  * @author <a href="mailto:stephan@apache.org">Stephan Michels </a>
- * @version CVS $Id$
+ * @version SVN $Id$
  */
 public class XIncludeTransformerTestCase extends SitemapComponentTestCase {
-    
+
     /**
      * Run this test suite from commandline
      *
@@ -43,7 +43,7 @@
     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.
@@ -53,59 +53,52 @@
         return suite;
     }
     
-    /** Testcase for xinclude simple include
-     *
-     * @throws Exception iff ComponentManager enterEnvironment fails
-     */
-    public void testXInclude1() throws Exception {
-        getLogger().debug("testXInclude1");
-        
+    private void xincludeTest(String input, String result) throws Exception {
         Parameters parameters = new Parameters();
-        
-        String input = "resource://org/apache/cocoon/transformation/xinclude-input-1.xml";
-        String result = "resource://org/apache/cocoon/transformation/xinclude-result-1.xml";
+
         String src =  null;
-        
+
         // enter & leave environment, as a manager is looked up using
         // the processing context stack
         MockEnvironment env = new
         MockEnvironment(null);
         Processor processor = (Processor)this.lookup(Processor.ROLE);
-        
+
         CocoonComponentManager.enterEnvironment(
         env, new WrapperComponentManager(this.getManager()), processor);
-        
-        assertEqual( load(result),
-        transform("xinclude", src, parameters, load(input)));
-        
+
+        assertEqual(load(result), transform("xinclude", src, parameters, load(input)));
+
         CocoonComponentManager.leaveEnvironment();
     }
+
+    /** Testcase for xinclude simple include
+     *
+     * @throws Exception if ComponentManager enterEnvironment fails
+     */
+    public void testXInclude1() throws Exception {
+        getLogger().debug("testXInclude1");
+        xincludeTest("resource://org/apache/cocoon/transformation/xinclude-input-1.xml",
+                "resource://org/apache/cocoon/transformation/xinclude-result-1.xml");
+    }
+
     /** Testcase for xinclude simple text include
      *
-     * @throws Exception iff ComponentManager enterEnvironment fails
+     * @throws Exception if ComponentManager enterEnvironment fails
      */
     public void testXInclude2() throws Exception {
         getLogger().debug("testXInclude2");
-        
-        Parameters parameters = new Parameters();
-        
-        String input = "resource://org/apache/cocoon/transformation/xinclude-input-2.xml";
-        String result = "resource://org/apache/cocoon/transformation/xinclude-result-2.xml";
-        String src =  null;
-        
-        // enter & leave environment, as a manager is looked up using
-        // the processing context stack
-        MockEnvironment env = new
-        MockEnvironment(null);
-        Processor processor = (Processor)this.lookup(Processor.ROLE);
-        
-        CocoonComponentManager.enterEnvironment(
-        env, new WrapperComponentManager(this.getManager()), processor);
-        
-        assertEqual( load(result),
-        transform("xinclude", src, parameters, load(input)));
-        
-        CocoonComponentManager.leaveEnvironment();
+        xincludeTest("resource://org/apache/cocoon/transformation/xinclude-input-2.xml",
+                "resource://org/apache/cocoon/transformation/xinclude-result-2.xml");
     }
     
+    /** Testcase for xinclude simple fallback
+    *
+    * @throws Exception if ComponentManager enterEnvironment fails
+    */
+   public void testXIncludeFallbackTest() throws Exception {
+       getLogger().debug("testXIncludeFallbackTest");
+       xincludeTest("resource://org/apache/cocoon/transformation/xinclude-input-fallbackTest.xml",
+               "resource://org/apache/cocoon/transformation/xinclude-result-fallbackTest.xml");
+   }
 }

Added: cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/xinclude-input-fallbackTest.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/xinclude-input-fallbackTest.xml?rev=409912&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/xinclude-input-fallbackTest.xml (added)
+++ cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/xinclude-input-fallbackTest.xml Sat May 27 19:58:52 2006
@@ -0,0 +1,31 @@
+<?xml version="1.0" ?>
+<!--
+  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.
+-->
+
+<root
+  xmlns:xi="http://www.w3.org/2001/XInclude">
+  <p>P1</p>
+  <p>P2</p>
+
+  <xi:include href="this_file_does_not_exist.xml">
+    <xi:fallback>
+      <element>This should be here if the file was not found</element>
+    </xi:fallback>
+  </xi:include> 
+
+  <p>P3</p>
+  <p>P4</p>
+</root>
\ No newline at end of file

Propchange: cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/xinclude-input-fallbackTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/xinclude-result-fallbackTest.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/xinclude-result-fallbackTest.xml?rev=409912&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/xinclude-result-fallbackTest.xml (added)
+++ cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/xinclude-result-fallbackTest.xml Sat May 27 19:58:52 2006
@@ -0,0 +1,27 @@
+<?xml version="1.0" ?>
+<!--
+  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.
+-->
+
+<root
+  xmlns:xi="http://apache.org/cocoon/include/1.0">
+  <p>P1</p>
+  <p>P2</p>
+
+  <element>This should be here if the file was not found</element>
+
+  <p>P3</p>
+  <p>P4</p>
+</root>
\ No newline at end of file

Propchange: cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/xinclude-result-fallbackTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native