📄 filtertest.java
字号:
package 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");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -