📄 jacsonreadertest.java
字号:
package de.spieleck.app.jacson;
import junit.framework.TestCase;
import junit.framework.Test;
import junit.framework.TestSuite;
import java.io.*;
import java.util.*;
/**
* Master test to test Jacson at the plain application level.
*/
public class JacsonReaderTest
extends TestCase
implements JacsonNames, NamesForTesting
{
protected BufferedReader br;
public void setUp()
{
}
public void tearDown()
{
br = null;
}
/**
* Simple application of a Jacson Reader.
*/
public void testReader1()
throws Exception
{
internalTest(basePath+"jacsonReaderTest.conf",
basePath+"jacsonReaderTest.in",
basePath+"jacsonReaderTest.list");
}
/**
* Nested invocation of Jacson Readers.
*/
public void testReader2()
throws Exception
{
Reader r = new InputStreamReader(new FileInputStream(
basePath+"jacsonReaderTest.in"));
JacsonReader jr =new JacsonReader(r ,basePath+"jacsonReaderTest1.conf");
JacsonReader jr2=new JacsonReader(jr,basePath+"jacsonReaderTest2.conf");
stupidDiff(jr2, basePath + "jacsonReaderTest.in");
}
protected void internalTest(String cName, String data, String expected)
throws Exception
{
Reader r = new InputStreamReader(new FileInputStream(data));
JacsonReader jr = new JacsonReader(r, cName);
stupidDiff(jr, expected);
}
protected void stupidDiff(Reader jr, String expected)
throws Exception
{
BufferedReader br = new BufferedReader(jr);
BufferedReader br2 = new BufferedReader(new InputStreamReader(
new FileInputStream(expected)));
String l1 = null;
String l2 = null;
while ( true )
{
l2 = br2.readLine();
l1 = br.readLine();
if ( l2 == null || l1 == null )
break;
assertEquals("Result works.", l2, l1);
}
assertNull("Filtered Stream not finished", l1);
assertNull("Test Input not finished", l2);
}
public static Test suite() {
TestSuite suite = new TestSuite(JacsonReaderTest.class);
return suite;
}
public static void main(java.lang.String[] args) {
junit.textui.TestRunner.run(suite());
}
}
//
// Jacson - Text Filtering with Java.
// Copyright (C) 2002 Frank S. Nestel (nestefan -at- users.sourceforge.net)
//
// 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
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -