当前位置: 首页>>代码示例>>Java>>正文


Java Settings.setProperty方法代码示例

本文整理汇总了Java中org.sonar.api.config.Settings.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java Settings.setProperty方法的具体用法?Java Settings.setProperty怎么用?Java Settings.setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.sonar.api.config.Settings的用法示例。


在下文中一共展示了Settings.setProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCheckstyleConfiguration

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void getCheckstyleConfiguration() throws Exception {
    fileSystem.setEncoding(StandardCharsets.UTF_8);
    final Settings settings = new Settings(new PropertyDefinitions(
            new CheckstylePlugin().getExtensions()));
    settings.setProperty(CheckstyleConstants.CHECKER_FILTERS_KEY,
            CheckstyleConstants.CHECKER_FILTERS_DEFAULT_VALUE);

    final RulesProfile profile = RulesProfile.create("sonar way", "java");

    final Rule rule = Rule.create("checkstyle", "CheckStyleRule1", "checkstyle rule one");
    rule.setConfigKey("checkstyle/rule1");
    profile.activateRule(rule, null);

    final CheckstyleConfiguration configuration = new CheckstyleConfiguration(settings,
            new CheckstyleProfileExporter(settings), profile, fileSystem);
    final Configuration checkstyleConfiguration = configuration.getCheckstyleConfiguration();
    assertThat(checkstyleConfiguration).isNotNull();
    assertThat(checkstyleConfiguration.getAttribute("charset")).isEqualTo("UTF-8");
    final File xmlFile = new File("checkstyle.xml");
    assertThat(xmlFile.exists()).isTrue();

    FileUtils.forceDelete(xmlFile);
}
 
开发者ID:checkstyle,项目名称:sonar-checkstyle,代码行数:26,代码来源:CheckstyleConfigurationTest.java

示例2: prepare

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
@Before
public void prepare() throws Exception {
  pullRequestFacade = mock(PullRequestFacade.class);
  Settings settings = new Settings(new PropertyDefinitions(PropertyDefinition.builder(CoreProperties.SERVER_BASE_URL)
    .name("Server base URL")
    .description("HTTP URL of this SonarQube server, such as <i>http://yourhost.yourdomain/sonar</i>. This value is used i.e. to create links in emails.")
    .category(CoreProperties.CATEGORY_GENERAL)
    .defaultValue(CoreProperties.SERVER_BASE_URL_DEFAULT_VALUE)
    .build()));
  GitHubPluginConfiguration config = new GitHubPluginConfiguration(settings, new System2());
  context = mock(PostJobContext.class);

  settings.setProperty("sonar.host.url", "http://192.168.0.1");
  settings.setProperty(CoreProperties.SERVER_BASE_URL, "http://myserver");
  pullRequestIssuePostJob = new PullRequestIssuePostJob(config, pullRequestFacade, new MarkDownUtils(settings));
}
 
开发者ID:SonarSource,项目名称:sonar-github,代码行数:17,代码来源:PullRequestIssuePostJobTest.java

示例3: testWithExternallyProvidedDomainWithProviders1

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
/**
 * Scenario:
 *   a) Domain is provided in sonar.properties.
 *   b) one srv records available for the domain.
 * @throws Exception
 */
@Test
public void testWithExternallyProvidedDomainWithProviders1() throws Exception {
    final String externallyProvidedDomain = "users.mycompany.com";
    final String externallyProvidedDomainDN = "DC=users,DC=mycompany,DC=com";
    setupMocks(externallyProvidedDomain, Arrays.asList("0 100 389 ldap.mycompany.com"));

    Settings settings = new Settings();
    settings.setProperty("sonar.ad.domain", externallyProvidedDomain);
    ADSettings adSettings = new ADSettings(settings);
    adSettings.load();

    assertEquals("fetchProviderList failed.", adSettings.getProviderList().size(), 1);
    Iterator<ADServerEntry> providers = adSettings.getProviderList().iterator();
    assertEquals("fetchProviderList failed.", providers.next(), new ADServerEntry(0, 100, "ldap.mycompany.com", 389));
    assertEquals("Domain identifcation failed.", adSettings.getDnsDomain(), externallyProvidedDomain);
    assertEquals("DomainDN construction failed.", adSettings.getDnsDomainDN(), externallyProvidedDomainDN);
}
 
