KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > jelly > core > TestFileTag


1 /*
2  * Copyright 2002,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.commons.jelly.core;
17
18 import java.io.StringWriter JavaDoc;
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 JavaDoc;
29
30 /**
31  * @author <a HREF="mailto:robert@bull-enterprises.com">Robert McIntosh</a>
32  * @version $Revision: 155420 $
33  */

34 public class TestFileTag extends BaseJellyTest
35 {
36
37     public TestFileTag(String JavaDoc name)
38     {
39         super(name);
40     }
41
42     public static TestSuite suite() throws Exception JavaDoc
43     {
44         return new TestSuite(TestFileTag.class);
45     }
46
47     public void testSimpleFileTag() throws Exception JavaDoc
48     {
49         setUpScript("testFileTag.jelly");
50         Script script = getJelly().compileScript();
51
52         script.run(getJellyContext(), getXMLOutput());
53
54         String JavaDoc data = (String JavaDoc)getJellyContext().getVariable("testFileTag");
55
56         //FIXME This doesn't take into account attribute ordering
57
assertEquals("fully qualified attributes not passed",
58                 "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\"></html>",
59                 data);
60     }
61
62     public void testDom4Xmlns() throws SAXException JavaDoc {
63         StringWriter JavaDoc writer = new StringWriter JavaDoc();
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 JavaDoc 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 }
80
Popular Tags