01: /*
02: * This file is part of "SnipSnap Radeox Rendering Engine".
03: *
04: * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel
05: * All Rights Reserved.
06: *
07: * Please visit http://radeox.org/ for updates and contact.
08: *
09: * --LICENSE NOTICE--
10: * Licensed under the Apache License, Version 2.0 (the "License");
11: * you may not use this file except in compliance with the License.
12: * You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software
17: * distributed under the License is distributed on an "AS IS" BASIS,
18: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19: * See the License for the specific language governing permissions and
20: * limitations under the License.
21: * --LICENSE NOTICE--
22: */
23: package org.radeox.test.macro.code;
24:
25: import junit.framework.Test;
26: import junit.framework.TestSuite;
27:
28: import org.radeox.EngineManager;
29: import org.radeox.test.macro.MacroTestSupport;
30:
31: public class XmlCodeMacroTest extends MacroTestSupport {
32: final String S_CODE = "<div class=\"code\"><pre>";
33:
34: final String E_CODE = "</pre></div>";
35:
36: final String S_XML_TAG = "<span class=\"xml-tag\"><";
37:
38: final String E_XML_TAG = "></span>";
39:
40: final String S_XML_KEYWORD = "<span class=\"xml-keyword\">";
41:
42: final String E_XML_KEYWORD = "</span>";
43:
44: final String S_XML_QUOTE = "<span class=\"xml-quote\">\"";
45:
46: final String E_XML_QUOTE = "\"</span>";
47:
48: public XmlCodeMacroTest(String name) {
49: super (name);
50: }
51:
52: public static Test suite() {
53: return new TestSuite(XmlCodeMacroTest.class);
54: }
55:
56: public void testXmlCodeXmlElement() {
57: String result = EngineManager
58: .getInstance()
59: .render(
60: "{code:xml}<xml a=\"attr\"><node>text</node></xml>{code}",
61: context);
62: assertEquals(S_CODE + S_XML_TAG + "xml a=" + S_XML_QUOTE
63: + "attr" + E_XML_QUOTE + E_XML_TAG + S_XML_TAG + "node"
64: + E_XML_TAG + "text" + S_XML_TAG + "/node" + E_XML_TAG
65: + S_XML_TAG + "/xml" + E_XML_TAG + E_CODE, result);
66: }
67:
68: public void testXmlCodeXsl() {
69: String sInput = "{code:xml}<xsl:anytag/>{code}";
70: String sExpected = S_CODE + S_XML_TAG + S_XML_KEYWORD
71: + "xsl:anytag" + E_XML_KEYWORD + "/" + E_XML_TAG
72: + E_CODE;
73: String sResult = EngineManager.getInstance().render(sInput,
74: context);
75: assertEquals(sExpected, sResult);
76: }
77:
78: public void testXmlCodeXslWithAttr() {
79: String sInput = "{code:xml}<xsl:anytag attr=\"1\"/>{code}";
80: String sExpected = S_CODE + S_XML_TAG + S_XML_KEYWORD
81: + "xsl:anytag" + E_XML_KEYWORD + " attr=" + S_XML_QUOTE
82: + "1" + E_XML_QUOTE + "/" + E_XML_TAG + E_CODE;
83: String sResult = EngineManager.getInstance().render(sInput,
84: context);
85: assertEquals(sExpected, sResult);
86: }
87: }
|