aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/sonar-findbugs-plugin
diff options
context:
space:
mode:
authorGodin <mandrikov@gmail.com>2010-11-02 09:54:37 +0000
committerGodin <mandrikov@gmail.com>2010-11-02 09:54:37 +0000
commit6167b0fd221a833bfa2298ea785b9f967e434c7a (patch)
tree64dd92159f6a7151d59f07f2ba6b138eebbe2126 /plugins/sonar-findbugs-plugin
parent58bf8f1f205bd01dc8bcd363e9a15abeed573776 (diff)
downloadsonarqube-6167b0fd221a833bfa2298ea785b9f967e434c7a.tar.gz
sonarqube-6167b0fd221a833bfa2298ea785b9f967e434c7a.zip
SONAR-1772: Use method getURL() from org.sonar.api.platform.Server
Diffstat (limited to 'plugins/sonar-findbugs-plugin')
-rw-r--r--plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsDownloader.java13
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsDownloaderTest.java10
2 files changed, 11 insertions, 12 deletions
diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsDownloader.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsDownloader.java
index 03c53ef65c1..96f9e9f33b7 100644
--- a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsDownloader.java
+++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsDownloader.java
@@ -26,10 +26,9 @@ import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.List;
-import org.apache.commons.configuration.Configuration;
import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.StringUtils;
import org.sonar.api.BatchExtension;
+import org.sonar.api.platform.Server;
import org.sonar.api.utils.HttpDownloader;
import org.sonar.api.utils.SonarException;
@@ -40,11 +39,11 @@ public class FindbugsDownloader implements BatchExtension {
private static List<File> libs;
private HttpDownloader downloader;
- private String host;
+ private String serverUrl;
- public FindbugsDownloader(Configuration configuration, HttpDownloader downloader) {
+ public FindbugsDownloader(Server server, HttpDownloader downloader) {
this.downloader = downloader;
- host = StringUtils.chomp(configuration.getString("sonar.host.url", "http://localhost:9000"), "/");
+ this.serverUrl = server.getURL();
}
public synchronized List<File> getLibs() {
@@ -58,14 +57,14 @@ public class FindbugsDownloader implements BatchExtension {
* Visibility has been relaxed to make the code testable.
*/
protected String getUrlForAnnotationsJar() {
- return host + FINDBUGS_URL + "/annotations-" + FindbugsVersion.getVersion() + ".jar";
+ return serverUrl + FINDBUGS_URL + "/annotations-" + FindbugsVersion.getVersion() + ".jar";
}
/**
* Visibility has been relaxed to make the code testable.
*/
protected String getUrlForJsrJar() {
- return host + FINDBUGS_URL + "/jsr305-" + FindbugsVersion.getVersion() + ".jar";
+ return serverUrl + FINDBUGS_URL + "/jsr305-" + FindbugsVersion.getVersion() + ".jar";
}
protected File downloadLib(String url) {
diff --git a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsDownloaderTest.java b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsDownloaderTest.java
index cfa1f085c76..25ff6f54b30 100644
--- a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsDownloaderTest.java
+++ b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsDownloaderTest.java
@@ -23,13 +23,13 @@ import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import java.io.File;
-import org.apache.commons.configuration.BaseConfiguration;
-import org.apache.commons.configuration.Configuration;
import org.junit.Before;
import org.junit.Test;
+import org.sonar.api.platform.Server;
import org.sonar.api.utils.HttpDownloader;
public class FindbugsDownloaderTest {
@@ -38,11 +38,11 @@ public class FindbugsDownloaderTest {
@Before
public void setUp() {
- Configuration configuration = new BaseConfiguration();
- configuration.setProperty("sonar.host.url", "http://sonar/");
+ Server server = mock(Server.class);
+ when(server.getURL()).thenReturn("http://sonar");
HttpDownloader httpDownloader = mock(HttpDownloader.class);
- downloader = new FindbugsDownloader(configuration, httpDownloader);
+ downloader = new FindbugsDownloader(server, httpDownloader);
}
@Test