Search in sources :

Example 86 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class CatchParameterNameCheckTest method testDefaultConfigurationOnCorrectFile.

@Test
public void testDefaultConfigurationOnCorrectFile() throws Exception {
    final Configuration checkConfig = createCheckConfig(CatchParameterNameCheck.class);
    final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
    verify(checkConfig, getPath("InputSimple.java"), expected);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 87 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class SuppressWarningsHolderTest method testAnnotationWithFullName.

@Test
public void testAnnotationWithFullName() throws Exception {
    final Configuration checkConfig = createCheckConfig(SuppressWarningsHolder.class);
    final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
    verify(checkConfig, getPath("InputSuppressWarningsHolder4.java"), expected);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 88 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class TranslationCheckTest method testTranslation.

@Test
public void testTranslation() throws Exception {
    final Configuration checkConfig = createCheckConfig(TranslationCheck.class);
    final String[] expected = { "0: " + getCheckMessage(MSG_KEY, "only.english") };
    final File[] propertyFiles = { new File(getPath("messages_test_de.properties")), new File(getPath("messages_test.properties")) };
    verify(createChecker(checkConfig), propertyFiles, getPath("messages_test_de.properties"), expected);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) File(java.io.File) Test(org.junit.Test)

Example 89 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class PropertyCacheFileTest method testConfigHashOnReset.

@Test
public void testConfigHashOnReset() throws IOException {
    final Configuration config = new DefaultConfiguration("myName");
    final String filePath = temporaryFolder.newFile().getPath();
    final PropertyCacheFile cache = new PropertyCacheFile(config, filePath);
    cache.load();
    final String hash = cache.get(PropertyCacheFile.CONFIG_HASH_KEY);
    assertNotNull(hash);
    cache.reset();
    assertEquals(hash, cache.get(PropertyCacheFile.CONFIG_HASH_KEY));
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 90 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class PropertyCacheFileTest method testPathToCacheContainsOnlyFileName.

@Test
public void testPathToCacheContainsOnlyFileName() throws IOException {
    final Configuration config = new DefaultConfiguration("myName");
    final String filePath = "temp.cache";
    final PropertyCacheFile cache = new PropertyCacheFile(config, filePath);
    // no exception expected
    cache.persist();
    if (Files.exists(Paths.get(filePath))) {
        Files.delete(Paths.get(filePath));
    }
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Configuration (com.puppycrawl.tools.checkstyle.api.Configuration)137 Test (org.junit.Test)127 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)21 DefaultConfiguration (com.puppycrawl.tools.checkstyle.DefaultConfiguration)16 Properties (java.util.Properties)13 CheckstyleException (com.puppycrawl.tools.checkstyle.api.CheckstyleException)9 File (java.io.File)9 Checker (com.puppycrawl.tools.checkstyle.Checker)5 PropertiesExpander (com.puppycrawl.tools.checkstyle.PropertiesExpander)4 OneTopLevelClassCheck (com.puppycrawl.tools.checkstyle.checks.design.OneTopLevelClassCheck)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 ModuleFactory (com.puppycrawl.tools.checkstyle.ModuleFactory)2 AuditListener (com.puppycrawl.tools.checkstyle.api.AuditListener)2 RootModule (com.puppycrawl.tools.checkstyle.api.RootModule)2 AnnotationLocationCheck (com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationLocationCheck)2 EmptyLineSeparatorCheck (com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck)2 MethodParamPadCheck (com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck)2 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2