Example usage for org.apache.commons.configuration BaseConfiguration BaseConfiguration

List of usage examples for org.apache.commons.configuration BaseConfiguration BaseConfiguration

Introduction

In this page you can find the example usage for org.apache.commons.configuration BaseConfiguration BaseConfiguration.

Prototype

BaseConfiguration

Source Link

Usage

From source file:org.sonar.plugins.csharp.gendarme.GendarmeSensorTest.java

@Test
public void testExecuteWithoutRule() throws Exception {
    RulesProfile rulesProfile = mock(RulesProfile.class);
    when(rulesProfile.getActiveRulesByRepository(anyString())).thenReturn(new ArrayList<ActiveRule>());
    GendarmeSensor sensor = new GendarmeSensor(null, rulesProfile, null, null,
            new CSharpConfiguration(new BaseConfiguration()), microsoftWindowsEnvironment);

    Project project = mock(Project.class);
    sensor.analyse(project, null);/*from   w w w.j a v a2  s  .  c om*/
    verify(project, never()).getName();
}

From source file:org.sonar.plugins.csharp.gendarme.GendarmeSensorTest.java

@Test
public void testLaunchGendarme() throws Exception {
    GendarmeSensor sensor = new GendarmeSensor(fileSystem, null, null, null,
            new CSharpConfiguration(new BaseConfiguration()), microsoftWindowsEnvironment);

    GendarmeRunner runner = mock(GendarmeRunner.class);
    when(runner.createCommandBuilder(solution, vsProject)).thenReturn(
            GendarmeCommandBuilder.createBuilder(solution, vsProject).setExecutable(new File("gendarme.exe")));
    Project project = mock(Project.class);
    when(project.getName()).thenReturn("Project #1");

    sensor.launchGendarme(project, runner, TestUtils.getResource("/Sensor/FakeGendarmeConfigFile.xml"));
    verify(runner).execute(any(GendarmeCommandBuilder.class), eq(10));
}

From source file:org.sonar.plugins.csharp.gendarme.GendarmeSensorTest.java

@Test
public void testShouldExecuteOnProject() throws Exception {
    Configuration conf = new BaseConfiguration();
    GendarmeSensor sensor = new GendarmeSensor(null, null, null, null, new CSharpConfiguration(conf),
            microsoftWindowsEnvironment);

    Project project = mock(Project.class);
    when(project.getName()).thenReturn("Project #1");
    when(project.getLanguageKey()).thenReturn("cs");
    assertTrue(sensor.shouldExecuteOnProject(project));

    conf.addProperty(GendarmeConstants.MODE, GendarmeConstants.MODE_SKIP);
    sensor = new GendarmeSensor(null, null, null, null, new CSharpConfiguration(conf),
            microsoftWindowsEnvironment);
    assertFalse(sensor.shouldExecuteOnProject(project));
}

From source file:org.sonar.plugins.csharp.gendarme.GendarmeSensorTest.java

@Test
public void testGenerateConfigurationFile() throws Exception {
    File sonarDir = new File("target/sonar");
    sonarDir.mkdirs();//ww  w . ja v a2  s.co  m
    ProjectFileSystem fileSystem = mock(ProjectFileSystem.class);
    when(fileSystem.getSonarWorkingDirectory()).thenReturn(sonarDir);
    GendarmeProfileExporter profileExporter = mock(GendarmeProfileExporter.class);
    doAnswer(new Answer<Object>() {

        public Object answer(InvocationOnMock invocation) throws IOException {
            FileWriter writer = (FileWriter) invocation.getArguments()[1];
            writer.write("Hello");
            return null;
        }
    }).when(profileExporter).exportProfile((RulesProfile) anyObject(), (FileWriter) anyObject());
    GendarmeSensor sensor = new GendarmeSensor(fileSystem, null, profileExporter, null,
            new CSharpConfiguration(new BaseConfiguration()), microsoftWindowsEnvironment);

    sensor.generateConfigurationFile();
    File report = new File(sonarDir, GendarmeConstants.GENDARME_RULES_FILE);
    assertTrue(report.exists());
    report.delete();
}

From source file:org.sonar.plugins.csharp.stylecop.StyleCopSensorTest.java

