Search in sources :

Example 1 with FilterSet

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

the class FilterSetTest method testToString2.

@Test
public void testToString2() {
    final FilterSet filterSet = new FilterSet();
    filterSet.addFilter(new SeverityMatchFilter());
    assertNotNull("size is the same", filterSet.toString());
}
Also used : FilterSet(com.puppycrawl.tools.checkstyle.api.FilterSet) Test(org.junit.Test)

Example 2 with FilterSet

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

the class SuppressionsLoaderTest method testLoadFromClasspath.

@Test
public void testLoadFromClasspath() throws Exception {
    final FilterSet fc = SuppressionsLoader.loadSuppressions(getPath("InputSuppressionsLoaderNone.xml"));
    final FilterSet fc2 = new FilterSet();
    assertWithMessage("Suppressions were not loaded").that(fc.getFilters()).isEqualTo(fc2.getFilters());
}
Also used : FilterSet(com.puppycrawl.tools.checkstyle.api.FilterSet) Test(org.junit.jupiter.api.Test)

Example 3 with FilterSet

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

the class SuppressionsLoaderTest method testSettingModuleId.

@Test
public void testSettingModuleId() throws Exception {
    final FilterSet fc = SuppressionsLoader.loadSuppressions(getPath("InputSuppressionsLoaderWithId.xml"));
    final SuppressFilterElement suppressElement = (SuppressFilterElement) fc.getFilters().toArray()[0];
    final String id = TestUtil.getInternalState(suppressElement, "moduleId");
    assertWithMessage("Id has to be defined").that(id).isEqualTo("someId");
}
Also used : FilterSet(com.puppycrawl.tools.checkstyle.api.FilterSet) Test(org.junit.jupiter.api.Test)

Example 4 with FilterSet

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

the class SuppressionsLoaderTest method testLoadFromUrl.

@Test
public void testLoadFromUrl() throws Exception {
    final String[] urlCandidates = { "https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/site/resources/" + "files/suppressions_none.xml", "https://checkstyle.org/files/suppressions_none.xml" };
    FilterSet actualFilterSet = null;
    for (String url : urlCandidates) {
        actualFilterSet = loadFilterSet(url);
        if (actualFilterSet != null) {
            break;
        }
    }
    assumeTrue(actualFilterSet != null, "No Internet connection.");
    final FilterSet expectedFilterSet = new FilterSet();
    assertWithMessage("Failed to load from url").that(actualFilterSet.getFilters()).isEqualTo(expectedFilterSet.getFilters());
}
Also used : FilterSet(com.puppycrawl.tools.checkstyle.api.FilterSet) Test(org.junit.jupiter.api.Test)

Example 5 with FilterSet

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

the class SuppressionsLoaderTest method testMultipleSuppression.

@Test
public void testMultipleSuppression() throws Exception {
    final FilterSet fc = SuppressionsLoader.loadSuppressions(getPath("InputSuppressionsLoaderMultiple.xml"));
    final FilterSet fc2 = new FilterSet();
    final SuppressFilterElement se0 = new SuppressFilterElement("file0", "check0", null, null, null, null);
    fc2.addFilter(se0);
    final SuppressFilterElement se1 = new SuppressFilterElement("file1", "check1", null, null, "1,2-3", null);
    fc2.addFilter(se1);
    final SuppressFilterElement se2 = new SuppressFilterElement("file2", "check2", null, null, null, "1,2-3");
    fc2.addFilter(se2);
    final SuppressFilterElement se3 = new SuppressFilterElement("file3", "check3", null, null, "1,2-3", "1,2-3");
    fc2.addFilter(se3);
    final SuppressFilterElement se4 = new SuppressFilterElement(null, null, "message0", null, null, null);
    fc2.addFilter(se4);
    assertWithMessage("Multiple suppressions were loaded incorrectly").that(fc.getFilters()).isEqualTo(fc2.getFilters());
}
Also used : FilterSet(com.puppycrawl.tools.checkstyle.api.FilterSet) Test(org.junit.jupiter.api.Test)

Aggregations

FilterSet (com.puppycrawl.tools.checkstyle.api.FilterSet)10 Test (org.junit.jupiter.api.Test)6 Test (org.junit.Test)2 Checker (com.puppycrawl.tools.checkstyle.Checker)1 DefaultConfiguration (com.puppycrawl.tools.checkstyle.DefaultConfiguration)1 AuditListener (com.puppycrawl.tools.checkstyle.api.AuditListener)1 CheckstyleException (com.puppycrawl.tools.checkstyle.api.CheckstyleException)1 Configuration (com.puppycrawl.tools.checkstyle.api.Configuration)1 Closeable (java.io.Closeable)1 File (java.io.File)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 URLClassLoader (java.net.URLClassLoader)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 MavenProject (org.apache.maven.project.MavenProject)1