use of com.puppycrawl.tools.checkstyle.api.Context in project checkstyle by checkstyle.
the class CheckerTest method testFinishLocalSetupFullyInitialized.
@Test
public void testFinishLocalSetupFullyInitialized() throws Exception {
final Checker checker = new Checker();
final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
checker.setModuleClassLoader(contextClassLoader);
final PackageObjectFactory factory = new PackageObjectFactory(new HashSet<>(), contextClassLoader);
checker.setModuleFactory(factory);
checker.setBasedir("testBaseDir");
checker.setLocaleLanguage("it");
checker.setLocaleCountry("IT");
checker.finishLocalSetup();
final Context context = TestUtil.getInternalState(checker, "childContext");
final String encoding = StandardCharsets.UTF_8.name();
assertWithMessage("Charset was different than expected").that(context.get("charset")).isEqualTo(encoding);
assertWithMessage("Severity is set to unexpected value").that(context.get("severity")).isEqualTo("error");
assertWithMessage("Basedir is set to unexpected value").that(context.get("basedir")).isEqualTo("testBaseDir");
final Field sLocale = Violation.class.getDeclaredField("sLocale");
sLocale.setAccessible(true);
final Locale locale = (Locale) sLocale.get(null);
assertWithMessage("Locale is set to unexpected value").that(locale).isEqualTo(Locale.ITALY);
}
Aggregations