@Test
public void testShouldExecuteOnProject() throws Exception {
    VisualStudioProject vsProject = mock(VisualStudioProject.class);
    when(vsProject.getName()).thenReturn("Project #1");
    VisualStudioSolution solution = mock(VisualStudioSolution.class);
    when(solution.getProjects()).thenReturn(Lists.newArrayList(vsProject));

    MicrosoftWindowsEnvironment microsoftWindowsEnvironment = new MicrosoftWindowsEnvironment();
    microsoftWindowsEnvironment.setCurrentSolution(solution);

    Configuration conf = new BaseConfiguration();
    StyleCopSensor sensor = new StyleCopSensor(null, null, null, null, new CSharpConfiguration(conf),
            microsoftWindowsEnvironment);

    Project project = mock(Project.class);
    when(project.getLanguageKey()).thenReturn("cs");
    when(project.getName()).thenReturn("Project #1");
    assertTrue(sensor.shouldExecuteOnProject(project));

    conf.addProperty(StyleCopConstants.MODE, StyleCopConstants.MODE_SKIP);
    sensor = new StyleCopSensor(null, null, null, null, new CSharpConfiguration(conf),
            microsoftWindowsEnvironment);
    assertFalse(sensor.shouldExecuteOnProject(project));
}

From source file:org.sonar.plugins.csharp.stylecop.StyleCopSensorTest.java

@Test
public void testGenerateConfigurationFile() throws Exception {
    File sonarDir = new File("target/sonar");
    sonarDir.mkdirs();//from ww  w .j  a v  a  2s. c o m
    ProjectFileSystem fileSystem = mock(ProjectFileSystem.class);
    when(fileSystem.getSonarWorkingDirectory()).thenReturn(sonarDir);
    StyleCopProfileExporter profileExporter = mock(StyleCopProfileExporter.class);
    doAnswer(new Answer<Object>() {

        public Object answer(InvocationOnMock invocation) throws IOException {
            FileWriter writer = (FileWriter) invocation.getArguments()[1];
            writer.write("Hello");
            return null;
        }
    }).when(profileExporter).exportProfile((RulesProfile) anyObject(), (FileWriter) anyObject());
    StyleCopSensor sensor = new StyleCopSensor(fileSystem, null, profileExporter, null,
            new CSharpConfiguration(new BaseConfiguration()), null);

    sensor.generateConfigurationFile();
    File report = new File(sonarDir, StyleCopConstants.STYLECOP_RULES_FILE);
    assertTrue(report.exists());
    report.delete();
}

From source file:org.sonar.plugins.csharp.stylecop.StyleCopSensorTest.java

@Test(expected = SonarException.class)
public void testGenerateConfigurationFileWithUnexistingFolder() throws Exception {
    File sonarDir = new File("target/sonar/NON-EXISTING-FOLDER");
    ProjectFileSystem fileSystem = mock(ProjectFileSystem.class);
    when(fileSystem.getSonarWorkingDirectory()).thenReturn(sonarDir);
    StyleCopProfileExporter profileExporter = mock(StyleCopProfileExporter.class);
    doAnswer(new Answer<Object>() {

        public Object answer(InvocationOnMock invocation) throws IOException {
            FileWriter writer = (FileWriter) invocation.getArguments()[1];
            writer.write("Hello");
            return null;
        }/*from   w  w  w. j  a v a  2 s.c om*/
    }).when(profileExporter).exportProfile((RulesProfile) anyObject(), (FileWriter) anyObject());
    StyleCopSensor sensor = new StyleCopSensor(fileSystem, null, profileExporter, null,
            new CSharpConfiguration(new BaseConfiguration()), null);

    sensor.generateConfigurationFile();
}

From source file:org.sonar.plugins.cxx.CxxLanguageTest.java

@Test
public void shouldReturnConfiguredSuffixes() {
    Configuration config = new BaseConfiguration();
    config.setProperty(CxxPlugin.FILE_SUFFIXES_KEY, "C, c");
    CxxLanguage cxx = new CxxLanguage(config);

    String[] expected = { "C", "c" };
    assertThat(cxx.getFileSuffixes(), is(expected));
}

From source file:org.sonar.plugins.cxx.CxxLanguageTest.java

@Test
public void shouldFallbackToDefaultIfNoSuffixesConfigured() {
    Configuration config = new BaseConfiguration();
    CxxLanguage cxx = new CxxLanguage(config);
    String[] suffixes = cxx.getFileSuffixes();
    assert (suffixes != null);
    assert (suffixes.length > 0);
}

From source file:org.sonar.plugins.delphi.core.helpers.DelphiProjectHelperTest.java

@Test
public void shouldReturnDefaultValueForImportSources() {
    Configuration configuration = new BaseConfiguration();
    DelphiProjectHelper helper = new DelphiProjectHelper(configuration, null);
    assertThat(helper.getImportSources(), is(true));
}