1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jelly.core;
17
18 import java.io.StringWriter;
19
20 import junit.framework.TestSuite;
21
22 import org.apache.commons.jelly.Script;
23 import org.apache.commons.jelly.XMLOutput;
24 import org.apache.commons.jelly.test.BaseJellyTest;
25 import org.dom4j.io.HTMLWriter;
26 import org.dom4j.io.OutputFormat;
27 import org.dom4j.io.XMLWriter;
28 import org.xml.sax.SAXException;
29
30 /***
31 * @author <a href="mailto:robert@bull-enterprises.com">Robert McIntosh</a>
32 * @version $Revision: 219726 $
33 */
34 public class TestFileTag extends BaseJellyTest
35 {
36
37 public TestFileTag(String name)
38 {
39 super(name);
40 }
41
42 public static TestSuite suite() throws Exception
43 {
44 return new TestSuite(TestFileTag.class);
45 }
46
47 public void testSimpleFileTag() throws Exception
48 {
49 setUpScript("testFileTag.jelly");
50 Script script = getJelly().compileScript();
51
52 script.run(getJellyContext(), getXMLOutput());
53
54 String data = (String)getJellyContext().getVariable("testFileTag");
55
56
57 assertEquals("fully qualified attributes not passed",
58 "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\"></html>",
59 data);
60 }
61
62 public void testDom4Xmlns() throws SAXException {
63 StringWriter writer = new StringWriter();
64 OutputFormat format = new OutputFormat();
65 final XMLWriter xmlWriter = new HTMLWriter(writer, format);
66 xmlWriter.setEscapeText(false);
67
68 XMLOutput output = new XMLOutput(xmlWriter, xmlWriter);
69
70 String golden = "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n";
71 golden += "<html>";
72
73 output.startDocument();
74 output.write(golden);
75 output.endDocument();
76 assertEquals("output should contain the namespaces", golden, writer.toString());
77 }
78
79 }