开发者ID:programmingforliving,项目名称:sonar-ad-plugin,代码行数:24,代码来源:ADSettingsTest.java

示例4: testWithExternallyProvidedDomainWithProviders2

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
/**
 * Scenario:
 *   a) Domain is provided in sonar.properties.
 *   b) two srv records available for the domain.
 * @throws Exception
 */
@Test
public void testWithExternallyProvidedDomainWithProviders2() throws Exception {
    final String externallyProvidedDomain = "users.mycompany.com";
    final String externallyProvidedDomainDN = "DC=users,DC=mycompany,DC=com";
    setupMocks(externallyProvidedDomain, Arrays.asList("0 1 389 ldap1.mycompany.com", "1 1 389 ldap2.mycompany.com"));

    Settings settings = new Settings();
    settings.setProperty("sonar.ad.domain", externallyProvidedDomain);
    ADSettings adSettings = new ADSettings(settings);
    adSettings.load();

    assertEquals("fetchProviderList failed.", adSettings.getProviderList().size(), 2);
    Iterator<ADServerEntry> providers = adSettings.getProviderList().iterator();
    assertEquals("fetchProviderList order failed.", providers.next(), new ADServerEntry(0,  1, "ldap1.mycompany.com", 389));
    assertEquals("fetchProviderList order failed.", providers.next(), new ADServerEntry(1,  1, "ldap2.mycompany.com", 389));
    assertEquals("Domain identifcation failed.", adSettings.getDnsDomain(), externallyProvidedDomain);
    assertEquals("DomainDN construction failed.", adSettings.getDnsDomainDN(), externallyProvidedDomainDN);
}
 
开发者ID:programmingforliving,项目名称:sonar-ad-plugin,代码行数:25,代码来源:ADSettingsTest.java

示例5: testAnnotateParams

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
@Test
public void testAnnotateParams() throws IOException {
  DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo")
    .setAbsolutePath(new File(baseDir, "src/foo.xoo").getAbsolutePath())
    .setLines(7);

  CvsCommandExecutor commandExecutor = mock(CvsCommandExecutor.class);
  Settings settings = new Settings(new PropertyDefinitions(CvsConfiguration.getProperties()));
  TempFolder tempFolder = mock(TempFolder.class);
  File tmp = new File("tmpcvs");
  when(tempFolder.newDir("cvs")).thenReturn(tmp);
  CvsBlameCommand cvsBlameCommand = new CvsBlameCommand(new CvsConfiguration(settings), tempFolder, commandExecutor);

  assertThat(cvsBlameCommand.buildAnnotateArguments(inputFile)).containsExactly("src/foo.xoo");

  settings.setProperty(CvsConfiguration.REV_PROP_KEY, "my-branch");
  assertThat(cvsBlameCommand.buildAnnotateArguments(inputFile)).containsExactly("-r", "my-branch", "src/foo.xoo");
}
 
开发者ID:SonarSource,项目名称:sonar-scm-cvs,代码行数:19,代码来源:CvsBlameCommandTest.java

