1 package org.apache.turbine.pipeline; 2 3 56 57 58 import junit.framework.TestCase; 59 60 import org.apache.turbine.Pipeline; 61 62 import com.thoughtworks.xstream.XStream; 63 import com.thoughtworks.xstream.io.xml.DomDriver; 64 65 71 public class PipelineCreationTest extends TestCase 72 { 73 private Pipeline pipeline; 74 77 public PipelineCreationTest(String testName) 78 { 79 super(testName); 80 } 81 82 public void setUp(){ 83 pipeline = new TurbinePipeline(); 84 pipeline.addValve(new SimpleValve()); 85 pipeline.addValve(new DetermineActionValve()); 86 } 87 88 89 public void testSavingPipelineWXstream() throws Exception 90 { 91 XStream xstream = new XStream(new DomDriver()); 93 String xml = xstream.toXML(pipeline); 94 97 } 98 99 public void testReadingPipelineWXstream() throws Exception { 100 String xml="<org.apache.turbine.pipeline.TurbinePipeline> <valves> <org.apache.turbine.pipeline.SimpleValve/> <org.apache.turbine.pipeline.DetermineActionValve/> </valves></org.apache.turbine.pipeline.TurbinePipeline>"; 101 XStream xstream = new XStream(new DomDriver()); Object o = xstream.fromXML(xml); 103 Pipeline pipeline = (Pipeline)o; 104 assertEquals(pipeline.getValves().length,2); 105 assertTrue(pipeline.getValves()[0] instanceof SimpleValve); 106 assertTrue(pipeline.getValves()[1] instanceof DetermineActionValve); 107 } 108 109 } 110 | Popular Tags |