Search in sources :

Example 56 with MapSettings

use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.

the class DeleteActionTest method setUp.

@Before
public void setUp() {
    defaultGroup = db.users().insertGroup(db.getDefaultOrganization(), CoreProperties.CORE_DEFAULT_GROUP_DEFAULT_VALUE);
    Settings settings = new MapSettings().setProperty(CoreProperties.CORE_DEFAULT_GROUP, CoreProperties.CORE_DEFAULT_GROUP_DEFAULT_VALUE);
    ws = new WsTester(new UserGroupsWs(new DeleteAction(db.getDbClient(), userSession, newGroupWsSupport(), settings, defaultOrganizationProvider)));
}
Also used : MapSettings(org.sonar.api.config.MapSettings) WsTester(org.sonar.server.ws.WsTester) Settings(org.sonar.api.config.Settings) MapSettings(org.sonar.api.config.MapSettings) Before(org.junit.Before)

Example 57 with MapSettings

use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.

the class DefaultHttpDownloaderTest method readStringWithDefaultTimeout.

@Test
public void readStringWithDefaultTimeout() throws URISyntaxException {
    String text = new DefaultHttpDownloader(new MapSettings()).readString(new URI(baseUrl + "/timeout/"), StandardCharsets.UTF_8);
    assertThat(text.length()).isGreaterThan(10);
}
Also used : MapSettings(org.sonar.api.config.MapSettings) URI(java.net.URI) Test(org.junit.Test)

Example 58 with MapSettings

use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.

the class DefaultHttpDownloaderTest method userAgent_is_static_value_when_server_is_not_provided.

@Test
public void userAgent_is_static_value_when_server_is_not_provided() throws URISyntaxException, IOException {
    InputStream stream = new DefaultHttpDownloader(new MapSettings()).openStream(new URI(baseUrl));
    Properties props = new Properties();
    props.load(stream);
    stream.close();
    assertThat(props.getProperty("agent")).isEqualTo("SonarQube");
}
Also used : MapSettings(org.sonar.api.config.MapSettings) InputStream(java.io.InputStream) Properties(java.util.Properties) CoreProperties(org.sonar.api.CoreProperties) URI(java.net.URI) Test(org.junit.Test)

Example 59 with MapSettings

use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.

the class DefaultHttpDownloaderTest method configure_http_proxy_credentials.

@Test
public void configure_http_proxy_credentials() {
    DefaultHttpDownloader.AuthenticatorFacade system = mock(DefaultHttpDownloader.AuthenticatorFacade.class);
    Settings settings = new MapSettings();
    settings.setProperty("https.proxyHost", "1.2.3.4");
    settings.setProperty("http.proxyUser", "the_login");
    settings.setProperty("http.proxyPassword", "the_passwd");
    new DefaultHttpDownloader.BaseHttpDownloader(system, settings, null);
    verify(system).setDefaultAuthenticator(argThat(new TypeSafeMatcher<Authenticator>() {

        @Override
        protected boolean matchesSafely(Authenticator authenticator) {
            DefaultHttpDownloader.ProxyAuthenticator a = (DefaultHttpDownloader.ProxyAuthenticator) authenticator;
            PasswordAuthentication authentication = a.getPasswordAuthentication();
            return authentication.getUserName().equals("the_login") && new String(authentication.getPassword()).equals("the_passwd");
        }

        @Override
        public void describeTo(Description description) {
        }
    }));
}
Also used : TypeSafeMatcher(org.hamcrest.TypeSafeMatcher) Description(org.hamcrest.Description) MapSettings(org.sonar.api.config.MapSettings) Settings(org.sonar.api.config.Settings) MapSettings(org.sonar.api.config.MapSettings) Authenticator(java.net.Authenticator) PasswordAuthentication(java.net.PasswordAuthentication) Test(org.junit.Test)

Example 60 with MapSettings

use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.

the class DefaultHttpDownloaderTest method downloadBytes.

@Test
public void downloadBytes() throws URISyntaxException {
    byte[] bytes = new DefaultHttpDownloader(new MapSettings()).readBytes(new URI(baseUrl));
    assertThat(bytes.length).isGreaterThan(10);
}
Also used : MapSettings(org.sonar.api.config.MapSettings) URI(java.net.URI) Test(org.junit.Test)

Aggregations

MapSettings (org.sonar.api.config.MapSettings)98 Test (org.junit.Test)75 Settings (org.sonar.api.config.Settings)36 Before (org.junit.Before)20 URI (java.net.URI)13 Languages (org.sonar.api.resources.Languages)9 DefaultLanguagesRepository (org.sonar.scanner.repository.language.DefaultLanguagesRepository)9 LanguagesRepository (org.sonar.scanner.repository.language.LanguagesRepository)8 File (java.io.File)7 SensorStorage (org.sonar.api.batch.sensor.internal.SensorStorage)7 FileExclusions (org.sonar.api.scan.filesystem.FileExclusions)6 Properties (java.util.Properties)5 IndexedFile (org.sonar.api.batch.fs.IndexedFile)5 DefaultFileSystem (org.sonar.api.batch.fs.internal.DefaultFileSystem)5 DefaultIndexedFile (org.sonar.api.batch.fs.internal.DefaultIndexedFile)5 PropertyDefinitions (org.sonar.api.config.PropertyDefinitions)5 InputFile (org.sonar.api.batch.fs.InputFile)4 InputStream (java.io.InputStream)3 Description (org.hamcrest.Description)3 CoreProperties (org.sonar.api.CoreProperties)3