summaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-07-16 10:05:34 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2012-07-16 10:05:34 +0200
commitc6d22a745bfe5e9b34331ed57a1c64e1d04fce8a (patch)
tree488b070651d112a2b3b8a0d62a46d796a73961b9 /sonar-plugin-api
parent9bf3be187a4893ad424eb09e3cd3c8e7c54f06d6 (diff)
downloadsonarqube-c6d22a745bfe5e9b34331ed57a1c64e1d04fce8a.tar.gz
sonarqube-c6d22a745bfe5e9b34331ed57a1c64e1d04fce8a.zip
Remove UriReader#openStream()
Let's keep API simple.
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java11
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/UriReader.java18
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/HttpDownloaderTest.java8
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/UriReaderTest.java15
4 files changed, 0 insertions, 52 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java
index 7b22120fe57..94e7c80e26f 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java
@@ -185,17 +185,6 @@ public class HttpDownloader extends UriReader.SchemeProcessor implements BatchCo
return downloadPlainText(uri, charset.name());
}
- @Override
- InputStream openStream(URI uri) {
- try {
- HttpURLConnection connection = newHttpConnection(uri);
- return connection.getInputStream();
-
- } catch (Exception e) {
- throw new SonarException("Fail to download the file: " + uri + " (" + getProxySynthesis(uri) + ")", e);
- }
- }
-
private HttpURLConnection newHttpConnection(URI uri) throws IOException {
LoggerFactory.getLogger(getClass()).debug("Download: " + uri + " (" + getProxySynthesis(uri) + ")");
HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/UriReader.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/UriReader.java
index b1c037be155..2314036e0bd 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/UriReader.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/UriReader.java
@@ -71,13 +71,6 @@ public class UriReader implements BatchComponent, ServerComponent {
}
/**
- * Opens an input stream over the given uri.
- */
- public InputStream openStream(URI uri) {
- return searchForSupportedProcessor(uri).openStream(uri);
- }
-
- /**
* Returns a detailed description of the given uri. For example HTTP URIs are completed
* with the configured HTTP proxy.
*/
@@ -101,8 +94,6 @@ public class UriReader implements BatchComponent, ServerComponent {
abstract String readString(URI uri, Charset charset);
- abstract InputStream openStream(URI uri);
-
abstract String description(URI uri);
}
@@ -136,15 +127,6 @@ public class UriReader implements BatchComponent, ServerComponent {
}
@Override
- InputStream openStream(URI uri) {
- try {
- return Files.newInputStreamSupplier(new File(uri)).getInput();
- } catch (IOException e) {
- throw Throwables.propagate(e);
- }
- }
-
- @Override
String description(URI uri) {
return new File(uri).getAbsolutePath();
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/HttpDownloaderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/HttpDownloaderTest.java
index c8bc80d83e2..c45d8076d21 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/HttpDownloaderTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/HttpDownloaderTest.java
@@ -32,7 +32,6 @@ import org.sonar.api.platform.Server;
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
import java.net.*;
import java.util.Arrays;
import java.util.Properties;
@@ -172,13 +171,6 @@ public class HttpDownloaderTest {
assertThat(text.length()).isGreaterThan(10);
}
- @Test
- public void openStream() throws Exception {
- InputStream input = new HttpDownloader(new Settings()).openStream(new URI(baseUrl));
- assertThat(IOUtils.toByteArray(input).length).isGreaterThan(10);
- IOUtils.closeQuietly(input);
- }
-
@Test(expected = SonarException.class)
public void failIfServerDown() throws Exception {
// I hope that the port 1 is not used !
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/UriReaderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/UriReaderTest.java
index b33e77ccd15..2434e84682c 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/UriReaderTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/UriReaderTest.java
@@ -66,14 +66,6 @@ public class UriReaderTest {
}
@Test
- public void file_openStream() throws Exception {
- UriReader uriReader = new UriReader(new UriReader.SchemeProcessor[0]);
- InputStream input = uriReader.openStream(testFile);
- assertThat(IOUtils.toString(input)).isEqualTo("in foo");
- IOUtils.closeQuietly(input);
- }
-
- @Test
public void file_readString_fails_if_file_not_found() throws Exception {
thrown.expect(RuntimeException.class);
UriReader uriReader = new UriReader(new UriReader.SchemeProcessor[0]);
@@ -88,13 +80,6 @@ public class UriReaderTest {
}
@Test
- public void file_openStream_fails_if_file_not_found() throws Exception {
- thrown.expect(RuntimeException.class);
- UriReader uriReader = new UriReader(new UriReader.SchemeProcessor[0]);
- uriReader.openStream(new URI("file:/notfound"));
- }
-
- @Test
public void file_description() {
UriReader uriReader = new UriReader(new UriReader.SchemeProcessor[0]);