use of com.puppycrawl.tools.checkstyle.api.CheckstyleException in project checkstyle by checkstyle.
the class ImportOrderCheckTest method testGroupWithSlashes.
@Test
public void testGroupWithSlashes() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(ImportOrderCheck.class);
checkConfig.addAttribute("groups", "/^javax");
try {
final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
verify(checkConfig, getPath("InputImportOrder.java"), expected);
fail("exception expected");
} catch (CheckstyleException ex) {
assertTrue(ex.getMessage().startsWith("cannot initialize module com.puppycrawl.tools.checkstyle.TreeWalker - " + "Cannot set property 'groups' to '/^javax' in module"));
}
}
use of com.puppycrawl.tools.checkstyle.api.CheckstyleException in project checkstyle by checkstyle.
the class ImportControlCheckTest method testUrlInFilePropertyUnableToLoad.
@Test
public void testUrlInFilePropertyUnableToLoad() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(ImportControlCheck.class);
checkConfig.addAttribute("file", "https://UnableToLoadThisURL");
try {
final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
verify(checkConfig, getPath("InputImportControl.java"), expected);
fail("Test should fail if exception was not thrown");
} catch (final CheckstyleException ex) {
final String message = getCheckstyleExceptionMessage(ex);
assertTrue(message.startsWith("Unable to load "));
}
}
use of com.puppycrawl.tools.checkstyle.api.CheckstyleException in project checkstyle by checkstyle.
the class ImportControlCheckTest method testUrlUnableToLoad.
@Test
public void testUrlUnableToLoad() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(ImportControlCheck.class);
checkConfig.addAttribute("url", "https://UnableToLoadThisURL");
try {
final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
verify(checkConfig, getPath("InputImportControl.java"), expected);
fail("Test should fail if exception was not thrown");
} catch (final CheckstyleException ex) {
final String message = getCheckstyleExceptionMessage(ex);
assertTrue(message.startsWith("Unable to load "));
}
}
use of com.puppycrawl.tools.checkstyle.api.CheckstyleException in project checkstyle by checkstyle.
the class ImportControlCheckTest method testUnknown.
@Test
public void testUnknown() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(ImportControlCheck.class);
checkConfig.addAttribute("file", "unknown-file");
try {
final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
verify(checkConfig, getPath("InputImportControl.java"), expected);
fail("Test should fail if exception was not thrown");
} catch (CheckstyleException ex) {
final String message = getCheckstyleExceptionMessage(ex);
assertTrue(message.startsWith("Unable to find: "));
}
}
use of com.puppycrawl.tools.checkstyle.api.CheckstyleException in project checkstyle by checkstyle.
the class ImportOrderCheckTest method testInvalidOption.
@Test
public void testInvalidOption() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(ImportOrderCheck.class);
checkConfig.addAttribute("option", "invalid_option");
try {
final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
verify(checkConfig, getPath("InputImportOrder_Top.java"), expected);
fail("exception expected");
} catch (CheckstyleException ex) {
assertTrue(ex.getMessage().startsWith("cannot initialize module com.puppycrawl.tools.checkstyle.TreeWalker - " + "Cannot set property 'option' to 'invalid_option' in module"));
}
}
Aggregations