@Test public void testTestLine() { File testSrcDir = MavenTestingUtils.getProjectDir("src/test/java"); String path = BannedRefCheckerTest.class.getName().replace('.', '/') + ".java"; File srcFile = PathAssert.assertFileExists(testSrcDir, path); String includes[] = { "fakeco" }; String excludes[] = { "fakecoopensource", "fakeco inc", "com.fakeco.kernel" }; BannedRefChecker checker = new BannedRefChecker(includes, excludes); JunitReport report = new JunitReport(); report.fileStart(srcFile); checker.testLine(report, 1, "package com.fakeco.internal;"); checker.testLine(report, 2, " checker.testLine(report, 3, "import com.fakecoopensource.common.Utils;"); checker.testLine(report, 4, "import com.fakeco.kernel.Logger;"); checker.testLine(report, 5, ""); checker.testLine(report, 6, "class FakeCoUtil { "); checker.testLine(report, 7, " public static final String VERSION=Utils.asVersion(this);"); checker.testLine(report, 8, "}"); report.fileEnd(); Errors errors = report.assertContainsFile(srcFile); errors.assertCount(2); errors.assertErrorExists(1, "com.fakeco.internal"); errors.assertErrorExists(6, "class FakeCoUtil"); }
protected void testLine(Report report, int linenum, String line) { List<Range> includedRanges = getRangeMatches(line, included); List<Range> excludedRanges = getRangeMatches(line, excluded); for (Range range : includedRanges) { if (range.overlaps(excludedRanges)) { continue; } report.error(linenum, range.match, range.start, range.end, line); } }
BannedRefChecker { protected void testLine(Report report, int linenum, String line) { List<Range> includedRanges = getRangeMatches(line, included); List<Range> excludedRanges = getRangeMatches(line, excluded); for (Range range : includedRanges) { if (range.overlaps(excludedRanges)) { continue; } report.error(linenum, range.match, range.start, range.end, line); } } }
BannedRefChecker { protected void testLine(Report report, int linenum, String line) { List<Range> includedRanges = getRangeMatches(line, included); List<Range> excludedRanges = getRangeMatches(line, excluded); for (Range range : includedRanges) { if (range.overlaps(excludedRanges)) { continue; } report.error(linenum, range.match, range.start, range.end, line); } } BannedRefChecker(String included[], String excluded[]); }
BannedRefChecker { protected void testLine(Report report, int linenum, String line) { List<Range> includedRanges = getRangeMatches(line, included); List<Range> excludedRanges = getRangeMatches(line, excluded); for (Range range : includedRanges) { if (range.overlaps(excludedRanges)) { continue; } report.error(linenum, range.match, range.start, range.end, line); } } BannedRefChecker(String included[], String excluded[]); void check(Report report, File file); }
BannedRefChecker { protected void testLine(Report report, int linenum, String line) { List<Range> includedRanges = getRangeMatches(line, included); List<Range> excludedRanges = getRangeMatches(line, excluded); for (Range range : includedRanges) { if (range.overlaps(excludedRanges)) { continue; } report.error(linenum, range.match, range.start, range.end, line); } } BannedRefChecker(String included[], String excluded[]); void check(Report report, File file);  }