use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class DefaultHttpDownloaderTest method followRedirect.
@Test
public void followRedirect() throws URISyntaxException {
String content = new DefaultHttpDownloader(new MapSettings()).readString(new URI(baseUrl + "/redirect/"), StandardCharsets.UTF_8);
assertThat(content).contains("agent");
}
use of org.sonar.api.config.MapSettings 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 #");
}
use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class DefaultHttpDownloaderTest method readStringWithTimeout.
@Test
public void readStringWithTimeout() throws URISyntaxException {
thrown.expect(new BaseMatcher<Exception>() {
@Override
public boolean matches(Object ex) {
return ex instanceof SonarException && ((SonarException) ex).getCause() instanceof SocketTimeoutException;
}
@Override
public void describeTo(Description arg0) {
}
});
new DefaultHttpDownloader(new MapSettings(), 50).readString(new URI(baseUrl + "/timeout/"), StandardCharsets.UTF_8);
}
use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class DefaultHttpDownloaderTest method shouldNotCreateFileIfFailToDownload.
@Test
public void shouldNotCreateFileIfFailToDownload() throws Exception {
File toDir = temporaryFolder.newFolder();
File toFile = new File(toDir, "downloadToFile.txt");
try {
int port = new InetSocketAddress("localhost", 0).getPort();
new DefaultHttpDownloader(new MapSettings()).download(new URI("http://localhost:" + port), toFile);
} catch (SonarException e) {
assertThat(toFile).doesNotExist();
}
}
use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class ProjectBuilderTest method shouldChangeProject.
@Test
public void shouldChangeProject() {
// this reactor is created and provided by Sonar
final ProjectReactor projectReactor = new ProjectReactor(ProjectDefinition.create());
ProjectBuilder builder = new ProjectBuilderSample(new MapSettings());
builder.build(new ProjectBuilderContext(projectReactor));
assertThat(projectReactor.getProjects().size(), is(2));
ProjectDefinition root = projectReactor.getRoot();
assertThat(root.getName(), is("Name changed by plugin"));
assertThat(root.getSubProjects().size(), is(1));
assertThat(root.getSubProjects().get(0).sources()).contains("src");
}
Aggregations