⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classicfiltertest.java

📁 jsp写的wiki.比较新
💻 JAVA
字号:
package tests;

import java.util.*;

import org.stringtree.factory.memory.MapStringRepository;
import org.stringtree.util.ResourceUtils;

import com.efsol.friki.*;

public class ClassicFilterTest extends FilterTest
{
	MapStringRepository context;
	Map remoteNames;

	public ClassicFilterTest(String name)
	{
		super(name);
	}

	public void setUp()
	{
		super.setUp();
		
		context = new MapStringRepository();

		remoteNames = new HashMap();
		remoteNames.put("ALife", "http://news.alife.org/wiki/index.php?");
		remoteNames.put("Wiki", "http://c2.com/cgi/wiki?");

		setFilter(new ClassicToHTMLFilter(context, rep, remoteNames, ResourceUtils.readResource("wiki.transform")));
	}

	public void testPlainText()
	{
		check("ClassicFilterTest.plain text 1", "hello, there",
			"hello, there");

		check("ClassicFilterTest.plain text 2", "then run c:\\bin\\rsync.exe",
			"then run c:\\bin\\rsync.exe");
	}

	public void testItalics()
	{
		check("ClassicFilterTest.italic 1", "uh<i>hello</i> there",
			"uh''hello'' there");
	}

	public void testBold()
	{
		check("ClassicFilterTest.bold 1", "uh<b>hello</b> there",
			"uh'''hello''' there");
	}

	public void testBoldItalic()
	{
		check("ClassicFilterTest.bolditalic 1", "uh<i><b>hello</b></i> there",
			"uh'''''hello''''' there");

		check("ClassicFilterTest.bolditalic 2", "uh<i>hum<b>hello</b></i> there",
			"uh''hum'''hello''''' there");
	}

	public void testRuler()
	{
		check("ClassicFilterTest.ruler 1", "\n<hr/>",
			"----");

		check("ClassicFilterTest.ruler 2", "\n<hr/>",
			"-----");

		check("ClassicFilterTest.ruler 3", "\n<hr/>",
			"------");

		check("ClassicFilterTest.ruler 4", "---",
			"---");
	}

	public void testExternalLinks()
	{
		check("ClassicFilterTest.ext 1",
			"<a href='http://www.efsol.com/'>http://www.efsol.com/</a>",
			"http://www.efsol.com/");

		check("ClassicFilterTest.ext 2",
			"<a href='http://www.efsol.com/friki?JustLink'>http://www.efsol.com/friki?JustLink</a>",
			"http://www.efsol.com/friki?JustLink");

		check("ClassicFilterTest.ext 3",
			"<a href='mailto:test@efsol.com'>mailto:test@efsol.com</a>",
			"mailto:test@efsol.com");

		check("ClassicFilterTest.ext 4",
			"<a href='mailto:test@efsol.gif'>mailto:test@efsol.gif</a>",
			"mailto:test@efsol.gif");

		check("ClassicFilterTest.ext 5",
			"<a href='mailto:test@172.16.1.254'>mailto:test@172.16.1.254</a>",
			"mailto:test@172.16.1.254");

		check("ClassicFilterTest.ext 6",
			"<a href='http://www.efsol.com/friki?JustLink&x=2'>http://www.efsol.com/friki?JustLink&x=2</a>.",
			"http://www.efsol.com/friki?JustLink&x=2.");

		check("ClassicFilterTest.ext 7",
			"<b><a href='http://www.efsol.com/friki?JustLink&x=2'>http://www.efsol.com/friki?JustLink&x=2</a></b>",
			"'''http://www.efsol.com/friki?JustLink&x=2'''");

		check("ClassicFilterTest.ext 8",
			"<a href='http://www.efsol.com/FrankCarver.html'>http://www.efsol.com/FrankCarver.html</a>",
			"http://www.efsol.com/FrankCarver.html");
	}

