001package 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
025import static org.junit.Assert.assertEquals;
026import static org.junit.Assert.assertTrue;
027
028import org.junit.Test;
029
030import com.thoughtworks.xstream.XStream;
031import com.thoughtworks.xstream.io.xml.DomDriver;
032
033/**
034 * Tests TurbinePipeline.
035 *
036 * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
037 * @version $Id: PipelineCreationTest.java 1606111 2014-06-27 14:46:47Z gk $
038 */
039public class PipelineCreationTest
040{
041    private Pipeline pipeline;
042
043    public void setUp(){
044        pipeline = new TurbinePipeline();
045        pipeline.addValve(new SimpleValve());
046        pipeline.addValve(new DetermineActionValve());
047    }
048
049    @Test public void testSavingPipelineWXstream() throws Exception
050    {
051        XStream xstream = new XStream(new DomDriver()); // does not require XPP3 library
052
053        /* String xml = */ xstream.toXML(pipeline);
054        //System.out.println(xml);
055        //Pipeline pipeline = (Pipeline)xstream.fromXML(xml);
056    }
057
058    @Test public void testReadingPipelineWXstream() throws Exception{
059        String xml="<org.apache.turbine.pipeline.TurbinePipeline>  <valves>    <org.apache.turbine.pipeline.SimpleValve/>    <org.apache.turbine.pipeline.DetermineActionValve/>  </valves></org.apache.turbine.pipeline.TurbinePipeline>";
060        XStream xstream = new XStream(new DomDriver()); // does not require XPP3 library
061        Object o = xstream.fromXML(xml);
062        Pipeline pipeline = (Pipeline)o;
063        assertEquals(pipeline.getValves().length,2);
064        assertTrue(pipeline.getValves()[0] instanceof SimpleValve);
065        assertTrue(pipeline.getValves()[1] instanceof DetermineActionValve);
066    }
067
068}