cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r892809 [2/2] - in /cocoon/cocoon3/trunk/cocoon-sax: ./ src/main/java/org/apache/cocoon/sax/component/ src/main/java/org/apache/cocoon/sax/xpointer/ src/main/javacc/ src/test/java/org/apache/cocoon/sax/component/ src/test/resources/
Date Mon, 21 Dec 2009 13:14:59 GMT
Added: cocoon/cocoon3/trunk/cocoon-sax/src/test/java/org/apache/cocoon/sax/component/XIncludeTransformerTest.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sax/src/test/java/org/apache/cocoon/sax/component/XIncludeTransformerTest.java?rev=892809&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sax/src/test/java/org/apache/cocoon/sax/component/XIncludeTransformerTest.java
(added)
+++ cocoon/cocoon3/trunk/cocoon-sax/src/test/java/org/apache/cocoon/sax/component/XIncludeTransformerTest.java
Mon Dec 21 13:14:59 2009
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.sax.component;
+
+import static junit.framework.Assert.*;
+
+import java.io.ByteArrayOutputStream;
+import java.net.URL;
+
+import org.apache.cocoon.pipeline.NonCachingPipeline;
+import org.apache.cocoon.pipeline.Pipeline;
+import org.apache.cocoon.sax.SAXPipelineComponent;
+import org.custommonkey.xmlunit.Diff;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * $Id$
+ */
+public final class XIncludeTransformerTest {
+
+    @BeforeClass
+    public static void setUp() {
+        XMLUnit.setIgnoreWhitespace(true);
+    }
+
+    /**
+     * A pipeline that reads from a file and perform a simple XInclude operation.
+     */
+     @Test
+     public void testPipelineWithXInclude() throws Exception {
+         this.internalXIncludeTest("xinclude-xml.xml",
+             "<?xml version=\"1.0\" encoding=\"UTF-8\"?><x><test/></x>");
+     }
+
+    /**
+     * A pipeline that performs an XInclude operation, including just text.
+     **/
+     @Test
+     public void testPipelineWithXIncludeText() throws Exception {
+         this.internalXIncludeTest("xinclude-text-only.xml",
+             "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+                 + "<x>in girum imus nocte et cosumimur igni</x>");
+     }
+
+    /**
+     * A pipeline that performs an XInclude operation, forced to use the fallback.
+     **/
+     @Test
+     public void testPipelineWithXIncludeFallback() throws Exception {
+         this.internalXIncludeTest("xinclude-fallback.xml",
+                "<?xml version=\"1.0\" encoding=\"UTF-8\"?><x>"
+                 + "<error>the linked document has not found</error></x>");
+     }
+
+    /**
+     * A pipeline that performs an XInclude operation and use XPointer to extract
+     * a fragment from the included document.
+     **/
+    @Test
+    public void testPipelineWithXIncludeAndXPointer() throws Exception {
+        this.internalXIncludeTest("xinclude-xpointer.xml",
+               "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+                + "<x xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"><p>"
+                + "<xsl:value-of select=\"$myParam\"/></p></x>");
+    }
+
+    /**
+     * A pipeline that performs an XInclude operation and use the deprecated
+     * XPointer to extract a fragment from the included document.
+     **/
+    @Test
+    public void testPipelineWithXIncludeAndDeprecatedXPointer() throws Exception {
+         this.internalXIncludeTest("xinclude-deprecated_xpointer.xml",
+            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+                 + "<x xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"><p>"
+                 + "<xsl:value-of select=\"$myParam\"/></p></x>");
+    }
+
+    /**
+     * A pipeline that performs an XInclude operation and use the shorthand
+     * XPointer to extract a fragment from the included document.
+     **/
+    @Test
+    public void testPipelineWithShorthandXPointerPart() throws Exception {
+        this.internalXIncludeTest("xinclude-shorthand.xml",
+            "<?xml version=\"1.0\" encoding=\"UTF-8\"?><x>"
+                + "<url id=\"url\">http://www.opensource.org/licenses/apache2.0.php</url>"
+                + "<url id=\"url\">http://www.opensource.org/licenses/lgpl-3.0.html</url>"
+                + "<url id=\"url\">http://www.opensource.org/licenses/mit-license.php</url>"
+                + "<url id=\"url\">http://www.opensource.org/licenses/W3C.php</url></x>");
+    }
+
+   /**
+    *
+    */
+   private void internalXIncludeTest(final String testResource, final String expectedDocument)
throws Exception {
+       URL base = this.getClass().getResource("/");
+       URL source = new URL(base, testResource);
+
+       Pipeline<SAXPipelineComponent> pipeline = new NonCachingPipeline<SAXPipelineComponent>();
+       pipeline.addComponent(new SAXGenerator(source));
+       pipeline.addComponent(new XIncludeTransformer(base));
+       pipeline.addComponent(new XMLSerializer());
+
+       ByteArrayOutputStream baos = new ByteArrayOutputStream();
+       pipeline.setup(baos);
+       pipeline.execute();
+
+       String actualDocument = new String(baos.toByteArray());
+
+       Diff diff = new Diff(expectedDocument, actualDocument);
+       assertTrue("XInclude transformation didn't work as expected " + diff,
+               diff.identical());
+   }
+
+}

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/java/org/apache/cocoon/sax/component/XIncludeTransformerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/java/org/apache/cocoon/sax/component/XIncludeTransformerTest.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/java/org/apache/cocoon/sax/component/XIncludeTransformerTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/just-text.txt
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/just-text.txt?rev=892809&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/just-text.txt (added)
+++ cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/just-text.txt Mon Dec 21 13:14:59 2009
@@ -0,0 +1 @@
+in girum imus nocte et cosumimur igni
\ No newline at end of file

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/just-text.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/just-text.txt
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/just-text.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/licenses.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/licenses.xml?rev=892809&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/licenses.xml (added)
+++ cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/licenses.xml Mon Dec 21 13:14:59 2009
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+ -->
+<!-- $Id$ -->
+<licenses>
+    <license>
+        <name>Apache License, Version 2.0</name>
+        <url id="url">http://www.opensource.org/licenses/apache2.0.php</url>
+    </license>
+    <license>
+        <name>LGPLv3</name>
+        <url id="url">http://www.opensource.org/licenses/lgpl-3.0.html</url>
+    </license>
+    <license>
+        <name>MIT License</name>
+        <url id="url">http://www.opensource.org/licenses/mit-license.php</url>
+    </license>
+    <license>
+        <name>W3C License</name>
+        <url id="url">http://www.opensource.org/licenses/W3C.php</url>
+    </license>
+</licenses>

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/licenses.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/licenses.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/licenses.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-deprecated_xpointer.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-deprecated_xpointer.xml?rev=892809&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-deprecated_xpointer.xml (added)
+++ cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-deprecated_xpointer.xml Mon
Dec 21 13:14:59 2009
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+ -->
+<!-- $Id$ -->
+<x xmlns:xi="http://www.w3.org/2001/XInclude"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+  <xi:include href="test.xslt#xmlns(xsl=http://www.w3.org/1999/XSL/Transform)xpointer(//p)"/>
+</x>

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-deprecated_xpointer.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-deprecated_xpointer.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-deprecated_xpointer.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-fallback.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-fallback.xml?rev=892809&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-fallback.xml (added)
+++ cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-fallback.xml Mon Dec 21 13:14:59
2009
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+ -->
+<!-- $Id$ -->
+<x xmlns:xi="http://www.w3.org/2001/XInclude">
+  <xi:include href="document-not-found.txt" parse="text">
+    <xi:fallback>
+        <error>the linked document has not found</error>
+    </xi:fallback>
+  </xi:include>
+</x>

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-fallback.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-fallback.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-fallback.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-shorthand.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-shorthand.xml?rev=892809&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-shorthand.xml (added)
+++ cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-shorthand.xml Mon Dec 21 13:14:59
2009
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+ -->
+<!-- $Id$ -->
+<x xmlns:xi="http://www.w3.org/2001/XInclude">
+  <xi:include href="licenses.xml" xpointer="url"/>
+</x>

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-shorthand.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-shorthand.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-shorthand.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-text-only.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-text-only.xml?rev=892809&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-text-only.xml (added)
+++ cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-text-only.xml Mon Dec 21 13:14:59
2009
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+ -->
+<!-- $Id$ -->
+<x xmlns:xi="http://www.w3.org/2001/XInclude">
+  <xi:include href="just-text.txt" parse="text"/>
+</x>

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-text-only.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-text-only.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-text-only.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-xml.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-xml.xml?rev=892809&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-xml.xml (added)
+++ cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-xml.xml Mon Dec 21 13:14:59
2009
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+ -->
+<!-- $Id$ -->
+<x xmlns:xi="http://www.w3.org/2001/XInclude">
+  <xi:include href="test.xml"/>
+</x>

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-xml.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-xml.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-xml.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-xpointer.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-xpointer.xml?rev=892809&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-xpointer.xml (added)
+++ cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-xpointer.xml Mon Dec 21 13:14:59
2009
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+ -->
+<!-- $Id$ -->
+<x xmlns:xi="http://www.w3.org/2001/XInclude"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+  <xi:include href="test.xslt"
+    xpointer="xmlns(xsl=http://www.w3.org/1999/XSL/Transform)xpointer(//p)"/>
+</x>

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-xpointer.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-xpointer.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-sax/src/test/resources/xinclude-xpointer.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message