	public void testInlinedLinks()
	{
		check("ClassicFilterTest.inlined 1",
			"<img src='http://www.efsol.com/images/efsol-logo.gif'/>",
			"http://www.efsol.com/images/efsol-logo.gif");

		check("ClassicFilterTest.inlined 2",
			"<img src='ftp://www.efsol.com/images/efsol-logo.jpg'/>",
			"ftp://www.efsol.com/images/efsol-logo.jpg");

		check("ClassicFilterTest.inlined 3",
			"<img src='http://www.efsol.com/images/efsol-logo.gif?ugh=x'/>",
			"http://www.efsol.com/images/efsol-logo.gif?ugh=x");
	}

	public void testUnorderedList()
	{
		check("ClassicFilterTest.unordered 1", "\n<ul>\n<li>first</li>\n<li>second</li>\n</ul>\n",
			"\t* first\n\t*second\n");

		check("ClassicFilterTest.unordered 2", "\n<ul>\n<li>first</li>\n<li>second</li>\n</ul>\nmore stuff",
			"\t* first\n\t*second\nmore stuff");

		check("ClassicFilterTest.unordered 3", "\n<ul>\n<li>first</li>\n<li>second</li>\n</ul>\nmore stuff",
			"\t* first\r\n\t*second\r\nmore stuff");

		check("ClassicFilterTest.unordered 4", "JustLink<a href='edit?JustLink'>?</a>\n\n<ul>\n<li>first</li>\n<li>second</li>\n</ul>\nmore stuff",
			"JustLink\n\t* first\r\n\t*second\r\nmore stuff");

		check("ClassicFilterTest.unordered 5", "\n<ul>\n<li>first</li>\n<li>second</li>\n</ul>\n<pre>abc\ndef</pre>",
			"\t* first\n\t*second\n abc\n def");

		check("ClassicFilterTest.unordered 6", "\n\t*\n<ul>\n<li> </li>\n</ul>\n",
			"\t*\n\t* \n");
	}

	public void testOrderedList()
	{
		check("ClassicFilterTest.ordered 1", "\n<ol>\n<li>first</li>\n<li>second</li>\n</ol>\n",
			"\t1 first\n\t1second\n");

		check("ClassicFilterTest.ordered 1", "\n<ol>\n<li>first</li>\n<li>second</li>\n</ol>\n",
			"        1 first\n        1second\n");

		check("ClassicFilterTest.ordered 1", "\n<ol>\n<li>first</li>\n<li>second</li>\n</ol>\n",
			"        1. first\n        1second\n");

		check("ClassicFilterTest.ordered 2", "\n<ol>\n<li>first</li>\n<li>second</li>\n</ol>\nmore stuff",
			"\t1 first\n\t1second\nmore stuff");

		check("ClassicFilterTest.ordered 3", "\n<ol>\n<li>first</li>\n<li>second</li>\n</ol>\nmore stuff",
			"\t1 first\r\n\t1second\r\nmore stuff");
	}

	public void testMixedList()
	{
		check("ClassicFilterTest.mixed 1", "\n<ol>\n<li>first</li>\n</ol>\n<ul>\n<li>second</li>\n</ul>\n",
			"\t1 first\n\t*second\n");

		check("ClassicFilterTest.mixed 2", "\n<ul>\n<li>first unordered element</li>\n<li>second unordered element</li>\n</ul>\n<ol>\n<li>third ordered element</li>\n</ol>\n",
			"\t* first unordered element\n\t* second unordered element\n\t1 third ordered element");
	}

	public void testMonospace()
	{
		check("ClassicFilterTest.monospace 1", "<pre>uh<i>hello</i> there</pre>",
			" uh''hello'' there");

		check("ClassicFilterTest.monospace 2", "<pre>uh\n  there\n  too</pre>",
			" uh\n   there\n   too");

		check("ClassicFilterTest.monospace 3", "<pre>uh\n  there\n  too</pre>",
			" uh\r\n   there\r\n   too");

		check("ClassicFilterTest.monospace 4", "\n<pre>uh\n  there\n  too</pre>",
			"\n uh\r\n   there\r\n   too");
	}

	public void testISBN()
	{
		check("ClassicFilterTest.isbn 1",
			"<a href='http://www.amazon.com/exec/obidos/ASIN/047120708X/efficacysolut-20'>ISBN 047120708X</a>",
			"ISBN 047120708X");

		check("ClassicFilterTest.isbn 2",
			"<a href='http://www.amazon.com/exec/obidos/ASIN/047120708X/efficacysolut-20'>ISBN 047120708X</a>",
			"[ISBN 047120708X]");

		check("ClassicFilterTest.isbn 3",
			"<a href='http://www.amazon.com/exec/obidos/ASIN/047120708X/efficacysolut-20'>ISBN 047120708X</a>",
			"[ ISBN 047120708X]");

		check("ClassicFilterTest.isbn 4",
			"<a href='http://www.amazon.com/exec/obidos/ASIN/047120708X/efficacysolut-20'>ISBN 047120708X</a>",
			"[ ISBN 047120708X ]");

		check("ClassicFilterTest.isbn 5",
			"<a href='http://www.amazon.com/exec/obidos/ASIN/047120708X/efficacysolut-20'>ISBN 047120708X</a>",
			"ISBN: 047120708X");

		check("ClassicFilterTest.isbn 6",
			"<a href='http://www.amazon.com/exec/obidos/ASIN/047120708X/efficacysolut-20'>ISBN 047120708X</a>",
			"[ISBN: 047120708X]");

		check("ClassicFilterTest.isbn 7",
			"<a href='http://www.amazon.com/exec/obidos/ASIN/047120708X/efficacysolut-20'>ISBN 047120708X</a>",
			"[ ISBN: 047120708X]");

		check("ClassicFilterTest.isbn 8",
			"<a href='http://www.amazon.com/exec/obidos/ASIN/047120708X/efficacysolut-20'>ISBN 047120708X</a>",
			"[ ISBN: 047120708X ]");

		check("ClassicFilterTest.isbn 9",
			"<a href='http://www.amazon.com/exec/obidos/ASIN/047120708X/efficacysolut-20'>ISBN 047-120-708-X</a>",
			"ISBN 047-120-708-X");

		check("ClassicFilterTest.isbn 10",
			"prefix <a href='http://www.amazon.com/exec/obidos/ASIN/047120708X/efficacysolut-20'>ISBN 047-120-708-X</a> hello",
			"prefix ISBN 047-120-708-X hello");

		check("ClassicFilterTest.isbn 11",
			"prefix <a href='http://www.amazon.com/exec/obidos/ASIN/047120708X/efficacysolut-20'>ISBN 047-120-708-X</a> hello",
			"prefix [ISBN 047-120-708-X] hello");

		check("ClassicFilterTest.isbn 12",
			"prefix <a href='http://www.amazon.com/exec/obidos/ASIN/047120708X/efficacysolut-20'>ISBN 047-120-708-X</a> hello",
			"prefix [ ISBN 047-120-708-X ] hello");
	}

	public void testJustLink()
	{
		check("ClassicFilterTest.just link 1.1", "JustLink<a href='edit?JustLink'>?</a>",
			"JustLink");

		check("ClassicFilterTest.just link 1.2", "Just<b></b>Link",
			"Just''''''Link");

		check("ClassicFilterTest.just link 1.3", "a JustLink<a href='edit?JustLink'>?</a>",
			"a JustLink");

		check("ClassicFilterTest.just link 1.4", "a JustLink<a href='edit?JustLink'>?</a> ",
			"a JustLink ");

		check("ClassicFilterTest.just link 1.5",
		"JustLink<a href='edit?JustLink'>?</a>\nAnotherLink<a href='edit?AnotherLink'>?</a>\nThirdLink<a href='edit?ThirdLink'>?</a>",
			"JustLink\nAnotherLink\nThirdLink");

		rep.put("JustLink", new Page("JustLink"));
		check("ClassicFilterTest.just link 2", "<a href='view?JustLink'>JustLink</a>",
			"JustLink");

		check("ClassicFilterTest.just link 3", "Just",
			"Just");

		check("ClassicFilterTest.just link 4", "JustL",
			"JustL");

		check("ClassicFilterTest.just link 5", "JustLI",
			"JustLI");

		check("ClassicFilterTest.just link 6", "JustLinkI",
			"JustLinkI");

		check("ClassicFilterTest.just link 7", "(<a href='view?JustLink'>JustLink</a>)",
			"(JustLink)");

	}

	public void testInterwikiLinks()
	{
		check("ClassicFilterTest.interwiki 1",
			"<a href='http://news.alife.org/wiki/index.php?HoopyFrood'>ALife:HoopyFrood</a>",
			"ALife:HoopyFrood");

		check("ClassicFilterTest.interwiki 2",
			"<a href='http://c2.com/cgi/wiki?FrankCarver'>Wiki:FrankCarver</a>",
			"Wiki:FrankCarver");

		check("ClassicFilterTest.interwiki 3",
			"NotAnotherWiki:FrankCarver",
			"NotAnotherWiki:FrankCarver");
	}

	public void testDefList()
	{
		check("ClassicFilterTest.deflist 1", "<dl>\n\t<dt>first</dt><dd>second</dd>\n</dl>\n",
			"\tfirst:\tsecond\n");

		check("ClassicFilterTest.deflist 2",
			"<dl>\n"+
			"\t<dt>first term</dt><dd>This is first definition.</dd>\n" +
			"\t<dt>second term</dt><dd>This is the second definition.</dd>\n" +
			"</dl>\n",
			"\tfirst term:\tThis is first definition.\n\tsecond term:\tThis is the second definition.\n");

		check("ClassicFilterTest.deflist 3",
			"<dl>\n"+
			"\t<dt>first term</dt><dd>This is first definition.</dd>\n" +
			"\t<dt>second term</dt><dd>This is the second definition.</dd>\n" +
			"</dl>\n",
			"\tfirst term:\tThis is first definition.\r\n\tsecond term:\tThis is the second definition.\r\n");
	}

	public void testIndents()
	{
		check("ClassicFilterTest.indent 1", "\n<ol>\n<ol>\n<li>first</li>\n</ol>\n</ol>\n",
			"\t\t1 first\n");

		check("ClassicFilterTest.indent 2", "\n<ul>\n<li>hello</li>\n<ol>\n<li>first</li>\n</ol>\n</ul>\n",
			"\t*hello\n\t\t1 first\n");

		check("ClassicFilterTest.indent 3", "\n<ul>\n<li>hello</li>\n<ul>\n<li>first</li>\n</ul>\n</ul>\n",
			"\t*hello\n\t\t*first\n");

		check("ClassicFilterTest.indent 3", "\n<ul>\n<li>hello</li>\n<ul>\n<li>first</li>\n</ul>\n</ul>\n",
			"        *hello\n                *first\n");
	}


