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

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

Introduction

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

Prototype

public MapConfiguration(Map map) 

Source Link

Document

Create a Configuration decorator around the specified Map.

Usage

From source file:org.sonar.api.batch.AbstractSourceImporterTest.java

private void fileEncodingTest(Project project, SensorContext context, String encoding, String testFile)
        throws Exception {
    ProjectFileSystem fileSystem = mock(ProjectFileSystem.class);
    when(project.getFileSystem()).thenReturn(fileSystem);
    when(fileSystem.getSourceCharset()).thenReturn(Charset.forName(encoding));
    when(project.getConfiguration()).thenReturn(new MapConfiguration(new HashMap<String, String>()));
    when(fileSystem.getSourceFiles(any(Language.class))).thenReturn(newArrayList(getFile(testFile)));

    importer.shouldExecuteOnProject(project);
    importer.analyse(project, context);/*from   w  ww . jav a  2 s.  co  m*/

    verify(context).saveSource(eq(FakeSourceImporter.TEST_RESOURCE), argThat(new ArgumentMatcher<String>() {
        @Override
        public boolean matches(Object arg0) {
            String source = (String) arg0;
            return source.contains(aClaess) && source.contains(explicacao);
        }
    }));
}

From source file:org.sonar.api.test.MavenTestUtils.java

public static Project loadProjectFromPom(Class clazz, String path) {
    MavenProject pom = loadPom(clazz, path);
    Configuration configuration = new MapConfiguration(pom.getProperties());
    Project project = new Project(pom.getGroupId() + ":" + pom.getArtifactId()).setPom(pom)
            .setConfiguration(configuration);
    configuration.setProperty("sonar.java.source", MavenUtils.getJavaSourceVersion(pom));
    configuration.setProperty("sonar.java.target", MavenUtils.getJavaVersion(pom));
    configuration.setProperty(CoreProperties.ENCODING_PROPERTY, MavenUtils.getSourceEncoding(pom));

    project.setFileSystem(new MavenModuleFileSystem(pom));
    return project;
}

From source file:org.sonar.batch.MavenProjectBuilder.java

Configuration getStartupConfiguration(MavenProject pom) {
    CompositeConfiguration configuration = new CompositeConfiguration();
    configuration.addConfiguration(new SystemConfiguration());
    configuration.addConfiguration(new EnvironmentConfiguration());
    configuration.addConfiguration(new MapConfiguration(pom.getModel().getProperties()));
    return configuration;
}

From source file:org.sonar.batch.ProjectConfiguration.java

private void loadMavenSettings(MavenProject pom) {
    addConfiguration(new MapConfiguration(pom.getModel().getProperties()));
}

From source file:org.sonar.batch.ProjectModule.java

private Project createProject(ProjectDefinition projectDefinition) {
    Configuration conf = new MapConfiguration(projectDefinition.getProperties());
    Project project = new Project(conf.getString(CoreProperties.PROJECT_KEY_PROPERTY));
    project.setLanguageKey(Java.KEY);//from  w  ww  .  ja va  2s.co m
    project.setLanguage(Java.INSTANCE);
    project.setConfiguration(conf);
    return project;
}

From source file:org.sonar.maven.SonarMojo.java

private Configuration getInitialConfiguration() {
    CompositeConfiguration configuration = new CompositeConfiguration();
    configuration.addConfiguration(new SystemConfiguration());
    configuration.addConfiguration(new EnvironmentConfiguration());
    configuration.addConfiguration(new MapConfiguration(project.getModel().getProperties()));
    return configuration;
}

From source file:org.sonar.plugins.ideainspections.IdeaExecutorTest.java

private IdeaConfiguration buildConf() {
    IdeaProfileExporter mockExporter = new IdeaProfileExporter();
    RulesProfile profile = createSimpleProfile();
    Project project = mock(Project.class);

    final HashMap<String, Object> map = new HashMap<String, Object>();
    map.put(IdeaConstants.IDEA_HOME_KEY, new File(System.getProperty("user.home"), "intellij").toString());
    map.put(IdeaConstants.JDK_HOME_KEY, "/System/Library/Frameworks/JavaVM.framework/Home/");

    when(project.getConfiguration()).thenReturn(new MapConfiguration(map));
    when(project.getFileSystem())// ww w .  j  a  v  a 2 s  . c o  m
            .thenReturn(new SimpleProjectFileSystem(new File(getBaseDir(), "test-resources")));
    when(project.getArtifactId()).thenReturn("TestProject");
    return new IdeaConfiguration(mockExporter, profile, project);
}

From source file:org.sonar.plugins.jmeter.JMeterSensorTest.java

@Test
public void testLocalJtlPathConfig() {
    Map<String, String> configMap = new HashMap<String, String>();
    configMap.put(JMeterPluginConst.LOCAL_JTL_PATH_PROPERTY, "classpath:/test-http.jtl.xml");

    Project project = new Project("test-http-key", "", "test-http"); // Force "test-http" as config name
    project.setConfiguration(new MapConfiguration(configMap));

    Assert.assertNotNull(sensor.getGlobalSummary(project));
}

From source file:org.sonar.plugins.mantis.MantisSensorTest.java

@Test
public void testAnalyse() {
    SensorContext context = mock(MockSensorContext.class, new CallsRealMethods());
    Project project = mock(Project.class);
    Map<String, String> config = new HashMap<String, String>();
    config.put(MantisPlugin.SERVER_URL_PROPERTY, "http://localhost:1234/mantis/");
    config.put(MantisPlugin.USERNAME_PROPERTY, "jer");
    config.put(MantisPlugin.PASSWORD_PROPERTY, "pwd");
    config.put(MantisPlugin.PROJECTNAME_PROPERTY, "myproject");
    config.put(MantisPlugin.FILTER_PROPERTY, "current-version");
    when(project.getConfiguration()).thenReturn(new MapConfiguration(config));
    sensor.analyse(project, context);/* ww w.  j  ava 2  s  . com*/
    assertThat(context.getMeasure(MantisMetrics.PRIORITIES).getValue(), is(Double.valueOf(1000)));
    assertThat(context.getMeasure(MantisMetrics.PRIORITIES).getData(),
            is("low=200;normal=200;high=200;urgent=200;immediate=200"));
    assertThat(context.getMeasure(MantisMetrics.STATUS).getValue(), is(Double.valueOf(1000)));
    assertThat(context.getMeasure(MantisMetrics.STATUS).getData(), is(
            "new=125;feedback=125;acknowledged=125;confirmed=125;assigned=125;resolved=125;validated=125;closed=125"));
    assertThat(context.getMeasure(MantisMetrics.DEVELOPERS).getValue(), is(Double.valueOf(1000)));
    assertThat(context.getMeasure(MantisMetrics.DEVELOPERS).getData(), is(
            "user1=50;user10=50;user11=50;user12=50;user13=50;user14=50;user15=50;user16=50;user17=50;user18=50;user19=50;user2=50;user20=50;user3=50;user4=50;user5=50;user6=50;user7=50;user8=50;user9=50"));
}

From source file:org.sonar.plugins.web.AbstractWebPluginTester.java

protected Project loadProjectFromPom(File pomFile) throws Exception {
    MavenProject pom = loadPom(pomFile);
    Project project = new Project(pom.getGroupId() + ":" + pom.getArtifactId()).setPom(pom)
            .setConfiguration(new MapConfiguration(pom.getProperties()));
    project.setPom(pom);/* w  w w  .j  a va2  s .  com*/
    project.setLanguageKey(Web.INSTANCE.getKey());
    project.setLanguage(Web.INSTANCE);

    return project;
}