summaryrefslogtreecommitdiffstats
path: root/sonar-server/src/test
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-11-04 15:50:19 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-11-04 15:50:19 +0000
commit76cb3079f651ad6bc2e2233fa1e401103567feaa (patch)
tree28a3747ce92575bb1a9ef8a34e556e1925c2e800 /sonar-server/src/test
parent31bd637bfc71b907dab84803d3845c3a243a1e11 (diff)
downloadsonarqube-76cb3079f651ad6bc2e2233fa1e401103567feaa.tar.gz
sonarqube-76cb3079f651ad6bc2e2233fa1e401103567feaa.zip
UpdateCenter: log HTTP proxy configuration
Diffstat (limited to 'sonar-server/src/test')
-rw-r--r--sonar-server/src/test/java/org/sonar/server/plugins/UpdateCenterClientTest.java28
1 files changed, 26 insertions, 2 deletions
diff --git a/sonar-server/src/test/java/org/sonar/server/plugins/UpdateCenterClientTest.java b/sonar-server/src/test/java/org/sonar/server/plugins/UpdateCenterClientTest.java
index 6d206f3d9d3..1186e26e252 100644
--- a/sonar-server/src/test/java/org/sonar/server/plugins/UpdateCenterClientTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/plugins/UpdateCenterClientTest.java
@@ -28,10 +28,11 @@ import org.sonar.server.plugins.UpdateCenterClient;
import org.sonar.updatecenter.common.UpdateCenter;
import org.sonar.updatecenter.common.Version;
-import java.net.URI;
-import java.net.URISyntaxException;
+import java.net.*;
+import java.util.Arrays;
import static junit.framework.Assert.assertNull;
+import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.junit.internal.matchers.IsCollectionContaining.hasItems;
import static org.mockito.Matchers.anyObject;
@@ -83,4 +84,27 @@ public class UpdateCenterClientTest {
verify(downloader, times(2)).openStream(new URI(BASE_URL));
}
+
+ @Test
+ public void shouldSumUpDirectProxyConfiguration() {
+ ProxySelector proxySelector = mock(ProxySelector.class);
+ when(proxySelector.select((URI)anyObject())).thenReturn(Arrays.asList(Proxy.NO_PROXY));
+ assertThat(UpdateCenterClient.sumUpProxyConfiguration("http://updatecenter", proxySelector), is("no HTTP proxy"));
+ }
+
+ @Test
+ public void shouldSumUpProxyConfiguration() {
+ ProxySelector proxySelector = mock(ProxySelector.class);
+ when(proxySelector.select((URI)anyObject())).thenReturn(Arrays.asList((Proxy)new FakeProxy()));
+ assertThat(UpdateCenterClient.sumUpProxyConfiguration("http://updatecenter", proxySelector), is("proxy: http://updatecenter:80"));
+ }
+
+
+}
+
+class FakeProxy extends Proxy {
+
+ public FakeProxy() {
+ super(Type.HTTP, new InetSocketAddress("http://updatecenter", 80));
+ }
}