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/29 08:59:19 UTC

svn commit: r410037 - in /cocoon/trunk/core/cocoon-core/src: main/java/org/apache/cocoon/transformation/ test/java/org/apache/cocoon/transformation/ test/resources/org/apache/cocoon/transformation/

Author: antonio
Date: Sun May 28 23:59:19 2006
New Revision: 410037

URL: http://svn.apache.org/viewvc?rev=410037&view=rev
Log:
Fix COCOON-1110 xi:fallback fail when use parse='text'.

Added:
    cocoon/trunk/core/cocoon-core/src/test/resources/org/apache/cocoon/transformation/xinclude-input-simpleFallbackForTextParseTest.xml   (with props)
Modified:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/transformation/XIncludeTransformer.java
    cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/transformation/XIncludeTransformerTestCase.java

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/transformation/XIncludeTransformer.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/transformation/XIncludeTransformer.java?rev=410037&r1=410036&r2=410037&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/transformation/XIncludeTransformer.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/transformation/XIncludeTransformer.java Sun May 28 23:59:19 2006
@@ -46,6 +46,7 @@
 import org.apache.cocoon.xml.XMLConsumer;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceException;
+import org.apache.excalibur.source.SourceNotFoundException;
 import org.apache.excalibur.source.SourceValidity; 
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
@@ -435,6 +436,10 @@
                         while ((read = reader.read(ary)) != -1) {
                             super.characters(ary,0,read);
                         }
+                    } catch (SourceNotFoundException e) {
+                        useFallback = true;
+                        fallBackException = new CascadingException("Resource not found: " + url.getURI());
+                        getLogger().error("xIncluded resource not found: " + url.getURI(), e);
                     } finally {
                         if (reader != null) reader.close();
                         if (isr != null) isr.close();

Modified: cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/transformation/XIncludeTransformerTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/transformation/XIncludeTransformerTestCase.java?rev=410037&r1=410036&r2=410037&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/transformation/XIncludeTransformerTestCase.java (original)
+++ cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/transformation/XIncludeTransformerTestCase.java Sun May 28 23:59:19 2006
@@ -58,27 +58,40 @@
                 "resource://org/apache/cocoon/transformation/xinclude-result-2.xml");
     }
 
-    // TODO: AG (2006-05-29): The following 2 testcases fail, due an unexpeced exception: 
+    // TODO: AG (2006-05-29): The following 3 testcases fail, due an unexpeced exception: 
     // org.springframework.beans.factory.NoSuchBeanDefinitionException
     // Once the avalon support into spring is totally transparent, this should work again.
     // Another option is to rewrite the XInclude transformer to only use spring framework.
     /** Testcase for xinclude simple fallback
-    *
-    * @throws Exception if ComponentManager enterEnvironment fails
-    */
-   /*public void testXIncludeSimpleFallbackTest() throws Exception {
-       getLogger().debug("testXIncludeSimpleFallbackTest");
+     * Check issue: COCOON-1489
+     *
+     * @throws Exception if ComponentManager enterEnvironment fails
+     */
+   /*public void testXIncludeSimpleFallback() throws Exception {
+       getLogger().debug("testXIncludeSimpleFallback");
        xincludeTest("resource://org/apache/cocoon/transformation/xinclude-input-fallbackTest.xml",
                "resource://org/apache/cocoon/transformation/xinclude-result-fallbackTest.xml");
    }*/
 
    /** Testcase for xinclude with a nested xinclude elemento into the fallback
+    * Check issue: COCOON-1489
+    *
+    * @throws Exception if ComponentManager enterEnvironment fails
+    */
+    /*public void testXIncludeNestedXincludeElementInAFallback() throws Exception {
+        getLogger().debug("testXIncludeNestedXincludeElementInAFallback");
+        xincludeTest("resource://org/apache/cocoon/transformation/xinclude-input-nestedXincludeFallbackTest.xml",
+            "resource://org/apache/cocoon/transformation/xinclude-result-fallbackTest.xml");
+    }*/
+
+  /** Testcase for xinclude simple fallback when parse attribute is 'text'
+   *  Check issue: COCOON-1110 
    *
    * @throws Exception if ComponentManager enterEnvironment fails
    */
-  /*public void testXIncludeNestedXincludeElementInAFallbackTest() throws Exception {
-      getLogger().debug("testXIncludeNestedXincludeElementInAFallbackTest");
-      xincludeTest("resource://org/apache/cocoon/transformation/xinclude-input-nestedXincludeFallbackTest.xml",
-              "resource://org/apache/cocoon/transformation/xinclude-result-fallbackTest.xml");
-  }*/
+    /*public void testXIncludeSimpleFallbackForTextParse() throws Exception {
+        getLogger().debug("testXIncludeSimpleFallbackForTextParse");
+        xincludeTest("resource://org/apache/cocoon/transformation/xinclude-input-simpleFallbackForTextParseTest.xml",
+            "resource://org/apache/cocoon/transformation/xinclude-result-fallbackTest.xml");
+    }*/
 }

Added: cocoon/trunk/core/cocoon-core/src/test/resources/org/apache/cocoon/transformation/xinclude-input-simpleFallbackForTextParseTest.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/test/resources/org/apache/cocoon/transformation/xinclude-input-simpleFallbackForTextParseTest.xml?rev=410037&view=auto
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/test/resources/org/apache/cocoon/transformation/xinclude-input-simpleFallbackForTextParseTest.xml (added)
+++ cocoon/trunk/core/cocoon-core/src/test/resources/org/apache/cocoon/transformation/xinclude-input-simpleFallbackForTextParseTest.xml Sun May 28 23:59:19 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 parse="text" href="this_file_does_not_exist.txt">
+    <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/trunk/core/cocoon-core/src/test/resources/org/apache/cocoon/transformation/xinclude-input-simpleFallbackForTextParseTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native