📄 jacsontest.java
字号:
package de.spieleck.app.jacson;
import junit.framework.TestCase;
import junit.framework.Test;
import junit.framework.TestSuite;
import java.io.*;
import java.util.*;
import de.spieleck.config.ConfigNode;
import de.spieleck.app.jacson.report.TestReport;
import de.spieleck.app.jacson.source.LineChunkSource;
/**
* Master test to test Jacson at the plain application level.
*/
public class JacsonTest
extends TestCase
implements JacsonNames, NamesForTesting
{
public void setUp()
{
}
public void tearDown()
{
}
public void testLogreport()
throws Exception
{
internalTest(basePath+"loganalysis.conf",
basePath+"access.log.gz",
basePath+"loganalysis.list");
}
protected void internalTest(String cName, String data, String expected)
throws Exception
{
JacsonState rootState = new JacsonState();
ConfigNode config = Jacson.obtainConfig(cName, rootState);
Jacson stat = new Jacson(config, rootState);
TestReport jr = new TestReport();
jr.setOutputStream(System.out);
jr.setReference(expected);
jr.addIgnore("processing.lines.time");
jr.addIgnore("processing.lines.name");
jr.addIgnore("processing.time");
jr.addIgnore("summary.timestamp");
jr.addIgnore("summary.time");
stat.addReport(jr);
// jr.begin/end pair need to mimic Jacson.main behaviour
jr.begin(JS_REP_PROC);
JacsonChunkSource ch = new LineChunkSource(data, true);
stat.run(ch);
// Dummy output just to stay in touch with original Jacson!
jr.report(JS_REP_TIME, "42");
jr.end();
stat.summary();
int diff = jr.getDiffCount();
jr.finish();
assertEquals("Linecount mismatch", 2760, jr.getLineNumber());
assertEquals("There are differences!", 0, diff);
assertTrue("There are too many ignored errors.", jr.getIgnores() < 6);
}
public static Test suite() {
TestSuite suite = new TestSuite(JacsonTest.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 + -