	public void testTable()
	{
		check("ClassicFilterTest.table 1", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\n<tr><td>hello</td></tr>\n</table>",
			"|hello|");

		check("ClassicFilterTest.table 2", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\n<tr><td>hello</td></tr>\n<tr><td>there</td></tr>\n</table>",
			"|hello|\n|there|");

		check("ClassicFilterTest.table 3", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\n<tr><td>hello</td><td>there</td></tr>\n</table>",
			"|hello|there|");

		check("ClassicFilterTest.table 4", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\n<tr><td>hello</td><td>world</td></tr>\n<tr><td>there</td><td>their</td></tr>\n</table>",
			"|hello|world|\n|there|their|");

		check("ClassicFilterTest.table 5", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\n<tr><td colspan='4'>hello</td></tr>\n</table>",
			"|hello||  |\t |");

		check("ClassicFilterTest.table 6", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\n<tr><td colspan='2'>hello</td></tr>\n<tr><td>there</td><td>their</td></tr>\n</table>",
			"|hello| |\n|there|their|");

		check("ClassicFilterTest.table 7", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\n<tr><td colspan='2'>hello</td></tr>\n</table>",
			"||hello|");

		check("ClassicFilterTest.table 7a", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\n<tr><td colspan='3'>hello</td></tr>\n</table>",
			"||hello||");

		check("ClassicFilterTest.table 8", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\n<tr><td>hello</td><td>world</td></tr>\n<tr><td>there</td><td>their</td></tr>\n</table>"+
			"\n<p/>\n<table BORDER CELLSPACING='0' CELLPADDING='3'>\n<tr><td>hello</td><td>world</td></tr>\n<tr><td>there</td><td>their</td></tr>\n</table>",
			"|hello|world|\n|there|their|\n\n|hello|world|\n|there|their|");

		check("ClassicFilterTest.table 9", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\n<tr><td>hello</td></tr>\n<tr><td>there</td></tr>\n</table>",
			"|hello|  \t \n|there|");

		check("ClassicFilterTest.table 10", "hello\n<table BORDER CELLSPACING='0' CELLPADDING='3'>\n<tr><td>hello</td></tr>\n</table>",
			"hello\n|hello|");

		check("ClassicFilterTest.table 11", "whoopee\n<table BORDER CELLSPACING='0' CELLPADDING='3'>\n<tr><td>hello</td></tr>\n</table>\ndoo",
			"whoopee\n|hello|\ndoo");

	}

	public void testBlock()
	{
		check("ClassicFilterTest.block 1", "<pre>first\nsecond  \nthird</pre>",
			"[\nfirst\nsecond  \nthird\n]");

		check("ClassicFilterTest.block 2", "aa <pre>first\nsecond  \nthird</pre>bb",
			"aa [\nfirst\nsecond  \nthird\n]bb");

		check("ClassicFilterTest.block double", "aa\n<pre>first\nsecond  \nthird</pre>\nbb\n<pre>first\nsecond  \nthird</pre>",
			"aa\n[\r\nfirst\r\nsecond  \r\nthird\r\n]\r\nbb\r\n[\r\nfirst\r\nsecond  \r\nthird\r\n]");

		check("ClassicFilterTest.block spacey 1", "aa\n<pre>\nfirst</pre>",
			"aa\n[\n\nfirst\n]");

		check("ClassicFilterTest.block spacey 2", "aa\n<pre>first\n</pre>",
			"aa\n[\nfirst\n\n]");

		check("ClassicFilterTest.block spacey 3", "aa\n<pre>\nfirst\n</pre>",
			"aa\n[\n\nfirst\n\n]");

		check("ClassicFilterTest.block spacey 4", "aa\n<pre>\nfirst\n\nsecond</pre>",
			"aa\n[\n\nfirst\n\nsecond\n]");
	}

	public void testBlockTable()
	{
		check("ClassicFilterTest.blocktable 1", 
			"<table BORDER CELLSPACING='0' CELLPADDING='3'>\n<tr><td><pre>first\nsecond  \nthird</pre></td></tr>\n</table>",
			"|[\nfirst\nsecond  \nthird\n]|");

		check("ClassicFilterTest.blocktable 2", 
			"<table BORDER CELLSPACING='0' CELLPADDING='3'>\n<tr><td colspan='2'><pre>first\nsecond  \nthird</pre></td></tr>\n</table>",
			"||[\nfirst\nsecond  \nthird\n]|");
	}
	
	public void testDollarProtection()
	{
		check("ClassicFilterTest.dollar 1", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\n<tr><td>$</td></tr>\n</table>",
			"|$|");
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -