alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  
\n

Friki example source code file (ClassicFilterTest.java)

This example Friki source code file (ClassicFilterTest.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Friki tags/keywords

border, border, cellpadding='3', cellpadding='3', cellspacing='0, cellspacing='0, classicfiltertest, isbn, isbn, just, justlink, justlinki, mapstringrepository, notanotherwiki:frankcarver, util

The Friki ClassicFilterTest.java source code

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 there",
			"uh''hello'' there");
	}

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

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

		check("ClassicFilterTest.bolditalic 2", "uh<i>humhello 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/",
			"http://www.efsol.com/");

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

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

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

		check("ClassicFilterTest.ext 5",
			"<a href='mailto:test@172.16.1.254'>mailto:test@172.16.1.254",
			"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.",
			"http://www.efsol.com/friki?JustLink&x=2.");

		check("ClassicFilterTest.ext 7",
			"<b>http://www.efsol.com/friki?JustLink&x=2",
			"'''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",
			"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
  • first
  • \n
  • second
  • \n\n", "\t* first\n\t*second\n"); check("ClassicFilterTest.unordered 2", "\n<ul>\n
  • first
  • \n
  • second
  • \n\nmore stuff", "\t* first\n\t*second\nmore stuff"); check("ClassicFilterTest.unordered 3", "\n<ul>\n
  • first
  • \n
  • second
  • \n\nmore stuff", "\t* first\r\n\t*second\r\nmore stuff"); check("ClassicFilterTest.unordered 4", "JustLink<a href='edit?JustLink'>?\n\n
      \n
    • first
    • \n
    • second
    • \n
    \nmore stuff", "JustLink\n\t* first\r\n\t*second\r\nmore stuff"); check("ClassicFilterTest.unordered 5", "\n<ul>\n
  • first
  • \n
  • second
  • \n\n
    abc\ndef
    ", "\t* first\n\t*second\n abc\n def"); check("ClassicFilterTest.unordered 6", "\n\t*\n<ul>\n
  • \n\n", "\t*\n\t* \n"); } public void testOrderedList() { check("ClassicFilterTest.ordered 1", "\n<ol>\n
  • first
  • \n
  • second
  • \n\n", "\t1 first\n\t1second\n"); check("ClassicFilterTest.ordered 1", "\n<ol>\n
  • first
  • \n
  • second
  • \n\n", " 1 first\n 1second\n"); check("ClassicFilterTest.ordered 1", "\n<ol>\n
  • first
  • \n
  • second
  • \n\n", " 1. first\n 1second\n"); check("ClassicFilterTest.ordered 2", "\n<ol>\n
  • first
  • \n
  • second
  • \n\nmore stuff", "\t1 first\n\t1second\nmore stuff"); check("ClassicFilterTest.ordered 3", "\n<ol>\n
  • first
  • \n
  • second
  • \n\nmore stuff", "\t1 first\r\n\t1second\r\nmore stuff"); } public void testMixedList() { check("ClassicFilterTest.mixed 1", "\n<ol>\n
  • first
  • \n\n
      \n
    • second
    • \n
    \n", "\t1 first\n\t*second\n"); check("ClassicFilterTest.mixed 2", "\n<ul>\n
  • first unordered element
  • \n
  • second unordered element
  • \n\n
      \n
    1. third ordered element
    2. \n
    \n", "\t* first unordered element\n\t* second unordered element\n\t1 third ordered element"); } public void testMonospace() { check("ClassicFilterTest.monospace 1", "<pre>uhhello there
    ", " uh''hello'' there"); check("ClassicFilterTest.monospace 2", "<pre>uh\n there\n too", " uh\n there\n too"); check("ClassicFilterTest.monospace 3", "<pre>uh\n there\n too", " uh\r\n there\r\n too"); check("ClassicFilterTest.monospace 4", "\n<pre>uh\n there\n too", "\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", "ISBN 047120708X"); check("ClassicFilterTest.isbn 2", "<a href='http://www.amazon.com/exec/obidos/ASIN/047120708X/efficacysolut-20'>ISBN 047120708X", "[ISBN 047120708X]"); check("ClassicFilterTest.isbn 3", "<a href='http://www.amazon.com/exec/obidos/ASIN/047120708X/efficacysolut-20'>ISBN 047120708X", "[ ISBN 047120708X]"); check("ClassicFilterTest.isbn 4", "<a href='http://www.amazon.com/exec/obidos/ASIN/047120708X/efficacysolut-20'>ISBN 047120708X", "[ ISBN 047120708X ]"); check("ClassicFilterTest.isbn 5", "<a href='http://www.amazon.com/exec/obidos/ASIN/047120708X/efficacysolut-20'>ISBN 047120708X", "ISBN: 047120708X"); check("ClassicFilterTest.isbn 6", "<a href='http://www.amazon.com/exec/obidos/ASIN/047120708X/efficacysolut-20'>ISBN 047120708X", "[ISBN: 047120708X]"); check("ClassicFilterTest.isbn 7", "<a href='http://www.amazon.com/exec/obidos/ASIN/047120708X/efficacysolut-20'>ISBN 047120708X", "[ ISBN: 047120708X]"); check("ClassicFilterTest.isbn 8", "<a href='http://www.amazon.com/exec/obidos/ASIN/047120708X/efficacysolut-20'>ISBN 047120708X", "[ ISBN: 047120708X ]"); check("ClassicFilterTest.isbn 9", "<a href='http://www.amazon.com/exec/obidos/ASIN/047120708X/efficacysolut-20'>ISBN 047-120-708-X", "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 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 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 hello", "prefix [ ISBN 047-120-708-X ] hello"); } public void testJustLink() { check("ClassicFilterTest.just link 1.1", "JustLink<a href='edit?JustLink'>?", "JustLink"); check("ClassicFilterTest.just link 1.2", "Just<b>Link", "Just''''''Link"); check("ClassicFilterTest.just link 1.3", "a JustLink<a href='edit?JustLink'>?", "a JustLink"); check("ClassicFilterTest.just link 1.4", "a JustLink<a href='edit?JustLink'>? ", "a JustLink "); check("ClassicFilterTest.just link 1.5", "JustLink<a href='edit?JustLink'>?\nAnotherLink?\nThirdLink?", "JustLink\nAnotherLink\nThirdLink"); rep.put("JustLink", new Page("JustLink")); check("ClassicFilterTest.just link 2", "<a href='view?JustLink'>JustLink", "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)", "(JustLink)"); } public void testInterwikiLinks() { check("ClassicFilterTest.interwiki 1", "<a href='http://news.alife.org/wiki/index.php?HoopyFrood'>ALife:HoopyFrood", "ALife:HoopyFrood"); check("ClassicFilterTest.interwiki 2", "<a href='http://c2.com/cgi/wiki?FrankCarver'>Wiki:FrankCarver", "Wiki:FrankCarver"); check("ClassicFilterTest.interwiki 3", "NotAnotherWiki:FrankCarver", "NotAnotherWiki:FrankCarver"); } public void testDefList() { check("ClassicFilterTest.deflist 1", "<dl>\n\t
    first
    second
    \n\n", "\tfirst:\tsecond\n"); check("ClassicFilterTest.deflist 2", "<dl>\n"+ "\t<dt>first term
    This is first definition.
    \n" + "\t<dt>second term
    This is the second definition.
    \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
    This is first definition.
    \n" + "\t<dt>second term
    This is the second definition.
    \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
      \n
    1. first
    2. \n
    \n\n", "\t\t1 first\n"); check("ClassicFilterTest.indent 2", "\n<ul>\n
  • hello
  • \n
      \n
    1. first
    2. \n
    \n\n", "\t*hello\n\t\t1 first\n"); check("ClassicFilterTest.indent 3", "\n<ul>\n
  • hello
  • \n
      \n
    • first
    • \n
    \n\n", "\t*hello\n\t\t*first\n"); check("ClassicFilterTest.indent 3", "\n<ul>\n
  • hello
  • \n
      \n
    • first
    • \n
    \n\n", " *hello\n *first\n"); } public void testTable() { check("ClassicFilterTest.table 1", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\n
    hello
    ", "|hello|"); check("ClassicFilterTest.table 2", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\nhello\nthere\n", "|hello|\n|there|"); check("ClassicFilterTest.table 3", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\nhellothere\n", "|hello|there|"); check("ClassicFilterTest.table 4", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\nhelloworld\ntheretheir\n", "|hello|world|\n|there|their|"); check("ClassicFilterTest.table 5", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\nhello\n", "|hello|| |\t |"); check("ClassicFilterTest.table 6", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\nhello\ntheretheir\n", "|hello| |\n|there|their|"); check("ClassicFilterTest.table 7", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\nhello\n", "||hello|"); check("ClassicFilterTest.table 7a", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\nhello\n", "||hello||"); check("ClassicFilterTest.table 8", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\nhelloworld\ntheretheir\n"+ "\n<p/>\n\n\n\n
    helloworld
    theretheir
    ", "|hello|world|\n|there|their|\n\n|hello|world|\n|there|their|"); check("ClassicFilterTest.table 9", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\nhello\nthere\n", "|hello| \t \n|there|"); check("ClassicFilterTest.table 10", "hello\n<table BORDER CELLSPACING='0' CELLPADDING='3'>\nhello\n", "hello\n|hello|"); check("ClassicFilterTest.table 11", "whoopee\n<table BORDER CELLSPACING='0' CELLPADDING='3'>\nhello\n\ndoo", "whoopee\n|hello|\ndoo"); } public void testBlock() { check("ClassicFilterTest.block 1", "<pre>first\nsecond \nthird", "[\nfirst\nsecond \nthird\n]"); check("ClassicFilterTest.block 2", "aa <pre>first\nsecond \nthirdbb", "aa [\nfirst\nsecond \nthird\n]bb"); check("ClassicFilterTest.block double", "aa\n<pre>first\nsecond \nthird\nbb\n
    first\nsecond  \nthird
    ", "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", "aa\n[\n\nfirst\n]"); check("ClassicFilterTest.block spacey 2", "aa\n<pre>first\n", "aa\n[\nfirst\n\n]"); check("ClassicFilterTest.block spacey 3", "aa\n<pre>\nfirst\n", "aa\n[\n\nfirst\n\n]"); check("ClassicFilterTest.block spacey 4", "aa\n<pre>\nfirst\n\nsecond", "aa\n[\n\nfirst\n\nsecond\n]"); } public void testBlockTable() { check("ClassicFilterTest.blocktable 1", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\n
    first\nsecond  \nthird
    \n", "|[\nfirst\nsecond \nthird\n]|"); check("ClassicFilterTest.blocktable 2", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\n
    first\nsecond  \nthird
    \n", "||[\nfirst\nsecond \nthird\n]|"); } public void testDollarProtection() { check("ClassicFilterTest.dollar 1", "<table BORDER CELLSPACING='0' CELLPADDING='3'>\n$\n", "|$|"); } }

    Other Friki examples (source code examples)

    Here is a short list of links related to this Friki ClassicFilterTest.java source code file:

    ... this post is sponsored by my books ...

    #1 New Release!

    FP Best Seller

     

    new blog posts

     

    Copyright 1998-2021 Alvin Alexander, alvinalexander.com
    All Rights Reserved.

    A percentage of advertising revenue from
    pages under the /java/jwarehouse URI on this website is
    paid back to open source projects.