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;
024:
025: import java.io.IOException;
026: import java.io.StringWriter;
027:
028: import junit.framework.Test;
029: import junit.framework.TestCase;
030: import junit.framework.TestSuite;
031:
032: import org.radeox.EngineManager;
033: import org.radeox.api.engine.RenderEngine;
034: import org.radeox.api.engine.context.RenderContext;
035: import org.radeox.engine.BaseRenderEngine;
036: import org.radeox.engine.context.BaseRenderContext;
037: import org.radeox.test.filter.mock.MockWikiRenderEngine;
038:
039: public class BaseRenderEngineTest extends TestCase {
040: RenderContext context;
041:
042: public BaseRenderEngineTest(String name) {
043: super (name);
044: }
045:
046: protected void setUp() throws Exception {
047: context = new BaseRenderContext();
048: super .setUp();
049: }
050:
051: public static Test suite() {
052: return new TestSuite(BaseRenderEngineTest.class);
053: }
054:
055: public void testBoldInList() {
056: RenderEngine engine = EngineManager.getInstance();
057: assertEquals(
058: "\n <ul class=\"minus\">\n <li>\n<b class=\"bold\">test</b></li></ul>\n",
059: engine.render("- __test__", context));
060: }
061:
062: public void testRenderEngine() {
063: String result = EngineManager.getInstance()
064: .render("__SnipSnap__ {link:Radeox|http://radeox.org}",
065: context);
066: assertEquals(
067: "\n <b class=\"bold\">SnipSnap</b> {link:Radeox|<span class=\"nobr\">\n"
068: + " <a href=\"http://radeox.org\" target=\"rwikiexternal\">http://radeox.org</a></span>}",
069: result);
070: }
071:
072: public void testEmpty() {
073: String result = EngineManager.getInstance().render("", context);
074: assertEquals("", result);
075: }
076:
077: public void testDefaultEngine() {
078: RenderEngine engine = EngineManager.getInstance();
079: RenderEngine engineDefault = EngineManager
080: .getInstance(EngineManager.DEFAULT);
081: assertEquals(engine.getName(), engineDefault.getName());
082: }
083:
084: public void testWriter() {
085: RenderEngine engine = new BaseRenderEngine();
086: StringWriter writer = new StringWriter();
087: try {
088: engine.render(writer, "__SnipSnap__", context);
089: } catch (IOException e) {
090: // never reach
091: }
092: assertEquals("BaseRenderEngine writes to Writer",
093: "\n <b class=\"bold\">SnipSnap</b>", writer
094: .toString());
095: }
096:
097: public void testFilterOrder() {
098: RenderEngine engine = EngineManager.getInstance();
099: context.setRenderEngine(new MockWikiRenderEngine());
100: assertEquals("'<link>' - '<link>'", engine.render(
101: "[<link>]", context));
102: }
103:
104: public void testParagraphTest() {
105: RenderEngine engine = EngineManager.getInstance();
106: context.setRenderEngine(new MockWikiRenderEngine());
107: assertEquals("Some <b class=\"bold\">Simple</b> Content",
108: engine.render("Some __Simple__ Content", context));
109: context.setRenderEngine(new MockWikiRenderEngine());
110: assertEquals(
111: "\n <p class=\"paragraph\">Some</p>\n <p class=\"paragraph\"> <b class=\"bold\">Simple</b> Content</p>",
112: engine.render("Some\n\n __Simple__ Content", context));
113:
114: }
115: }
|