001: /*
002: * This file is part of "SnipSnap Radeox Rendering Engine".
003: *
004: * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel
005: * All Rights Reserved.
006: *
007: * Please visit http://radeox.org/ for updates and contact.
008: *
009: * --LICENSE NOTICE--
010: * Licensed under the Apache License, Version 2.0 (the "License");
011: * you may not use this file except in compliance with the License.
012: * You may obtain a copy of the License at
013: *
014: * http://www.apache.org/licenses/LICENSE-2.0
015: *
016: * Unless required by applicable law or agreed to in writing, software
017: * distributed under the License is distributed on an "AS IS" BASIS,
018: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
019: * See the License for the specific language governing permissions and
020: * limitations under the License.
021: * --LICENSE NOTICE--
022: */
023: package org.radeox.test.macro;
024:
025: import junit.framework.Test;
026: import junit.framework.TestSuite;
027:
028: import org.radeox.EngineManager;
029: import org.radeox.api.engine.RenderEngine;
030:
031: public class LinkMacroTest extends MacroTestSupport {
032: public RenderEngine engine;
033:
034: public LinkMacroTest(String name) {
035: super (name);
036: engine = EngineManager.getInstance();
037:
038: }
039:
040: public static Test suite() {
041: return new TestSuite(LinkMacroTest.class);
042: }
043:
044: // public void testFile() {
045: // String result =
046: // EngineManager.getInstance().render("{link:Test|c:\\some\\file}",
047: // context);
048: // assertEquals("<a href=\"\"></a>", result);
049: // }
050:
051: public void testSimpleLink() {
052: String result = engine.render("{link:TEST|http://foo.com/}",
053: context);
054: assertEquals(
055: "<span class=\"nobr\"><a href=\"http://foo.com/\">TEST</a></span>",
056: result);
057: }
058:
059: public void testSimpleLinkWithoutName() {
060: String result = engine
061: .render("{link:http://foo.com/}", context);
062: assertEquals(
063: "<span class=\"nobr\"><a href=\"http://foo.com/\">http://foo.com/</a></span>",
064: result);
065: }
066:
067: public void testCorrectEndWithSpace() {
068: String result = engine.render("{link:TEST|http://foo.com/} ",
069: context);
070: assertEquals(
071: "<span class=\"nobr\"><a href=\"http://foo.com/\">TEST</a></span> ",
072: result);
073: }
074:
075: public void testCorrectEndWithComma() {
076: String result = engine.render("{link:TEST|http://foo.com/},",
077: context);
078: assertEquals(
079: "<span class=\"nobr\"><a href=\"http://foo.com/\">TEST</a></span>,",
080: result);
081: }
082:
083: public void testCorrectEndWithSpaceAndComma() {
084: String result = engine.render("{link:TEST|http://foo.com/} ,",
085: context);
086: assertEquals(
087: "<span class=\"nobr\"><a href=\"http://foo.com/\">TEST</a></span> ,",
088: result);
089: }
090:
091: public void testSimpleLinkWithoutNameAndComma() {
092: String result = engine.render("{link:http://foo.com/},",
093: context);
094: assertEquals(
095: "<span class=\"nobr\"><a href=\"http://foo.com/\">http://foo.com/</a></span>,",
096: result);
097: }
098:
099: public void testLinkWithAmpersand() {
100: String result = engine
101: .render(
102: "{link:test|http://foo.com/foo.cgi?test=aaa&test1=bbb},",
103: context);
104: assertEquals(
105: "<span class=\"nobr\"><a href=\"http://foo.com/foo.cgi?test=aaa&test1=bbb\">test</a></span>,",
106: result);
107: }
108:
109: }
|