|
Friki example source code file (FilterTest.java)
The Friki FilterTest.java source codepackage tests; import java.io.*; import junit.framework.*; import com.efsol.friki.*; public class FilterTest extends TestCase { protected PageRepository rep; protected ContentFilter filter; public FilterTest(String name) { super(name); } public void setUp() { rep = new PageRepository(new InMemoryRepository()); } protected void setFilter(ContentFilter filter) { this.filter = filter; } protected String convert(String content) { StringWriter out = new StringWriter(); try { filter.filter(new StringReader(content), out); } catch(IOException ioe) { ioe.printStackTrace(); } return out.toString(); } protected void check(String name, String expected, String source, boolean log) { String result = convert(source); if (log) { System.out.println(name + ":\n '" + source + "'->'" + result + "' expected (" + expected + ")"); } assertEquals(name, expected, result); } protected void check(String name, String expected, String source) { check(name, expected, source, false); } public void testEmpty() { check("FilterTest.empty 1", "", ""); } public void testOneLine() { check("FilterTest.oneline 1", "hello", "hello"); } public void testTwoLines() { check("FilterTest.twolines 1", "hello\nthere", "hello\nthere"); } public void testTwoParagraphs() { check("FilterTest.twoparas 1", "hello\n<p/>\nthere", "hello\n\nthere"); check("FilterTest.twoparas 2", "hello\n<p/>\nthere", "hello\n \nthere"); check("FilterTest.twoparas 3", "hello\n<p/>\nthere", "hello\r\n\r\nthere"); } public void testLT() { check("FilterTest.lt 1", "a < b", "a < b"); } public void testGT() { check("FilterTest.gt 1", "a > b", "a > b"); } } Other Friki examples (source code examples)Here is a short list of links related to this Friki FilterTest.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
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.