cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thors...@apache.org
Subject svn commit: r1448487 - in /cocoon/cocoon3/trunk/cocoon-optional/src/test: java/org/apache/cocoon/optional/pipeline/components/sax/generator/ resources/org/apache/cocoon/optional/pipeline/components/sax/generator/
Date Thu, 21 Feb 2013 01:24:50 GMT
Author: thorsten
Date: Thu Feb 21 01:24:50 2013
New Revision: 1448487

URL: http://svn.apache.org/r1448487
Log:
COCOON3-121
adding test for the generator

Added:
    cocoon/cocoon3/trunk/cocoon-optional/src/test/java/org/apache/cocoon/optional/pipeline/components/sax/generator/
    cocoon/cocoon3/trunk/cocoon-optional/src/test/java/org/apache/cocoon/optional/pipeline/components/sax/generator/AddRootElementGeneratorTest.java
    cocoon/cocoon3/trunk/cocoon-optional/src/test/resources/org/apache/cocoon/optional/pipeline/components/sax/generator/
    cocoon/cocoon3/trunk/cocoon-optional/src/test/resources/org/apache/cocoon/optional/pipeline/components/sax/generator/page.xml

Added: cocoon/cocoon3/trunk/cocoon-optional/src/test/java/org/apache/cocoon/optional/pipeline/components/sax/generator/AddRootElementGeneratorTest.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-optional/src/test/java/org/apache/cocoon/optional/pipeline/components/sax/generator/AddRootElementGeneratorTest.java?rev=1448487&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-optional/src/test/java/org/apache/cocoon/optional/pipeline/components/sax/generator/AddRootElementGeneratorTest.java
(added)
+++ cocoon/cocoon3/trunk/cocoon-optional/src/test/java/org/apache/cocoon/optional/pipeline/components/sax/generator/AddRootElementGeneratorTest.java
Thu Feb 21 01:24:50 2013
@@ -0,0 +1,67 @@
+/*
+ * 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.optional.pipeline.components.sax.generator;
+
+import static org.custommonkey.xmlunit.XMLAssert.assertNodeTestPasses;
+
+import java.io.ByteArrayOutputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.cocoon.pipeline.NonCachingPipeline;
+import org.apache.cocoon.pipeline.Pipeline;
+import org.apache.cocoon.sax.SAXPipelineComponent;
+import org.apache.cocoon.sax.component.XMLSerializer;
+import org.custommonkey.xmlunit.examples.CountingNodeTester;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Node;
+
+public class AddRootElementGeneratorTest {
+
+    /**
+     * Logger.
+     */
+    private static final Logger LOG = LoggerFactory
+            .getLogger(AddRootElementGeneratorTest.class);
+    
+	@Test
+    public void testPipelineWithAddRootElementGenerator() throws Exception {
+        Pipeline<SAXPipelineComponent> pipeline = new NonCachingPipeline<SAXPipelineComponent>();
+        URL resource = this.getClass().getResource("page.xml");
+        AddRootElementGenerator generator  = new AddRootElementGenerator();
+        Map<String, Object> parameters = new HashMap<String, Object>();
+        parameters.put("source", resource);
+        generator.setConfiguration(parameters);
+        generator.setEncoding("UTF-8");
+        generator.setLocalName("events");
+        generator.setPrefix("x");
+        generator.setNamespace("http://cocoon.apache.org/testing/");
+        pipeline.addComponent(generator);
+        pipeline.addComponent(new XMLSerializer());
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        pipeline.setup(baos);
+        pipeline.execute();
+        CountingNodeTester countingNodeTester = new CountingNodeTester(3);
+        String out = new String(baos.toByteArray());
+        LOG.debug(out);
+        assertNodeTestPasses(out, countingNodeTester, Node.ELEMENT_NODE);
+    }
+}

Added: cocoon/cocoon3/trunk/cocoon-optional/src/test/resources/org/apache/cocoon/optional/pipeline/components/sax/generator/page.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-optional/src/test/resources/org/apache/cocoon/optional/pipeline/components/sax/generator/page.xml?rev=1448487&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-optional/src/test/resources/org/apache/cocoon/optional/pipeline/components/sax/generator/page.xml
(added)
+++ cocoon/cocoon3/trunk/cocoon-optional/src/test/resources/org/apache/cocoon/optional/pipeline/components/sax/generator/page.xml
Thu Feb 21 01:24:50 2013
@@ -0,0 +1,19 @@
+<!--
+  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.
+-->
+<x:notWellformed>
+  <x:title>Hello</x:title>
+</x:notWellformed>



Mime
View raw message