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


Java Settings类代码示例

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


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

示例1: testExecute

import org.sonar.api.config.Settings; //导入依赖的package包/类
@Test
public void testExecute() throws IOException, InterruptedException {

	File baseFile = folder.newFile("test.ps1");

	FileUtils.copyURLToFile(getClass().getResource("/testFiles/test.ps1"), baseFile);

	DefaultFileSystem fs = new DefaultFileSystem(folder.getRoot());
	DefaultInputFile ti = new DefaultInputFile("test", "test.ps1");
	ti.initMetadata(new String(Files.readAllBytes(baseFile.toPath())));
	ti.setLanguage(PowershellLanguage.KEY);
	fs.add(ti);

	SensorContextTester ctxTester = SensorContextTester.create(folder.getRoot());
	ctxTester.setFileSystem(fs);
	TokenizerSensor s = new TokenizerSensor(new Settings(), temp);
	s.execute(ctxTester);
	Assert.assertEquals(16, ctxTester.cpdTokens("test:test.ps1").size());
	Assert.assertEquals(1, ctxTester.highlightingTypeAt("test:test.ps1", 1, 5).size());

}
 
开发者ID:gretard,项目名称:sonar-ps-plugin,代码行数:22,代码来源:TokenizerSensorTest.java

示例2: 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

示例3: runGetUserDetailsFromWindowsAccountTest

import org.sonar.api.config.Settings; //导入依赖的package包/类
private void runGetUserDetailsFromWindowsAccountTest(IWindowsAccount windowsAccount, boolean isCompatibilityModeEnabled,
  boolean isAuthenticatorDownCase, UserDetails expectedUserDetails) {
  windowsAuthSettings = new WindowsAuthSettings(new Settings()
    .setProperty(WindowsAuthSettings.LDAP_WINDOWS_COMPATIBILITY_MODE, Boolean.toString(isCompatibilityModeEnabled))
    .setProperty(WindowsAuthSettings.SONAR_AUTHENTICATOR_LOGIN_DOWNCASE, Boolean.toString(isAuthenticatorDownCase)));

  Map<String, String> attributesUserDetails = null;
  if (expectedUserDetails != null) {
    attributesUserDetails = new HashMap<String, String>();
    attributesUserDetails.put(windowsAuthSettings.getLdapUserRealNameAttribute(), expectedUserDetails.getName());
    attributesUserDetails.put(AdConnectionHelper.MAIL_ATTRIBUTE, expectedUserDetails.getEmail());
  }

  Collection<String> attributeNames = new ArrayList<>();
  attributeNames.add(windowsAuthSettings.getLdapUserRealNameAttribute());
  attributeNames.add(AdConnectionHelper.MAIL_ATTRIBUTE);
  Mockito.when(adConnectionHelper.getUserDetails(windowsAccount.getDomain(), windowsAccount.getName(), attributeNames)).thenReturn(attributesUserDetails);

  authenticationHelper = new WindowsAuthenticationHelper(windowsAuthSettings, windowsAuthProvider, adConnectionHelper);

  assertThat(authenticationHelper.getUserDetails(windowsAccount)).isEqualToComparingFieldByField(expectedUserDetails);
}
 
开发者ID:SonarQubeCommunity,项目名称:sonar-activedirectory,代码行数:23,代码来源:WindowsAuthenticationHelperTest.java

示例4: defaults

import org.sonar.api.config.Settings; //导入依赖的package包/类
@Test
public void defaults() {
  Settings settings = new Settings();
  WindowsAuthSettings windowsAuthSettings = new WindowsAuthSettings(settings);

  Settings settingsWithBlankSettings = new Settings()
    .setProperty(WindowsAuthSettings.SONAR_AUTHENTICATOR_LOGIN_DOWNCASE, "")
    .setProperty(WindowsAuthSettings.LDAP_WINDOWS_AUTH_SSO_PROTOCOLS, "")
    .setProperty(WindowsAuthSettings.LDAP_GROUP_ID_ATTRIBUTE, "")
    .setProperty(WindowsAuthSettings.LDAP_WINDOWS_COMPATIBILITY_MODE, "")
    .setProperty(WindowsAuthSettings.LDAP_WINDOWS_USER_REAL_NAME_ATTRIBUTE, "");
  WindowsAuthSettings windowsAuthSettingsWithBlankSettings = new WindowsAuthSettings(settingsWithBlankSettings);

  validateDefaultSettings(windowsAuthSettings);
  validateDefaultSettings(windowsAuthSettingsWithBlankSettings);
}
 
