Skip to content

Commit

Permalink
Issue #4587: Moved resources for descendant token check test
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmytro Kytsmen authored and romani committed Jul 5, 2017
1 parent 69d371c commit 208a3ae
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 30 deletions.
Expand Up @@ -36,7 +36,10 @@
public class DescendantTokenCheckTest extends BaseCheckTestSupport {
@Override
protected String getPath(String filename) throws IOException {
return super.getPath("checks" + File.separator + filename);
return super.getPath("checks" + File.separator
+ "misc" + File.separator
+ "descendanttoken" + File.separator
+ filename);
}

@Test
Expand All @@ -45,7 +48,7 @@ public void testDefault()
final DefaultConfiguration checkConfig =
createCheckConfig(DescendantTokenCheck.class);
final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
verify(checkConfig, getPath("InputDescendantTokenIllegalTokens.java"), expected);
}

@Test
Expand All @@ -59,7 +62,7 @@ public void testMaximumNumber()
final String[] expected = {
"17:12: " + getCheckMessage(MSG_KEY_MAX, 1, 0, "LITERAL_NATIVE", "LITERAL_NATIVE"),
};
verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
verify(checkConfig, getPath("InputDescendantTokenIllegalTokens.java"), expected);
}

@Test
Expand All @@ -74,7 +77,7 @@ public void testMessage()
final String[] expected = {
"17:12: Using 'native' is not allowed.",
};
verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
verify(checkConfig, getPath("InputDescendantTokenIllegalTokens.java"), expected);
}

@Test
Expand All @@ -88,7 +91,7 @@ public void testMinimumNumber()
final String[] expected = {
"8:9: " + getCheckMessage(MSG_KEY_MIN, 1, 2, "LITERAL_SWITCH", "LITERAL_DEFAULT"),
};
verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
verify(checkConfig, getPath("InputDescendantTokenIllegalTokens.java"), expected);
}

@Test
Expand All @@ -101,7 +104,7 @@ public void testMinimumDepth()
checkConfig.addAttribute("maximumNumber", "0");
checkConfig.addAttribute("minimumDepth", "3");
final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
verify(checkConfig, getPath("InputDescendantTokenIllegalTokens.java"), expected);
}

@Test
Expand All @@ -114,7 +117,7 @@ public void testMaximumDepth()
checkConfig.addAttribute("maximumNumber", "0");
checkConfig.addAttribute("maximumDepth", "1");
final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
verify(checkConfig, getPath("InputDescendantTokenIllegalTokens.java"), expected);
}

@Test
Expand Down Expand Up @@ -147,7 +150,7 @@ public void testEmptyStatements()
"75:10: Empty statement.",
};

verify(checkConfig, getPath("InputEmptyStatement.java"), expected);
verify(checkConfig, getPath("InputDescendantTokenEmptyStatement.java"), expected);
}

@Test
Expand All @@ -164,7 +167,7 @@ public void testMissingSwitchDefault() throws Exception {
"17:9: switch without \"default\" clause.",
};

verify(checkConfig, getPath("InputMissingSwitchDefault.java"), expected);
verify(checkConfig, getPath("InputDescendantTokenMissingSwitchDefault.java"), expected);
}

@Test
Expand All @@ -183,7 +186,7 @@ public void testStringLiteralEquality() throws Exception {
"12:20: Literal Strings should be compared using equals(), not '=='.",
"17:22: Literal Strings should be compared using equals(), not '=='.",
};
verify(checkConfig, getPath("InputStringLiteralEquality.java"), expected);
verify(checkConfig, getPath("InputDescendantTokenStringLiteralEquality.java"), expected);
}

@Test
Expand All @@ -201,7 +204,7 @@ public void testIllegalTokenDefault() throws Exception {
"11:18: Using 'POST_DEC' is not allowed.",
"12:18: Using 'POST_INC' is not allowed.",
};
verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
verify(checkConfig, getPath("InputDescendantTokenIllegalTokens.java"), expected);
}

@Test
Expand All @@ -217,7 +220,7 @@ public void testIllegalTokenNative() throws Exception {
final String[] expected = {
"17:12: Using 'LITERAL_NATIVE' is not allowed.",
};
verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
verify(checkConfig, getPath("InputDescendantTokenIllegalTokens.java"), expected);
}

@Test
Expand All @@ -234,7 +237,7 @@ public void testReturnFromCatch() throws Exception {
"15:11: Return from catch is not allowed.",
};

