[hmath-commits] org.hmath.server/WEB-INF/src/org/hartmath/server/test/filter WikipediaFilterTest.jav
Status: Pre-Alpha
Brought to you by:
jsurfer
|
From: <js...@us...> - 2004-03-09 20:38:32
|
Update of /cvsroot/hmath/org.hmath.server/WEB-INF/src/org/hartmath/server/test/filter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21210/WEB-INF/src/org/hartmath/server/test/filter Added Files: WikipediaFilterTest.java ParserFilterTest.java Log Message: initial version --- NEW FILE: WikipediaFilterTest.java --- /* * This file is part of the "HMath MathML BLOG/Wiki Engine". * * Copyright (c) 2004 Klaus Hartlage All Rights Reserved. * * Please visit http://www.hmath.org/ for updates and contact. * * --LICENSE NOTICE-- This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser * General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any * later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --LICENSE NOTICE-- */ package org.hartmath.server.test.filter; import junit.framework.Test; import junit.framework.TestSuite; import org.hartmath.server.filter.WikipediaFilter; import org.radeox.test.filter.FilterTestSupport; public class WikipediaFilterTest extends FilterTestSupport { public WikipediaFilterTest(String name) { super(name); } protected void setUp() throws Exception { filter = new WikipediaFilter(); super.setUp(); } public static Test suite() { return new TestSuite(WikipediaFilterTest.class); } public void testParser() { assertEquals( "test <span class=\"nobr\"><a href=\"http://www.hmath.org\">http://www.hmath.org</a></span><br/><span class=\"nobr\"><a href=\"http://www.hmath.org\">http://www.hmath.org</a></span>", filter.filter("test http://www.hmath.org<br/>http://www.hmath.org", context)); assertEquals("asssřzzz", filter.filter("asssřzzz", context)); assertEquals("a>b", filter.filter("a>b", context)); assertEquals("abc&#12345678;fgh", filter.filter("abc�fgh", context)); assertEquals("〹", filter.filter("〹", context)); assertEquals("<h2><a name=\"test_head\"> test head </a></h2>", filter.filter("== test head ==", context)); assertEquals("hhhhw\n<h3><a name=\"test_head_2\"> test head 2 </a></h3>", filter.filter("hhhhw\n=== test head 2 ===", context)); assertEquals( "<em>em test</em> <strong>strong test</strong>", filter.filter("''em test'' '''strong test'''", context)); // no wiki engine instance so give back only the scanned macro in these tests assertEquals("{macro}", filter.filter("{macro}", context)); // no wiki engine instance so give back only the scanned name assertEquals("about wikis", filter.filter("[[about wikis]]", context)); assertEquals("about wikis", filter.filter("[about wikis]", context)); // in these tests we don't handle links an dmacros: assertEquals("snipsnap-help", filter.filter("[snipsnap-help]", context)); assertEquals( "<ol class=\"roman\"><li>one\n<ol class=\"roman\"><li>two</li>\n</ol>\n</li>\n</ol>", filter.filter("i. one\nii. two", context).trim()); assertEquals("<ol><li>red\n</li><li>green</li>\n</ol>", filter.filter("1. red\n1. green", context).trim()); assertEquals( "<ul class=\"star\"><li>l1\n<ul class=\"star\"><li>l2</li>\n</ul>\n</li>\n</ul>", filter.filter("*l1\n**l2", context).trim()); // assertEquals("<strike class=\"strike\">test </strike>", filter.filter("--test --", context)); assertEquals("hello - brave gnu world", filter.filter("hello - brave gnu world", context)); assertEquals("<ul class=\"star\"><li>l1\n</li><li>l2</li>\n</ul>", filter.filter("*l1\n*l2", context).trim()); assertEquals( "<i class=\"italic\">italic <b class=\"bold\">bold <u class=\"underline\">underline</u></b></i>", filter.filter("<i>italic <B>bold <u>underline", context)); assertEquals("<hr class=\"line\"/>\r\n<hr class=\"line\"/>", filter.filter("<Hr>\r\n<hR/>", context)); assertEquals("<br/>\r\n<br/>", filter.filter("<br>\r\n<br/>", context)); assertEquals("<h1 class=\"h1\">hh</h1>", filter.filter("<h1>hh</h1>", context)); assertEquals("<strike class=\"strike\">test </strike>", filter.filter("<strike>test </strike>", context)); assertEquals( "<i class=\"italic\">italic</i> <b class=\"bold\">bold</b> <u class=\"underline\">underline</u>", filter.filter("<i>italic</i> <B>bold</B> <u>underline</u>", context)); assertEquals( "<i class=\"italic\">em test</i> <b class=\"bold\"> strong test</b>", filter.filter("~~em test~~ __ strong test__", context)); assertEquals( "<sub class=\"sub\">subtest</sub> <sup class=\"sup\">suppenTest</sup>", filter.filter("<sub>subtest</sub> <sup>suppenTest</sup>", context)); assertEquals( "<i class=\"italic\">em test</i> <b class=\"bold\"> strong test</b>", filter.filter("<em>em test</em> <strong> strong test</strong>", context)); assertEquals("__ and ~~", filter.filter("\\_\\_ and \\~\\~", context)); ((WikipediaFilter) filter).setContext(context); assertEquals( "field:expr|<expr>|snipsnap-eval|Evaluate", ((WikipediaFilter) filter).parseParameters("field:expr|$expr|snipsnap-eval|Evaluate")); } } //1 Welcome to SnipSnap {anchor:Welcome to SnipSnap}\\ //You can now login and add/edit your first post. There is a __post blog__ link //in the menu bar. For help with formatting your post take a look at //[snipsnap-help]. To create a link to a page on your site surround a word with //\[ and \]. Putting \_\_ around a phrase makes it __bold__ and putting \~\~ //around it makes the phrase ~~italics~~. You can create links to the internet //by just writing the url like http://snipsnap.org or by using \{link:Name|url\}. //So \{link:SnipSnap|\http://snipsnap.org\} produces //{link:SnipSnap|http://snipsnap.org}. Have fun. // //Pinging weblogs.com may be turned on. The //{link:FAQ|http://snipsnap.org/space/FAQ} explains how to turn this on or off. // //<i>italic</i> <b>bold</b> <u>underline</u> //<sub>subtest</sub> <sup>suppenTest</sup> //<h1>Header 1</h1> //<em>em test</em> <strong> strong test</strong> // //{mml}D[Sin[x],x]{mml} // //<br> //<br/> //<hr> //<hr/> --- NEW FILE: ParserFilterTest.java --- /* * This file is part of "SnipSnap Radeox Rendering Engine". * * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel * All Rights Reserved. * * Please visit http://radeox.org/ for updates and contact. * * --LICENSE NOTICE-- * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * --LICENSE NOTICE-- */ package org.hartmath.server.test.filter; import junit.framework.Test; import junit.framework.TestSuite; import org.hartmath.server.filter.ParserFilter; import org.radeox.test.filter.FilterTestSupport; public class ParserFilterTest extends FilterTestSupport { public ParserFilterTest(String name) { super(name); } protected void setUp() throws Exception { filter = new ParserFilter(); super.setUp(); } public static Test suite() { return new TestSuite(ParserFilterTest.class); } public void testParser() { assertEquals("<ol class=\"roman\"><li>one\n<ol class=\"roman\"><li>two</li>\n</ol>\n</li>\n</ol>", filter.filter("i. one\nii. two", context).trim()); assertEquals("<ol><li>red\n</li><li>green</li>\n</ol>", filter.filter("1. red\n1. green", context).trim()); assertEquals("<ul class=\"star\"><li>l1\n<ul class=\"star\"><li>l2</li>\n</ul>\n</li>\n</ul>", filter.filter("* l1\n** l2", context).trim()); assertEquals("<strike class=\"strike\">test </strike>", filter.filter("--test --", context)); assertEquals("hello - brave gnu world", filter.filter("hello - brave gnu world", context)); assertEquals("<ul class=\"star\"><li>l1\n</li><li>l2</li>\n</ul>", filter.filter("* l1\n* l2", context).trim()); assertEquals("<i class=\"italic\">italic <b class=\"bold\">bold <u class=\"underline\">underline</u></b></i>", filter.filter("<i>italic <B>bold <u>underline", context)); assertEquals("<hr class=\"line\"/>\r\n<hr class=\"line\"/>", filter.filter("<Hr>\r\n<hR/>", context)); assertEquals("<br/>\r\n<br/>", filter.filter("<br>\r\n<br/>", context)); assertEquals("<h1 class=\"h1\">hh</h1>", filter.filter("<h1>hh</h1>", context)); assertEquals("<strike class=\"strike\">test </strike>", filter.filter("<strike>test </strike>", context)); assertEquals("<i class=\"italic\">italic</i> <b class=\"bold\">bold</b> <u class=\"underline\">underline</u>", filter.filter("<i>italic</i> <B>bold</B> <u>underline</u>", context)); assertEquals("<i class=\"italic\">em test</i> <b class=\"bold\"> strong test</b>", filter.filter("~~em test~~ __ strong test__", context)); assertEquals("<sub class=\"sub\">subtest</sub> <sup class=\"sup\">suppenTest</sup>", filter.filter("<sub>subtest</sub> <sup>suppenTest</sup>", context)); assertEquals("<i class=\"italic\">em test</i> <b class=\"bold\"> strong test</b>", filter.filter("<em>em test</em> <strong> strong test</strong>", context)); assertEquals("__ and ~~", filter.filter("\\_\\_ and \\~\\~", context)); // in these tests we don't handle links an dmacros: assertEquals("[snipsnap-help]", filter.filter("[snipsnap-help]", context)); assertEquals("{macro}", filter.filter("{macro}", context)); assertEquals("{mml}D[Sin[x],x]{mml}", filter.filter("{mml}D[Sin[x],x]{mml}", context)); ((ParserFilter)filter).setContext(context); assertEquals("field:expr|<expr>|snipsnap-eval|Evaluate", ((ParserFilter)filter).parseParameters("field:expr|$expr|snipsnap-eval|Evaluate") ); } } //1 Welcome to SnipSnap {anchor:Welcome to SnipSnap}\\ //You can now login and add/edit your first post. There is a __post blog__ link //in the menu bar. For help with formatting your post take a look at //[snipsnap-help]. To create a link to a page on your site surround a word with //\[ and \]. Putting \_\_ around a phrase makes it __bold__ and putting \~\~ //around it makes the phrase ~~italics~~. You can create links to the internet //by just writing the url like http://snipsnap.org or by using \{link:Name|url\}. //So \{link:SnipSnap|\http://snipsnap.org\} produces //{link:SnipSnap|http://snipsnap.org}. Have fun. // //Pinging weblogs.com may be turned on. The //{link:FAQ|http://snipsnap.org/space/FAQ} explains how to turn this on or off. // //<i>italic</i> <b>bold</b> <u>underline</u> //<sub>subtest</sub> <sup>suppenTest</sup> //<h1>Header 1</h1> //<em>em test</em> <strong> strong test</strong> // //{mml}D[Sin[x],x]{mml} // //<br> //<br/> //<hr> //<hr/> |