added test for PackageHtmlCheck
This commit is contained in:
parent
6568a9b882
commit
f116754656
|
|
@ -29,7 +29,7 @@ public abstract class BaseCheckTestCase
|
|||
}
|
||||
|
||||
private final ByteArrayOutputStream mBAOS = new ByteArrayOutputStream();
|
||||
private final PrintStream mStream = new PrintStream(mBAOS);
|
||||
protected final PrintStream mStream = new PrintStream(mBAOS);
|
||||
protected final Properties mProps = new Properties();
|
||||
|
||||
protected Checker createChecker(CheckConfiguration aCheckConfig)
|
||||
|
|
@ -50,11 +50,18 @@ public abstract class BaseCheckTestCase
|
|||
return f.getCanonicalPath();
|
||||
}
|
||||
|
||||
protected void verify(Checker aC, String aFilename, String[] aExpected)
|
||||
protected void verify(Checker aC, String aFileName, String[] aExpected)
|
||||
throws Exception
|
||||
{
|
||||
verify(aC, aFileName, aFileName, aExpected);
|
||||
}
|
||||
|
||||
protected void verify(Checker aC, String aProcessedFilename,
|
||||
String aMessageFileName, String[] aExpected)
|
||||
throws Exception
|
||||
{
|
||||
mStream.flush();
|
||||
final int errs = aC.process(new File[] {new File(aFilename)});
|
||||
final int errs = aC.process(new File[] {new File(aProcessedFilename)});
|
||||
|
||||
// process each of the lines
|
||||
final ByteArrayInputStream bais =
|
||||
|
|
@ -63,7 +70,7 @@ public abstract class BaseCheckTestCase
|
|||
new LineNumberReader(new InputStreamReader(bais));
|
||||
|
||||
for (int i = 0; i < aExpected.length; i++) {
|
||||
assertEquals(aFilename + ":" + aExpected[i], lnr.readLine());
|
||||
assertEquals(aMessageFileName + ":" + aExpected[i], lnr.readLine());
|
||||
}
|
||||
assertEquals(aExpected.length, errs);
|
||||
aC.destroy();
|
||||
|
|
|
|||
|
|
@ -6,16 +6,34 @@ import com.puppycrawl.tools.checkstyle.checks.PackageHtmlCheck;
|
|||
public class PackageHtmlCheckTest
|
||||
extends BaseCheckTestCase
|
||||
{
|
||||
protected Checker createChecker(CheckConfiguration aCheckConfig)
|
||||
throws Exception
|
||||
{
|
||||
final Checker c = new Checker(new GlobalProperties(mProps, mStream),
|
||||
new CheckConfiguration[0]);
|
||||
final AuditListener listener = new BriefLogger(mStream);
|
||||
c.addListener(listener);
|
||||
return c;
|
||||
}
|
||||
|
||||
public void testPackageHtml()
|
||||
throws Exception
|
||||
{
|
||||
CheckConfiguration checkConfig = new CheckConfiguration();
|
||||
// no Checks in config, but register new PackageHtml as a FileSetCheck
|
||||
Checker c = createChecker(checkConfig);
|
||||
final FileSetCheck fsc = new PackageHtmlCheck();
|
||||
c.addFileSetCheck(fsc);
|
||||
|
||||
final String packageHtmlPath = getPath("package.html");
|
||||
// final String filepath = packageHtmlPath;
|
||||
// TODO: should really be a java file like
|
||||
final String filepath = getPath("InputScopeAnonInner.java");
|
||||
|
||||
final String[] expected = {
|
||||
packageHtmlPath + ":0: Missing package documentation file.",
|
||||
"0: Missing package documentation file.",
|
||||
};
|
||||
// TODO: verify(fsc, filepath, expected);
|
||||
verify(c, filepath, packageHtmlPath, expected);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue