Skip to content

Commit

Permalink
Issue #2161: unify test input locations for naming package
Browse files Browse the repository at this point in the history
  • Loading branch information
rnveach committed Oct 16, 2015
1 parent bf94ea4 commit 7e5e919
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,25 @@

import static com.puppycrawl.tools.checkstyle.checks.naming.AbbreviationAsWordInNameCheck.MSG_KEY;

import java.io.File;
import java.io.IOException;

import org.apache.commons.lang3.ArrayUtils;
import org.junit.Test;

import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;

public class AbbreviationAsWordInNameCheckTest extends BaseCheckTestSupport {

/** Warning message. */
private String warningMessage;

@Override
protected String getPath(String filename) throws IOException {
return super.getPath("checks" + File.separator
+ "naming" + File.separator + filename);
}

@Test
public void testTypeNamesForThreePermittedCapitalLetters() throws Exception {

Expand All @@ -50,7 +58,7 @@ public void testTypeNamesForThreePermittedCapitalLetters() throws Exception {
"37: " + warningMessage,
};

verify(checkConfig, getPath("naming/InputAbbreviationAsWordInTypeNameCheck.java"), expected);
verify(checkConfig, getPath("InputAbbreviationAsWordInTypeNameCheck.java"), expected);
}

@Test
Expand All @@ -68,7 +76,7 @@ public void testTypeNamesForFourPermittedCapitalLetters() throws Exception {
"32: " + warningMessage,
};

verify(checkConfig, getPath("naming/InputAbbreviationAsWordInTypeNameCheck.java"), expected);
verify(checkConfig, getPath("InputAbbreviationAsWordInTypeNameCheck.java"), expected);
}

@Test
Expand All @@ -86,7 +94,7 @@ public void testTypeNamesForFivePermittedCapitalLetters() throws Exception {
"37: " + warningMessage,
};

verify(checkConfig, getPath("naming/InputAbbreviationAsWordInTypeNameCheck.java"), expected);
verify(checkConfig, getPath("InputAbbreviationAsWordInTypeNameCheck.java"), expected);
}

@Test
Expand All @@ -112,7 +120,7 @@ public void testTypeAndVariablesAndMethodNames() throws Exception {
"58: " + warningMessage,
};

verify(checkConfig, getPath("naming/InputAbbreviationAsWordInTypeNameCheck.java"), expected);
verify(checkConfig, getPath("InputAbbreviationAsWordInTypeNameCheck.java"), expected);
}

@Test
Expand Down Expand Up @@ -141,7 +149,7 @@ public void testTypeAndVariablesAndMethodNamesWithNoIgnores() throws Exception {
"84: " + warningMessage,
};

verify(checkConfig, getPath("naming/InputAbbreviationAsWordInTypeNameCheck.java"), expected);
verify(checkConfig, getPath("InputAbbreviationAsWordInTypeNameCheck.java"), expected);
}

@Test
Expand All @@ -166,7 +174,7 @@ public void testTypeAndVariablesAndMethodNamesWithIgnores() throws Exception {
"38: " + warningMessage,
};

verify(checkConfig, getPath("naming/InputAbbreviationAsWordInTypeNameCheck.java"), expected);
verify(checkConfig, getPath("InputAbbreviationAsWordInTypeNameCheck.java"), expected);
}

@Test
Expand Down Expand Up @@ -194,7 +202,7 @@ public void testTypeAndVariablesAndMethodNamesWithIgnoresFinal() throws Exceptio
"60: " + warningMessage, // no ignore for static
};

verify(checkConfig, getPath("naming/InputAbbreviationAsWordInTypeNameCheck.java"), expected);
verify(checkConfig, getPath("InputAbbreviationAsWordInTypeNameCheck.java"), expected);
}

@Test
Expand All @@ -221,7 +229,7 @@ public void testTypeAndVariablesAndMethodNamesWithIgnoresStatic() throws Excepti
"59: " + warningMessage, // no ignore for final
};

verify(checkConfig, getPath("naming/InputAbbreviationAsWordInTypeNameCheck.java"), expected);
verify(checkConfig, getPath("InputAbbreviationAsWordInTypeNameCheck.java"), expected);
}

@Test
Expand All @@ -240,7 +248,7 @@ public void testTypeNamesForThreePermittedCapitalLettersWithOverriddenMethod() t
};

verify(checkConfig,
getPath("naming/InputAbbreviationAsWordInTypeNameCheckOverridableMethod.java"), expected);
getPath("InputAbbreviationAsWordInTypeNameCheckOverridableMethod.java"), expected);
}

@Test
Expand Down Expand Up @@ -286,7 +294,7 @@ public void testTypeNamesForZeroPermittedCapitalLetter() throws Exception {
"98: " + warningMessage,
};
verify(checkConfig,
getPath("naming/InputAbbreviationAsWordInTypeNameCheck.java"), expected);
getPath("InputAbbreviationAsWordInTypeNameCheck.java"), expected);
}

@Test
Expand All @@ -301,6 +309,6 @@ public void testNPE() throws Exception {

final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY;

verify(checkConfig, getPath("naming/AbstractMultisetSetCountTester.java"), expected);
verify(checkConfig, getPath("AbstractMultisetSetCountTester.java"), expected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractClassNameCheck.NO_ABSTRACT_CLASS_MODIFIER;

import java.io.File;
import java.io.IOException;

import org.junit.Assert;
import org.junit.Test;
Expand All @@ -32,6 +33,12 @@
import com.puppycrawl.tools.checkstyle.api.TokenTypes;

public class AbstractClassNameCheckTest extends BaseCheckTestSupport {
@Override
protected String getPath(String filename) throws IOException {
return super.getPath("checks" + File.separator
+ "naming" + File.separator + filename);
}

@Test
public void testIllegalAbstractClassName() throws Exception {
final DefaultConfiguration checkConfig =
Expand All @@ -47,7 +54,7 @@ public void testIllegalAbstractClassName() throws Exception {
"10:5: " + getCheckMessage(ILLEGAL_ABSTRACT_CLASS_NAME, "NonAbstractInnerClass", pattern),
};

verify(checkConfig, getPath("naming" + File.separator + "InputAbstractClassName.java"), expected);
verify(checkConfig, getPath("InputAbstractClassName.java"), expected);
}

@Test
Expand All @@ -61,7 +68,7 @@ public void testIllegalClassType() throws Exception {
"22:5: " + getCheckMessage(NO_ABSTRACT_CLASS_MODIFIER, "AbstractInnerClass"),
};

verify(checkConfig, getPath("naming" + File.separator + "InputAbstractClassName.java"), expected);
verify(checkConfig, getPath("InputAbstractClassName.java"), expected);
}

@Test
Expand All @@ -80,7 +87,7 @@ public void testAllVariants() throws Exception {
"22:5: " + getCheckMessage(NO_ABSTRACT_CLASS_MODIFIER, "AbstractInnerClass"),
};

verify(checkConfig, getPath("naming" + File.separator + "InputAbstractClassName.java"), expected);
verify(checkConfig, getPath("InputAbstractClassName.java"), expected);
}

@Test
Expand All @@ -91,8 +98,7 @@ public void testFalsePositive() throws Exception {
"9:5: " + getCheckMessage(NO_ABSTRACT_CLASS_MODIFIER, "AbstractClass"),
};

verify(checkConfig, getPath("naming" + File.separator
+ "InputAbstractClassNameFormerFalsePositive.java"), expected);
verify(checkConfig, getPath("InputAbstractClassNameFormerFalsePositive.java"), expected);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.io.IOException;

import org.apache.commons.lang3.ArrayUtils;
import org.junit.Before;
import org.junit.Test;

import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
Expand All @@ -36,12 +35,10 @@

public class TypeNameCheckTest
extends BaseCheckTestSupport {

private String inputFilename;

@Before
public void setUp() throws IOException {
inputFilename = getPath("naming" + File.separator + "InputTypeName.java");
@Override
protected String getPath(String filename) throws IOException {
return super.getPath("checks" + File.separator
+ "naming" + File.separator + filename);
}

@Test
Expand All @@ -51,7 +48,7 @@ public void testSpecified()
createCheckConfig(TypeNameCheck.class);
checkConfig.addAttribute("format", "^inputHe");
final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY;
verify(checkConfig, inputFilename, expected);
verify(checkConfig, getPath("InputTypeName.java"), expected);
}

@Test
Expand All @@ -69,7 +66,7 @@ public void testDefault()
"9:23: " + getCheckMessage(MSG_INVALID_PATTERN,
"inputHeaderAnnotation", DEFAULT_PATTERN),
};
verify(checkConfig, inputFilename, expected);
verify(checkConfig, getPath("InputTypeName.java"), expected);
}

@Test
Expand All @@ -82,7 +79,7 @@ public void testClassSpecific()
"3:7: " + getCheckMessage(MSG_INVALID_PATTERN,
"inputHeaderClass", DEFAULT_PATTERN),
};
verify(checkConfig, inputFilename, expected);
verify(checkConfig, getPath("InputTypeName.java"), expected);
}

@Test
Expand All @@ -95,7 +92,7 @@ public void testInterfaceSpecific()
"5:22: " + getCheckMessage(MSG_INVALID_PATTERN,
"inputHeaderInterface", DEFAULT_PATTERN),
};
verify(checkConfig, inputFilename, expected);
verify(checkConfig, getPath("InputTypeName.java"), expected);
}

@Test
Expand All @@ -108,7 +105,7 @@ public void testEnumSpecific()
"7:17: " + getCheckMessage(MSG_INVALID_PATTERN,
"inputHeaderEnum", DEFAULT_PATTERN),
};
verify(checkConfig, inputFilename, expected);
verify(checkConfig, getPath("InputTypeName.java"), expected);
}

@Test
Expand All @@ -121,6 +118,6 @@ public void testAnnotationSpecific()
"9:23: " + getCheckMessage(MSG_INVALID_PATTERN,
"inputHeaderAnnotation", DEFAULT_PATTERN),
};
verify(checkConfig, inputFilename, expected);
verify(checkConfig, getPath("InputTypeName.java"), expected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static org.junit.Assert.assertArrayEquals;

import java.io.File;
import java.io.IOException;

import org.junit.Test;

Expand All @@ -32,6 +33,11 @@

public class TypeParameterNameTest
extends BaseCheckTestSupport {
@Override
protected String getPath(String filename) throws IOException {
return super.getPath("checks" + File.separator
+ "naming" + File.separator + filename);
}

@Test
public void testGetInterfaceRequiredTokens() {
Expand Down Expand Up @@ -70,7 +76,7 @@ public void testClassDefault()
"13:14: " + getCheckMessage(MSG_INVALID_PATTERN, "foo", pattern),
"27:24: " + getCheckMessage(MSG_INVALID_PATTERN, "foo", pattern),
};
verify(checkConfig, getPath("naming" + File.separator + "InputTypeParameterName.java"), expected);
verify(checkConfig, getPath("InputTypeParameterName.java"), expected);
}

@Test
Expand All @@ -88,7 +94,7 @@ public void testMethodDefault()
"23:6: " + getCheckMessage(MSG_INVALID_PATTERN, "foo", pattern),
"28:10: " + getCheckMessage(MSG_INVALID_PATTERN, "_fo", pattern),
};
verify(checkConfig, getPath("naming" + File.separator + "InputTypeParameterName.java"), expected);
verify(checkConfig, getPath("InputTypeParameterName.java"), expected);
}

@Test
Expand All @@ -102,7 +108,7 @@ public void testInterfaceDefault()
final String[] expected = {
"48:15: " + getCheckMessage(MSG_INVALID_PATTERN, "Input", pattern),
};
verify(checkConfig, getPath("naming" + File.separator + "InputTypeParameterName.java"), expected);
verify(checkConfig, getPath("InputTypeParameterName.java"), expected);
}

@Test
Expand All @@ -118,7 +124,7 @@ public void testClassFooName()
"5:38: " + getCheckMessage(MSG_INVALID_PATTERN, "t", pattern),
"33:18: " + getCheckMessage(MSG_INVALID_PATTERN, "T", pattern),
};
verify(checkConfig, getPath("naming" + File.separator + "InputTypeParameterName.java"), expected);
verify(checkConfig, getPath("InputTypeParameterName.java"), expected);
}

@Test
Expand All @@ -139,7 +145,7 @@ public void testMethodFooName()
"37:14: " + getCheckMessage(MSG_INVALID_PATTERN, "T", pattern),
//"40:14: Name 'EE' must match pattern '^foo$'.",
};
verify(checkConfig, getPath("naming" + File.separator + "InputTypeParameterName.java"), expected);
verify(checkConfig, getPath("InputTypeParameterName.java"), expected);
}

@Test
Expand All @@ -155,7 +161,7 @@ public void testInterfaceFooName()
"48:15: " + getCheckMessage(MSG_INVALID_PATTERN, "Input", pattern),
"52:24: " + getCheckMessage(MSG_INVALID_PATTERN, "T", pattern),
};
verify(checkConfig, getPath("naming" + File.separator + "InputTypeParameterName.java"), expected);
verify(checkConfig, getPath("InputTypeParameterName.java"), expected);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.puppycrawl.tools.checkstyle.naming;
package com.puppycrawl.tools.checkstyle.checks.naming;

public abstract class AbstractMultisetSetCountTester<E> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.puppycrawl.tools.checkstyle.naming;
package com.puppycrawl.tools.checkstyle.checks.naming;

abstract class IIIInputAbstractClassName {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.puppycrawl.tools.checkstyle.naming;
package com.puppycrawl.tools.checkstyle.checks.naming;

import org.junit.Before;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.puppycrawl.tools.checkstyle.naming;
package com.puppycrawl.tools.checkstyle.checks.naming;

abstract public class InputAbstractClassName {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.puppycrawl.tools.checkstyle.naming;
package com.puppycrawl.tools.checkstyle.checks.naming;

public class InputAbstractClassNameFormerFalsePositive
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.puppycrawl.tools.checkstyle.naming;
package com.puppycrawl.tools.checkstyle.checks.naming;

class inputHeaderClass {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.puppycrawl.tools.checkstyle.naming;
package com.puppycrawl.tools.checkstyle.checks.naming;

import java.io.Serializable;

Expand Down

0 comments on commit 7e5e919

Please sign in to comment.