本文整理汇总了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);
}
示例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));
}
示例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);
}
示例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);
}
示例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");
}
示例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);
}
示例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");
}
示例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);
}
示例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");
}
示例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");
}
示例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");
}
示例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"));
}
示例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();
}
示例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());
}
示例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());
}