1 16 package org.apache.commons.jelly; 17 18 import java.io.ByteArrayOutputStream ; 19 20 import org.apache.commons.jelly.Script; 21 import org.apache.commons.jelly.XMLOutput; 22 import org.apache.commons.jelly.test.BaseJellyTest; 23 24 28 public class TestXMLOutput extends BaseJellyTest { 29 30 33 public TestXMLOutput(String name) { 34 super(name); 35 } 36 37 public void testOutputGood() throws Exception { 38 setUpScript("outputGood.jelly"); 39 Script script = getJelly().compileScript(); 40 41 ByteArrayOutputStream bos = new ByteArrayOutputStream (); 42 43 script.run(getJellyContext(),XMLOutput.createXMLOutput(bos)); 44 assertEquals("<html></html>x",bos.toString()); 45 } 46 47 public void testOutputBad() throws Exception { 48 setUpScript("outputBad.jelly"); 49 Script script = getJelly().compileScript(); 50 51 ByteArrayOutputStream bos = new ByteArrayOutputStream (); 52 53 script.run(getJellyContext(),XMLOutput.createXMLOutput(bos)); 54 assertEquals("<html></html>",bos.toString()); 55 } 56 57 public void testOutputBadGood() throws Exception { 58 setUpScript("outputBad.jelly"); 59 Script script = getJelly().compileScript(); 60 61 ByteArrayOutputStream bos = new ByteArrayOutputStream (); 62 63 XMLOutput ouput = XMLOutput.createXMLOutput(bos); 64 65 script.run(getJellyContext(),ouput); 66 ouput.flush(); 67 assertEquals("<html></html>",bos.toString()); 68 } 69 70 public void testOutputData() throws Exception { 71 setUpScript("outputData.jelly"); 72 Script script = getJelly().compileScript(); 73 74 ByteArrayOutputStream bos = new ByteArrayOutputStream (); 75 XMLOutput ouput = XMLOutput.createXMLOutput(bos); 76 77 script.run(getJellyContext(),ouput); 78 ouput.flush(); 79 assertEquals("[string]",bos.toString().trim()); 80 } 81 } 82 | Popular Tags |