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