verify(checkConfig, getPath("InputReturnFromCatch.java"), expected);
verify(checkConfig, getPath("InputDescendantTokenReturnFromCatch.java"), expected);
}

@Test
Expand All @@ -251,7 +254,7 @@ public void testReturnFromFinally() throws Exception {
"15:11: Return from finally is not allowed.",
};

verify(checkConfig, getPath("InputReturnFromFinally.java"), expected);
verify(checkConfig, getPath("InputDescendantTokenReturnFromFinally.java"), expected);
}

@Test
Expand All @@ -265,7 +268,7 @@ public void testNoSum() throws Exception {

final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;

verify(checkConfig, getPath("InputReturnFromFinally.java"), expected);
verify(checkConfig, getPath("InputDescendantTokenReturnFromFinally.java"), expected);
}

@Test
Expand All @@ -285,7 +288,7 @@ public void testWithSumCustomMsg() throws Exception {
"23:51: this cannot be null.",
};

verify(checkConfig, getPath("InputReturnFromFinally.java"), expected);
verify(checkConfig, getPath("InputDescendantTokenReturnFromFinally.java"), expected);
}

@Test
Expand All @@ -304,7 +307,7 @@ public void testWithSumDefaultMsg() throws Exception {
"23:51: " + getCheckMessage(MSG_KEY_SUM_MAX, 2, 1, "NOT_EQUAL"),
};

verify(checkConfig, getPath("InputReturnFromFinally.java"), expected);
verify(checkConfig, getPath("InputDescendantTokenReturnFromFinally.java"), expected);
}

@Test
Expand All @@ -325,7 +328,7 @@ public void testWithSumLessThenMinDefMsg() throws Exception {
"24:77: " + getCheckMessage(MSG_KEY_SUM_MIN, 1, 3, "EQUAL"),
};

verify(checkConfig, getPath("InputReturnFromFinally.java"), expected);
verify(checkConfig, getPath("InputDescendantTokenReturnFromFinally.java"), expected);
}

@Test
Expand All @@ -347,6 +350,6 @@ public void testWithSumLessThenMinCustomMsg() throws Exception {
"24:77: custom message",
};

verify(checkConfig, getPath("InputReturnFromFinally.java"), expected);
verify(checkConfig, getPath("InputDescendantTokenReturnFromFinally.java"), expected);
}
}
@@ -1,8 +1,8 @@
package com.puppycrawl.tools.checkstyle.checks;
package com.puppycrawl.tools.checkstyle.checks.misc.descendanttoken;

public class InputEmptyStatement
public class InputDescendantTokenEmptyStatement
{
public InputEmptyStatement()
public InputDescendantTokenEmptyStatement()
{
;
}
Expand Down
@@ -0,0 +1,18 @@
package com.puppycrawl.tools.checkstyle.checks.misc.descendanttoken;

public class InputDescendantTokenIllegalTokens
{
public void methodWithPreviouslyIllegalTokens()
{
int i = 0;
switch (i)
{
default:
i--;
i++;
break;
}
}

public native void nativeMethod();
}
@@ -1,6 +1,6 @@
package com.puppycrawl.tools.checkstyle.checks;
package com.puppycrawl.tools.checkstyle.checks.misc.descendanttoken;

public class InputMissingSwitchDefault {
public class InputDescendantTokenMissingSwitchDefault {
public void foo() {
int i = 1;
switch (i) {
Expand Down
@@ -1,6 +1,6 @@
package com.puppycrawl.tools.checkstyle.checks;
package com.puppycrawl.tools.checkstyle.checks.misc.descendanttoken;

public class InputReturnFromCatch {
public class InputDescendantTokenReturnFromCatch {
public void foo() {
try {
System.currentTimeMillis();
Expand Down
@@ -1,6 +1,6 @@
package com.puppycrawl.tools.checkstyle.checks;
package com.puppycrawl.tools.checkstyle.checks.misc.descendanttoken;

public class InputReturnFromFinally {
public class InputDescendantTokenReturnFromFinally {
public void foo() {
try {
System.currentTimeMillis();
Expand Down
@@ -1,6 +1,6 @@
package com.puppycrawl.tools.checkstyle.checks;
package com.puppycrawl.tools.checkstyle.checks.misc.descendanttoken;

public class InputStringLiteralEquality
public class InputDescendantTokenStringLiteralEquality
{
void foo(String name)
{
Expand Down

0 comments on commit 208a3ae

Please sign in to comment.