开发者ID:SonarQubeCommunity,项目名称:sonar-activedirectory,代码行数:17,代码来源:WindowsAuthSettingsTest.java

示例5: customSettings

import org.sonar.api.config.Settings; //导入依赖的package包/类
@Test
public void customSettings() {
  final boolean sonarAuthenticatorDownCase = false;
  final boolean sonarAuthenticatorGroupDownCase = false;
  final boolean sonarLdapWindowsCompatibilityMode = true;
  final String sonarLdapWindowsGroupIdAttribute = "userPrincipalName";
  final String protocols = "someProtocol1 someProtocol2";
  final String userRealNameAttribute = "someAttribute";

  Settings settings = new Settings()
    .setProperty(WindowsAuthSettings.LDAP_WINDOWS_GROUP_DOWNCASE, Boolean.toString(sonarAuthenticatorGroupDownCase))
    .setProperty(WindowsAuthSettings.SONAR_AUTHENTICATOR_LOGIN_DOWNCASE, Boolean.toString(sonarAuthenticatorDownCase))
    .setProperty(WindowsAuthSettings.LDAP_WINDOWS_COMPATIBILITY_MODE, Boolean.toString(sonarLdapWindowsCompatibilityMode))
    .setProperty(WindowsAuthSettings.LDAP_GROUP_ID_ATTRIBUTE, sonarLdapWindowsGroupIdAttribute)
    .setProperty(WindowsAuthSettings.LDAP_WINDOWS_AUTH_SSO_PROTOCOLS, protocols)
    .setProperty(WindowsAuthSettings.LDAP_WINDOWS_USER_REAL_NAME_ATTRIBUTE, userRealNameAttribute);

  WindowsAuthSettings windowsAuthSettings = new WindowsAuthSettings(settings);

  assertThat(windowsAuthSettings.getIsSonarAuthenticatorGroupDownCase()).isEqualTo(sonarAuthenticatorGroupDownCase);
  assertThat(windowsAuthSettings.getIsSonarAuthenticatorLoginDownCase()).isEqualTo(sonarAuthenticatorDownCase);
  assertThat(windowsAuthSettings.getIsLdapWindowsCompatibilityModeEnabled()).isEqualTo(sonarLdapWindowsCompatibilityMode);
  assertThat(windowsAuthSettings.getGroupIdAttribute()).isEqualTo(sonarLdapWindowsGroupIdAttribute);
  assertThat(windowsAuthSettings.getProtocols()).isEqualTo(protocols);
  assertThat(windowsAuthSettings.getLdapUserRealNameAttribute()).isEqualTo(userRealNameAttribute);
}
 
开发者ID:SonarQubeCommunity,项目名称:sonar-activedirectory,代码行数:27,代码来源:WindowsAuthSettingsTest.java

示例6: FlowSquidSensor

