Search in sources :

Example 1 with Server

use of org.sonar.api.platform.Server in project sonarqube by SonarSource.

the class DefaultHttpDownloaderTest method userAgent_includes_version_and_SERVER_ID_when_server_is_provided.

@Test
public void userAgent_includes_version_and_SERVER_ID_when_server_is_provided() throws URISyntaxException, IOException {
    Server server = mock(Server.class);
    when(server.getVersion()).thenReturn("2.2");
    MapSettings settings = new MapSettings();
    settings.setProperty(CoreProperties.SERVER_ID, "blablabla");
    InputStream stream = new DefaultHttpDownloader(server, settings).openStream(new URI(baseUrl));
    Properties props = new Properties();
    props.load(stream);
    stream.close();
    assertThat(props.getProperty("agent")).isEqualTo("SonarQube 2.2 # blablabla");
}
Also used : Server(org.sonar.api.platform.Server) 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 2 with Server

use of org.sonar.api.platform.Server in project sonarqube by SonarSource.

the class MacroInterpreterTest method setUp.

@Before
public void setUp() {
    Server server = mock(Server.class);
    when(server.getContextPath()).thenReturn(path);
    interpreter = new MacroInterpreter(server);
}
Also used : Server(org.sonar.api.platform.Server) Before(org.junit.Before)

Example 3 with Server

use of org.sonar.api.platform.Server in project sonarqube by SonarSource.

the class DefaultHttpDownloaderTest method userAgent_includes_only_version_when_there_is_no_SERVER_ID_and_server_is_provided.

@Test
public void userAgent_includes_only_version_when_there_is_no_SERVER_ID_and_server_is_provided() throws URISyntaxException, IOException {
    Server server = mock(Server.class);
    when(server.getVersion()).thenReturn("2.2");
    InputStream stream = new DefaultHttpDownloader(server, new MapSettings()).openStream(new URI(baseUrl));
    Properties props = new Properties();
    props.load(stream);
    stream.close();
    assertThat(props.getProperty("agent")).isEqualTo("SonarQube 2.2 #");
}
Also used : Server(org.sonar.api.platform.Server) 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)

Aggregations

Server (org.sonar.api.platform.Server)3 InputStream (java.io.InputStream)2 URI (java.net.URI)2 Properties (java.util.Properties)2 Test (org.junit.Test)2 CoreProperties (org.sonar.api.CoreProperties)2 MapSettings (org.sonar.api.config.MapSettings)2 Before (org.junit.Before)1