Skip to content

Commit

Permalink
Issue #14436: Enforced naming convention for illegalcatch
Browse files Browse the repository at this point in the history
  • Loading branch information
MANISH-K-07 authored and romani committed Feb 17, 2024
1 parent 0723bc1 commit b08ea45
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected String getPackageLocation() {
}

@Test
public void testDefault() throws Exception {
public void testIllegalCatchCheckDefaultTokens() throws Exception {

final String[] expected = {
"14:11: " + getCheckMessage(MSG_KEY, "RuntimeException"),
Expand All @@ -46,11 +46,11 @@ public void testDefault() throws Exception {
};

verifyWithInlineConfigParser(
getPath("InputIllegalCatch.java"), expected);
getPath("InputIllegalCatchCheckDefaultTokens.java"), expected);
}

@Test
public void testIllegalClassNames() throws Exception {
public void testIllegalCatchCheckSuperclassThrowable() throws Exception {
final String[] expected = {
"14:11: " + getCheckMessage(MSG_KEY, "Exception"),
"15:11: " + getCheckMessage(MSG_KEY, "Throwable"),
Expand All @@ -59,23 +59,23 @@ public void testIllegalClassNames() throws Exception {
};

verifyWithInlineConfigParser(
getPath("InputIllegalCatch3.java"), expected);
getPath("InputIllegalCatchCheckSuperclassThrowable.java"), expected);
}

@Test
public void testIllegalClassNamesBad() throws Exception {
public void testIllegalCatchCheckSuperclassException() throws Exception {
// check that incorrect names don't break the Check
final String[] expected = {
"15:11: " + getCheckMessage(MSG_KEY, "Exception"),
"23:11: " + getCheckMessage(MSG_KEY, "java.lang.Exception"),
};

verifyWithInlineConfigParser(
getPath("InputIllegalCatch4.java"), expected);
getPath("InputIllegalCatchCheckSuperclassException.java"), expected);
}

@Test
public void testMultipleTypes() throws Exception {
public void testIllegalCatchCheckMultipleExceptions() throws Exception {
final String[] expected = {
"15:11: " + getCheckMessage(MSG_KEY, "RuntimeException"),
"15:11: " + getCheckMessage(MSG_KEY, "SQLException"),
Expand All @@ -91,7 +91,7 @@ public void testMultipleTypes() throws Exception {
};

verifyWithInlineConfigParser(
getPath("InputIllegalCatch2.java"), expected);
getPath("InputIllegalCatchCheckMultipleExceptions.java"), expected);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

package com.puppycrawl.tools.checkstyle.checks.coding.illegalcatch;

public class InputIllegalCatch {
public class InputIllegalCatchCheckDefaultTokens {
public void foo() {
try { //class names
} catch (RuntimeException e) { // violation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

package com.puppycrawl.tools.checkstyle.checks.coding.illegalcatch;

public class InputIllegalCatch2 {
public class InputIllegalCatchCheckMultipleExceptions {
public void foo() throws OneMoreException {
try {
foo1();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

package com.puppycrawl.tools.checkstyle.checks.coding.illegalcatch;

public class InputIllegalCatch4 {
public class InputIllegalCatchCheckSuperclassException {
public void foo() {
try { //class names
} catch (RuntimeException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

package com.puppycrawl.tools.checkstyle.checks.coding.illegalcatch;

public class InputIllegalCatch3 {
public class InputIllegalCatchCheckSuperclassThrowable {
public void foo() {
try { //class names
} catch (RuntimeException e) {
Expand Down

0 comments on commit b08ea45

Please sign in to comment.