import org.sonar.api.config.Settings; //导入依赖的package包/类
public FlowSquidSensor(Settings settings, CheckFactory checkFactory, FileLinesContextFactory fileLinesContextFactory,
                        FileSystem fileSystem, ResourcePerspectives resourcePerspectives, PathResolver pathResolver) {
logger.debug("** FlowSquidSenser constructor");
this.settings = settings;
this.pathResolver = pathResolver;
   this.checks = checkFactory
     .<SquidCheck<Grammar>>create(CheckList.REPOSITORY_KEY)
     .addAnnotatedChecks((Iterable)CheckList.getChecks(settings.getBoolean(FlowPlugin.IGNORE_TOPLEVEL_KEY),false));
   this.nodeChecks = checkFactory
	      .<SquidCheck<Grammar>>create(CheckList.REPOSITORY_KEY)
	      .addAnnotatedChecks((Iterable)CheckList.getChecks(settings.getBoolean(FlowPlugin.IGNORE_TOPLEVEL_KEY), true));
   this.fileLinesContextFactory = fileLinesContextFactory;
   this.fileSystem = fileSystem;
   this.resourcePerspectives = resourcePerspectives;
   this.mainFilePredicates = fileSystem.predicates().and(
     fileSystem.predicates().hasLanguage(FlowLanguage.KEY),
     fileSystem.predicates().hasType(InputFile.Type.MAIN));
 }
 
开发者ID:I8C,项目名称:sonar-flow-plugin,代码行数:19,代码来源:FlowSquidSensor.java

示例7: testHighlighting2

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

	Settings settings = new Settings();

	File baseFile = folder.newFile("test.sql");
	FileUtils.write(baseFile, "SELECT * FROM dbo.test");

	DefaultInputFile file1 = new DefaultInputFile("test", "test.sql");

	file1.initMetadata(new String(Files.readAllBytes(baseFile.toPath())));
	file1.setLanguage(TSQLLanguage.KEY);

	SensorContextTester ctxTester = SensorContextTester.create(folder.getRoot());
	ctxTester.fileSystem().add(file1);
	HighlightingSensor sensor = new HighlightingSensor(settings);
	sensor.execute(ctxTester);

	Assert.assertEquals(1, ctxTester.highlightingTypeAt("test:test.sql", 1, 5).size());
	Assert.assertEquals(0, ctxTester.highlightingTypeAt("test:test.sql", 2, 0).size());
	Assert.assertEquals(0, ctxTester.highlightingTypeAt("test:test.sql", 5, 0).size());
	Assert.assertEquals(1, ctxTester.cpdTokens("test:test.sql").size());

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

示例8: GitLabPluginConfiguration

import org.sonar.api.config.Settings; //导入依赖的package包/类
public GitLabPluginConfiguration(Settings settings, System2 system2) {
    super();

    this.settings = settings;
    this.system2 = system2;

    String tempBaseUrl = settings.hasKey(CoreProperties.SERVER_BASE_URL) ? settings.getString(CoreProperties.SERVER_BASE_URL) : settings.getString("sonar.host.url");
    if (tempBaseUrl == null) {
        tempBaseUrl = "http://localhost:9090";
    }
    if (!tempBaseUrl.endsWith("/")) {
        tempBaseUrl += "/";
    }
    this.baseUrl = tempBaseUrl;

    LOG.info("GlobalWorkingDir {}", settings.getString(CoreProperties.GLOBAL_WORKING_DIRECTORY));
}
 
开发者ID:gabrie-allaigre,项目名称:sonar-gitlab-plugin,代码行数:18,代码来源:GitLabPluginConfiguration.java

示例9: readProjectConfigurations

import org.sonar.api.config.Settings; //导入依赖的package包/类
private static Map<String, ProjectConfiguration> readProjectConfigurations(Settings settings) {
	Map<String, ProjectConfiguration> projectConfigs = new HashMap<>();
	String[] projectIndexes = settings.getStringArray(SlackNotifierPlugin.SLACK_PROJECTS);
	LOG.info(MessageFormat.format("Project configurations: [{0}]", Arrays.toString(projectIndexes)));
	
	for (String projectIndex : projectIndexes) {
		String projectKey = settings.getString(getPropertyProjectKey(projectIndex));
		String projectChannel = settings.getString(getPropertyProjectChannel(projectIndex));
		if (projectKey == null || projectChannel == null) {
			LOG.info(MessageFormat.format("Invalid project configuration. Project key or channel name missing.Project Key = {0}, Channel name = {1}", projectKey, projectChannel));
			continue;
		}
		
		ProjectConfiguration projectConfig = new ProjectConfiguration(projectKey, projectChannel);
		LOG.info(MessageFormat.format("Found project configuration [key = {0}, channel={1}]", projectConfig.getKey(), projectConfig.getChannel()));
		projectConfigs.put(projectConfig.getKey(), projectConfig);
	}
	return projectConfigs;
}
 