示例6: init

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
@Before
public void init() throws Exception {
  sonarIssue = new DefaultIssue()
    .setKey("ABCD")
    .setMessage("The Cyclomatic Complexity of this method is 14 which is greater than 10 authorized.")
    .setSeverity("MINOR")
    .setRuleKey(RuleKey.of("squid", "CycleBetweenPackages"));

  ruleFinder = mock(RuleFinder.class);
  when(ruleFinder.findByKey(RuleKey.of("squid", "CycleBetweenPackages"))).thenReturn(org.sonar.api.rules.Rule.create().setName("Avoid cycle between java packages"));

  settings = new Settings(new PropertyDefinitions(JiraIssueCreator.class, JiraPlugin.class));
  settings.setProperty(CoreProperties.SERVER_BASE_URL, "http://my.sonar.com");
  settings.setProperty(JiraConstants.SERVER_URL_PROPERTY, "http://my.jira.com");
  settings.setProperty(JiraConstants.USERNAME_PROPERTY, "foo");
  settings.setProperty(JiraConstants.PASSWORD_PROPERTY, "bar");
  settings.setProperty(JiraConstants.JIRA_PROJECT_KEY_PROPERTY, "TEST");

  jiraIssueCreator = new JiraIssueCreator(ruleFinder);
}
 
开发者ID:aifraenkel,项目名称:caltec-tools,代码行数:21,代码来源:JiraIssueCreatorTest.java

示例7: should_return_file_suffixes

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
@Test
public void should_return_file_suffixes() {

    Settings settings = new MapSettings();
    OneC language = new OneC(settings);

    // default
    assertThat(language.getFileSuffixes()).containsOnly(".1s");

    settings.setProperty(OneCPlugin.FILE_SUFFIXES_KEY, "");
    assertThat(language.getFileSuffixes()).containsOnly(".1s");

    settings.setProperty(OneCPlugin.FILE_SUFFIXES_KEY, ".bar, .foo");
    assertThat(language.getFileSuffixes()).containsOnly(".bar", ".foo");
}
 
开发者ID:antowski,项目名称:sonar-onec,代码行数:16,代码来源:OneCTest.java

示例8: test

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
@Test
public void test() throws ReflectiveOperationException, IOException {
	final Settings settings = new MapSettings();
	final JavaSensor subject = new JavaSensor(settings);

	final File baseDir = new File("./src/test/java");
	System.out.println("Base directory for scanning: " + baseDir.getCanonicalPath());
	StringBuilder libraries = new StringBuilder(); 
	for(String lib : System.getProperty("java.class.path").split(File.pathSeparator)) {
		try {
			Paths.get(lib);
			if(libraries.length() !=0) {
				libraries.append(',');
			}
			libraries.append(lib);
		} catch(InvalidPathException e) {
			// Eclipse add something weird to the classpath. Just ignore it
		}
	}
	
	System.out.println("Libraries: " + libraries);
	settings.setProperty(JavaClasspathProperties.SONAR_JAVA_LIBRARIES, libraries.toString());

	final SensorContextTester context = SensorContextTester.create(baseDir);
	addInputFile(context.fileSystem(), "Foo.java");
	addInputFile(context.fileSystem(), "Bar.java");
	addInputFile(context.fileSystem(), "package-info.java");

	addInputFile(context.fileSystem(), "quux/Xed.java");
	addInputFile(context.fileSystem(), "quux/Yon.java");
	addInputFile(context.fileSystem(), "quux/Zed.java");
	addInputFile(context.fileSystem(), "quux/package-info.java");

	final Method method = JavaSensor.class.getDeclaredMethod("buildModel", SensorContext.class);
	method.setAccessible(true);
	@SuppressWarnings("unchecked")
	final Model<Location> model = (Model<Location>) method.invoke(subject, context);

	Model.print(model, System.out);
}
 
开发者ID:willemsrb,项目名称:sonar-packageanalyzer-plugin,代码行数:41,代码来源:JavaSensorTest.java

