use of org.apache.commons.beanutils.ConversionException in project contribution by checkstyle.
the class AbstractUsageCheck method setIgnoreFormat.
/**
* Set the ignore format to the specified regular expression.
* @param aFormat a <code>String</code> value
* @throws ConversionException unable to parse aFormat
*/
public void setIgnoreFormat(String aFormat) throws ConversionException {
try {
mRegexp = Utils.getPattern(aFormat);
mIgnoreFormat = aFormat;
} catch (PatternSyntaxException e) {
throw new ConversionException("unable to parse " + aFormat, e);
}
}
use of org.apache.commons.beanutils.ConversionException in project checkstyle by checkstyle.
the class AutomaticBeanTest method testContextualizeConversionException.
@Test
public void testContextualizeConversionException() {
final TestBean testBean = new TestBean();
final DefaultContext context = new DefaultContext();
context.add("val", "some string");
try {
testBean.contextualize(context);
assertWithMessage("InvocationTargetException is expected").fail();
} catch (CheckstyleException ex) {
final String expected = "illegal value ";
assertWithMessage("Invalid exception cause, should be: ConversionException").that(ex).hasCauseThat().isInstanceOf(ConversionException.class);
assertWithMessage("Invalid exception message, should start with: " + expected).that(ex).hasMessageThat().startsWith(expected);
}
}
Aggregations