开发者ID:astrebel,项目名称:sonar-slack-notifier-plugin,代码行数:20,代码来源:SlackNotificationChannel.java

示例10: 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

示例11: setUp

import org.sonar.api.config.Settings; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    this.file = new DefaultInputFile("", "src/test/existing.ts").setLanguage(TypeScriptLanguage.LANGUAGE_KEY);
    this.file.setLines(5);
    
    this.settings = mock(Settings.class);
    when(this.settings.getString(TypeScriptPlugin.SETTING_LCOV_REPORT_PATH)).thenReturn("lcovpath");

    this.parser = mock(LCOVParser.class);

    this.sensor = spy(new TsCoverageSensorImpl());
    this.context = SensorContextTester.create(new File(""));

    this.context.fileSystem().add(this.file);
    this.context.setSettings(this.settings);
    
    this.lcovFile = mock(File.class);
    when(this.lcovFile.isFile()).thenReturn(true);
    doReturn(this.lcovFile).when(this.sensor).getIOFile(any(File.class), eq("lcovpath"));
    doReturn(this.parser).when(this.sensor).getParser(eq(this.context), any(File[].class));
}
 
开发者ID:Pablissimo,项目名称:SonarTsPlugin,代码行数:22,代码来源:TsCoverageSensorImplTest.java

示例12: setupMocks

import org.sonar.api.config.Settings; //导入依赖的package包/类
private void setupMocks(final boolean hasProviders, final boolean hostHasFQN) throws Exception {
    whenNew(ADSettings.class).withAnyArguments().thenAnswer(new Answer<ADSettings>() {
        public ADSettings answer(InvocationOnMock invocation)
                throws Throwable {
            ADSettings adSettings = spy(new ADSettings((Settings) invocation.getArguments()[0]));
            TreeSet<ADServerEntry> providers = null;
            if (hasProviders)
                providers = new TreeSet<ADServerEntry>(Arrays.asList((new ADServerEntry(0, 1, "ldap.mycompany.com", 389))));
            doReturn(providers).when(adSettings).fetchProviderList(anyString());
            return adSettings;
        }
    });

    mockStatic(InetAddress.class);
    InetAddress mockInetAddress = mock(InetAddress.class);
    when(InetAddress.getLocalHost()).thenReturn(mockInetAddress);
    if (hostHasFQN)
        when(mockInetAddress.getCanonicalHostName()).thenReturn("mycomp.ad.mycompany.com");
    else
        when(mockInetAddress.getCanonicalHostName()).thenReturn("mycomputer");
}
 
开发者ID:programmingforliving,项目名称:sonar-ad-plugin,代码行数:22,代码来源:ADSecurityRealmTest.java

示例13: 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

示例14: 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

示例15: testAutoDiscoveryWithProviders

import org.sonar.api.config.Settings; //导入依赖的package包/类
/**
 * Scenario:
 *   a) auto-discovery of domain.
 *   b) two srv records available for the domain.
 * @throws Exception
 */
@Test
public void testAutoDiscoveryWithProviders() throws Exception {
    String hostName = "mycomp.users.mycompany.com";
    String domainName = hostName.substring(hostName.indexOf('.') + 1);
    String domainNameDN = "DC=" + domainName.replace(".", ",DC=");
    setupMocks(domainName, Arrays.asList("0 1 389 ldap1.mycompany.com", "1 1 389 ldap2.mycompany.com"));

    ADSettings adSettings = new ADSettings(new 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(), domainName);
    assertEquals("DomainDN construction failed.", adSettings.getDnsDomainDN(), domainNameDN);
}
 
开发者ID:programmingforliving,项目名称:sonar-ad-plugin,代码行数:24,代码来源:ADSettingsTest.java


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