示例9: custom_file_suffixes

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
@Test
public void custom_file_suffixes() {
  Settings settings = new Settings();
  settings.setProperty("sonar.css.file.suffixes", "css,css3");

  CssLanguage language = new CssLanguage(settings);
  assertThat(language.getFileSuffixes()).containsOnly("css", "css3");
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:9,代码来源:CssLanguageTest.java

示例10: custom_file_suffixes

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
@Test
public void custom_file_suffixes() {
  Settings settings = new Settings();
  settings.setProperty("sonar.less.file.suffixes", "less,less3");

  LessLanguage language = new LessLanguage(settings);
  assertThat(language.getFileSuffixes()).containsOnly("less", "less3");
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:9,代码来源:LessLanguageTest.java

示例11: custom_file_suffixes

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
@Test
public void custom_file_suffixes() {
  Settings settings = new Settings();
  settings.setProperty("sonar.scss.file.suffixes", "scss,scss3");

  ScssLanguage language = new ScssLanguage(settings);
  assertThat(language.getFileSuffixes()).containsOnly("scss", "scss3");
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:9,代码来源:ScssLanguageTest.java

示例12: getTargetXmlReport

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
@Test
public void getTargetXmlReport() {
    final Settings settings = new Settings();
    final CheckstyleConfiguration configuration = new CheckstyleConfiguration(settings,
            null, null, fileSystem);
    assertThat(configuration.getTargetXmlReport()).isNull();

    final Settings settings2 = new Settings();
    settings2.setProperty(CheckstyleConfiguration.PROPERTY_GENERATE_XML, "true");
    final CheckstyleConfiguration configuration2 = new CheckstyleConfiguration(settings2,
            null, null, fileSystem);
    assertThat(configuration2.getTargetXmlReport()).isEqualTo(
            new File(fileSystem.workDir(), "checkstyle-result.xml"));
}
 
开发者ID:checkstyle,项目名称:sonar-checkstyle,代码行数:15,代码来源:CheckstyleConfigurationTest.java

示例13: testCustomSettings

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
@Test
public void testCustomSettings() {
    Settings settings = new MapSettings();
    settings.setProperty(PerlPlugin.FILE_SUFFIXES_KEY, "file,,other");
    PerlLanguage lang = new PerlLanguage(settings);
    assertThat(lang.getFileSuffixes()).isEqualTo(new String[] {"file","other"});
    assertThat(lang.hasValidSuffixes("my.file")).isTrue();
}
 
开发者ID:sonar-perl,项目名称:sonar-perl,代码行数:9,代码来源:PerlLanguageTest.java

示例14: run

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
@Test
public void run() throws IOException {
	TemporaryFolder folder = new TemporaryFolder();
	folder.create();
	Settings settings = new Settings();
	settings.setProperty(Constants.PLUGIN_SKIP_CUSTOM_RULES, false);
	String dirPath = "..\\grammars\\tsql";
	File dir = new File(dirPath);
	Collection<File> files = FileUtils.listFiles(dir, new String[] { "sql" }, true);
	SensorContextTester ctxTester = SensorContextTester.create(folder.getRoot());
	for (File f : files) {
		String tempName = f.getName() + System.nanoTime();
		File dest = folder.newFile(tempName);
		FileUtils.copyFile(f, dest);

		DefaultInputFile file1 = new DefaultInputFile("test", tempName);
		file1.initMetadata(new String(Files.readAllBytes(f.toPath())));
		file1.setLanguage(TSQLLanguage.KEY);
		ctxTester.fileSystem().add(file1);

	}
	HighlightingSensor sensor = new HighlightingSensor(settings);
	sensor.execute(ctxTester);
	Collection<Issue> issues = ctxTester.allIssues();
	// System.out.println(files.size() + " " + issues.size() + " " + took);
	Assert.assertEquals(97, issues.size());

}
 
开发者ID:gretard,项目名称:sonar-tsql-plugin,代码行数:29,代码来源:PluginRulesVerifierTest.java

示例15: testDefinedSuffixes

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
@Test
public void testDefinedSuffixes() {
	final Settings settings = new Settings();
	settings.setProperty(Constants.PLUGIN_SUFFIXES, ".sql,.test");
	final TSQLLanguage language = new TSQLLanguage(settings);
	Assert.assertArrayEquals(new String[] { ".sql", ".test" }, language.getFileSuffixes());
}
 
开发者ID:gretard,项目名称:sonar-tsql-plugin,代码行数:8,代码来源:TSQLLanguageTest.java


注:本文中的org.sonar.api.config.Settings.setProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。