1   package org.apache.turbine.pipeline;
2   
3   
4   /*
5    * Licensed to the Apache Software Foundation (ASF) under one
6    * or more contributor license agreements.  See the NOTICE file
7    * distributed with this work for additional information
8    * regarding copyright ownership.  The ASF licenses this file
9    * to you under the Apache License, Version 2.0 (the
10   * "License"); you may not use this file except in compliance
11   * with the License.  You may obtain a copy of the License at
12   *
13   *   http://www.apache.org/licenses/LICENSE-2.0
14   *
15   * Unless required by applicable law or agreed to in writing,
16   * software distributed under the License is distributed on an
17   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18   * KIND, either express or implied.  See the License for the
19   * specific language governing permissions and limitations
20   * under the License.
21   */
22  
23  
24  import java.io.StringWriter;
25  
26  import junit.framework.TestCase;
27  
28  /**
29   * Tests TurbinePipeline.
30   *
31   * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
32   * @version $Id: PipelineTest.java 615328 2008-01-25 20:25:05Z tv $
33   */
34  public class PipelineTest extends TestCase
35  {
36      /**
37       * Constructor
38       */
39      public PipelineTest(String testName)
40      {
41          super(testName);
42      }
43  
44      /**
45       * Tests the Pipeline.
46       */
47      public void testPipeline() throws Exception
48      {
49  
50          // Make sure Valves are getting added properly to the
51          // Pipeline.
52          StringWriter writer = new StringWriter();
53          Pipeline pipeline = new TurbinePipeline();
54  
55          SimpleValve valve = new SimpleValve();
56          valve.setWriter(writer);
57          valve.setValue("foo");
58          pipeline.addValve(valve);
59          valve = new SimpleValve();
60          valve.setWriter(writer);
61          valve.setValue("bar");
62          pipeline.addValve(valve);
63  
64          pipeline.invoke(new DefaultPipelineData());
65  
66          assertEquals("foobar", writer.toString());
67      }
68  }