diff --git a/src/tests/com/puppycrawl/tools/checkstyle/AvoidStarImportTest.java b/src/tests/com/puppycrawl/tools/checkstyle/AvoidStarImportTest.java index e1f92bc4c..ee2796a78 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/AvoidStarImportTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/AvoidStarImportTest.java @@ -9,8 +9,7 @@ public class AvoidStarImportTest throws Exception { final DefaultConfiguration checkConfig = - new DefaultConfiguration("test"); - checkConfig.addAttribute("classname", AvoidStarImport.class.getName()); + createCheckConfig(AvoidStarImport.class); final Checker c = createChecker(checkConfig); final String fname = getPath("InputImport.java"); final String[] expected = { diff --git a/src/tests/com/puppycrawl/tools/checkstyle/BaseCheckTestCase.java b/src/tests/com/puppycrawl/tools/checkstyle/BaseCheckTestCase.java index d43636244..83231f266 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/BaseCheckTestCase.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/BaseCheckTestCase.java @@ -33,6 +33,14 @@ public abstract class BaseCheckTestCase protected final PrintStream mStream = new PrintStream(mBAOS); protected final Properties mProps = new Properties(); + public static DefaultConfiguration createCheckConfig(Class aClazz) + { + final DefaultConfiguration checkConfig = + new DefaultConfiguration("test"); + checkConfig.addAttribute("classname", aClazz.getName()); + return checkConfig; + } + protected Checker createChecker(Configuration aConfig) throws Exception { diff --git a/src/tests/com/puppycrawl/tools/checkstyle/ConstantNameCheckTest.java b/src/tests/com/puppycrawl/tools/checkstyle/ConstantNameCheckTest.java index a54951b87..ecfa72bd1 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/ConstantNameCheckTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/ConstantNameCheckTest.java @@ -9,9 +9,9 @@ public class ConstantNameCheckTest public void testIllegalRegexp() throws Exception { - final CheckConfiguration checkConfig = new CheckConfiguration(); - checkConfig.setClassname(ConstantNameCheck.class.getName()); - checkConfig.addProperty("format", "\\"); + final DefaultConfiguration checkConfig = + createCheckConfig(ConstantNameCheck.class); + checkConfig.addAttribute("format", "\\"); try { createChecker(checkConfig); fail(); @@ -24,8 +24,8 @@ public class ConstantNameCheckTest public void testDefault() throws Exception { - final CheckConfiguration checkConfig = new CheckConfiguration(); - checkConfig.setClassname(ConstantNameCheck.class.getName()); + final DefaultConfiguration checkConfig = + createCheckConfig(ConstantNameCheck.class); final Checker c = createChecker(checkConfig); final String fname = getPath("InputSimple.java"); final String[] expected = { @@ -38,8 +38,8 @@ public class ConstantNameCheckTest public void testInterface() throws Exception { - final CheckConfiguration checkConfig = new CheckConfiguration(); - checkConfig.setClassname(ConstantNameCheck.class.getName()); + final DefaultConfiguration checkConfig = + createCheckConfig(ConstantNameCheck.class); final Checker c = createChecker(checkConfig); final String fname = getPath("InputInner.java"); final String[] expected = { diff --git a/src/tests/com/puppycrawl/tools/checkstyle/EmptyBlockCheckTest.java b/src/tests/com/puppycrawl/tools/checkstyle/EmptyBlockCheckTest.java index a0e8bebc8..7cd3f9ca4 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/EmptyBlockCheckTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/EmptyBlockCheckTest.java @@ -9,8 +9,8 @@ public class EmptyBlockCheckTest public void testDefault() throws Exception { - final CheckConfiguration checkConfig = new CheckConfiguration(); - checkConfig.setClassname(EmptyBlockCheck.class.getName()); + final DefaultConfiguration checkConfig = + createCheckConfig(EmptyBlockCheck.class); final Checker c = createChecker(checkConfig); final String fname = getPath("InputSemantic.java"); final String[] expected = { @@ -30,9 +30,9 @@ public class EmptyBlockCheckTest public void testText() throws Exception { - final CheckConfiguration checkConfig = new CheckConfiguration(); - checkConfig.setClassname(EmptyBlockCheck.class.getName()); - checkConfig.addProperty("option", BlockOption.TEXT.toString()); + final DefaultConfiguration checkConfig = + createCheckConfig(EmptyBlockCheck.class); + checkConfig.addAttribute("option", BlockOption.TEXT.toString()); final Checker c = createChecker(checkConfig); final String fname = getPath("InputSemantic.java"); final String[] expected = { @@ -48,9 +48,9 @@ public class EmptyBlockCheckTest public void testStatement() throws Exception { - final CheckConfiguration checkConfig = new CheckConfiguration(); - checkConfig.setClassname(EmptyBlockCheck.class.getName()); - checkConfig.addProperty("option", BlockOption.STMT.toString()); + final DefaultConfiguration checkConfig = + createCheckConfig(EmptyBlockCheck.class); + checkConfig.addAttribute("option", BlockOption.STMT.toString()); final Checker c = createChecker(checkConfig); final String fname = getPath("InputSemantic.java"); final String[] expected = {