001    package org.apache.turbine.pipeline;
002    
003    
004    /*
005     * Licensed to the Apache Software Foundation (ASF) under one
006     * or more contributor license agreements.  See the NOTICE file
007     * distributed with this work for additional information
008     * regarding copyright ownership.  The ASF licenses this file
009     * to you under the Apache License, Version 2.0 (the
010     * "License"); you may not use this file except in compliance
011     * with the License.  You may obtain a copy of the License at
012     *
013     *   http://www.apache.org/licenses/LICENSE-2.0
014     *
015     * Unless required by applicable law or agreed to in writing,
016     * software distributed under the License is distributed on an
017     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
018     * KIND, either express or implied.  See the License for the
019     * specific language governing permissions and limitations
020     * under the License.
021     */
022    
023    
024    import java.io.StringWriter;
025    
026    import junit.framework.TestCase;
027    
028    /**
029     * Tests TurbinePipeline.
030     *
031     * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
032     * @version $Id: PipelineTest.java 615328 2008-01-25 20:25:05Z tv $
033     */
034    public class PipelineTest extends TestCase
035    {
036        /**
037         * Constructor
038         */
039        public PipelineTest(String testName)
040        {
041            super(testName);
042        }
043    
044        /**
045         * Tests the Pipeline.
046         */
047        public void testPipeline() throws Exception
048        {
049    
050            // Make sure Valves are getting added properly to the
051            // Pipeline.
052            StringWriter writer = new StringWriter();
053            Pipeline pipeline = new TurbinePipeline();
054    
055            SimpleValve valve = new SimpleValve();
056            valve.setWriter(writer);
057            valve.setValue("foo");
058            pipeline.addValve(valve);
059            valve = new SimpleValve();
060            valve.setWriter(writer);
061            valve.setValue("bar");
062            pipeline.addValve(valve);
063    
064            pipeline.invoke(new DefaultPipelineData());
065    
066            assertEquals("foobar", writer.toString());
067        }
068    }