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");
}
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);
}
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 #");
}
Aggregations