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