You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by si...@apache.org on 2010/12/07 21:33:16 UTC

svn commit: r1043190 - /cocoon/cocoon3/trunk/cocoon-sax/src/test/java/org/apache/cocoon/sax/PipelineTest.java

Author: simonetripodi
Date: Tue Dec  7 20:33:16 2010
New Revision: 1043190

URL: http://svn.apache.org/viewvc?rev=1043190&view=rev
Log:
test shows how to use pipeline DSL

Modified:
    cocoon/cocoon3/trunk/cocoon-sax/src/test/java/org/apache/cocoon/sax/PipelineTest.java

Modified: cocoon/cocoon3/trunk/cocoon-sax/src/test/java/org/apache/cocoon/sax/PipelineTest.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sax/src/test/java/org/apache/cocoon/sax/PipelineTest.java?rev=1043190&r1=1043189&r2=1043190&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sax/src/test/java/org/apache/cocoon/sax/PipelineTest.java (original)
+++ cocoon/cocoon3/trunk/cocoon-sax/src/test/java/org/apache/cocoon/sax/PipelineTest.java Tue Dec  7 20:33:16 2010
@@ -26,6 +26,7 @@ import junit.framework.TestCase;
 
 import org.apache.cocoon.pipeline.NonCachingPipeline;
 import org.apache.cocoon.pipeline.Pipeline;
+import org.apache.cocoon.pipeline.builder.PipelineBuilder;
 import org.apache.cocoon.sax.component.XMLGenerator;
 import org.apache.cocoon.sax.component.XMLSerializer;
 import org.apache.cocoon.sax.component.XSLTTransformer;
@@ -58,18 +59,20 @@ public class PipelineTest extends TestCa
      * @throws Exception if any error occurs.
      */
     public void testPipelineWithCompiledXSLT() throws Exception {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
         Map<String, Object> attributes = new HashMap<String, Object>();
         attributes.put("translet-name", "CompiledXslt");
         attributes.put("package-name", "org.apache.cocoon.sax");
 
-        Pipeline<SAXPipelineComponent> pipeline = new NonCachingPipeline<SAXPipelineComponent>();
-        pipeline.addComponent(new XMLGenerator("<x></x>"));
-        pipeline.addComponent(new XSLTTransformer(this.getClass().getResource("/test.xslt"), attributes));
-        pipeline.addComponent(new XMLSerializer());
-
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        pipeline.setup(baos);
-        pipeline.execute();
+        new PipelineBuilder<SAXPipelineComponent>()
+            .newCachingPipeline()
+            .setStarter(new XMLGenerator("<x></x>"))
+            .addComponent(new XSLTTransformer(this.getClass().getResource("/test.xslt"), attributes))
+            .setFinisher(new XMLSerializer())
+            .withEmptyConfiguration()
+            .setup(baos)
+            .execute();
 
         Diff diff = new Diff("<?xml version=\"1.0\" encoding=\"UTF-8\"?><p></p>", new String(baos.toByteArray()));
         assertTrue("XSL transformation didn't work as expected " + diff, diff.identical());