Example #1
0
 void store() {
   GlobalCheckstyleSettings.INSTANCE.setCheckstyleConfigurationPath(
       checkstyleConfiguration.getConfigFilePath());
   GlobalCheckstyleSettings.INSTANCE.setPropertiesPath(
       checkstyleConfiguration.getPropertiesFilePath());
   GlobalCheckstyleSettings.INSTANCE.setProperties(checkstyleConfiguration.getProperties());
   GlobalCheckstyleSettings.INSTANCE.flush();
 }
  @Test
  public void writeConfigurationToWorkingDir() throws IOException {
    Project project =
        MavenTestUtils.loadProjectFromPom(getClass(), "writeConfigurationToWorkingDir/pom.xml");

    CheckstyleProfileExporter exporter = new FakeExporter();
    CheckstyleConfiguration configuration =
        new CheckstyleConfiguration(null, exporter, null, project.getFileSystem());
    File xmlFile = configuration.getXMLDefinitionFile();

    assertThat(xmlFile.exists(), is(true));
    assertThat(FileUtils.readFileToString(xmlFile), is("<conf/>"));
  }
Example #3
0
 void load() {
   FileObject checkstyleConfigurationFile =
       GlobalCheckstyleSettings.INSTANCE.getCheckstyleConfigurationFile();
   String cleanAbsoluteFile = FileUtil.toFile(checkstyleConfigurationFile).getAbsolutePath();
   checkstyleConfiguration.setConfigFilePath(cleanAbsoluteFile);
   FileObject checkstylePropertiesFile = GlobalCheckstyleSettings.INSTANCE.getPropertiesFile();
   if (null != checkstylePropertiesFile) {
     String propertiesFilePath = FileUtil.toFile(checkstylePropertiesFile).getAbsolutePath();
     checkstyleConfiguration.setPropertiesFilePath(propertiesFilePath);
   } else {
     checkstyleConfiguration.setPropertiesFilePath("");
   }
   checkstyleConfiguration.setProperties(
       GlobalCheckstyleSettings.INSTANCE.getPropertiesAsString());
 }