aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-11-09 11:07:14 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-11-09 11:07:14 +0000
commitb064bef048b04fc3b5d6ca4dfe6311bf90230836 (patch)
tree7db974291554b78397f45b52990509a8975f4dc4 /tests
parentd667594a1fe81b4f235b44b3a2ebdfeedaab4dc3 (diff)
downloadsonarqube-b064bef048b04fc3b5d6ca4dfe6311bf90230836.tar.gz
sonarqube-b064bef048b04fc3b5d6ca4dfe6311bf90230836.zip
add integration test to SONAR-1911
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/tests/src/it/java/org/sonar/tests/integration/GzipCompressionTest.java9
-rw-r--r--tests/integration/tests/src/it/java/org/sonar/tests/integration/ITUtils.java41
-rw-r--r--tests/integration/tests/src/it/java/org/sonar/tests/integration/ServerTest.java13
-rw-r--r--tests/integration/tests/src/it/java/org/sonar/tests/integration/Struts139Test.java2
-rw-r--r--tests/integration/tests/src/it/java/org/sonar/tests/integration/UpdateCenterTest.java2
-rw-r--r--tests/integration/tests/src/it/java/org/sonar/tests/integration/selenium/SonarTestCase.java3
6 files changed, 60 insertions, 10 deletions
diff --git a/tests/integration/tests/src/it/java/org/sonar/tests/integration/GzipCompressionTest.java b/tests/integration/tests/src/it/java/org/sonar/tests/integration/GzipCompressionTest.java
index 852f3b96df5..841e7b59e77 100644
--- a/tests/integration/tests/src/it/java/org/sonar/tests/integration/GzipCompressionTest.java
+++ b/tests/integration/tests/src/it/java/org/sonar/tests/integration/GzipCompressionTest.java
@@ -22,14 +22,15 @@ package org.sonar.tests.integration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.methods.GetMethod;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.*;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.junit.After;
import java.io.IOException;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
+
public class GzipCompressionTest {
private HttpClient client;
@@ -38,7 +39,7 @@ public class GzipCompressionTest {
@Before
public void before() {
client = new HttpClient();
- method = new GetMethod("http://localhost:9000");
+ method = new GetMethod(ITUtils.getSonarURL());
}
@After
diff --git a/tests/integration/tests/src/it/java/org/sonar/tests/integration/ITUtils.java b/tests/integration/tests/src/it/java/org/sonar/tests/integration/ITUtils.java
new file mode 100644
index 00000000000..e6d0ec79dd1
--- /dev/null
+++ b/tests/integration/tests/src/it/java/org/sonar/tests/integration/ITUtils.java
@@ -0,0 +1,41 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.tests.integration;
+
+import org.apache.commons.lang.StringUtils;
+import org.junit.Ignore;
+import org.sonar.wsclient.Sonar;
+
+@Ignore
+public final class ITUtils {
+
+ private ITUtils() {
+ }
+
+ public static Sonar createSonarWsClient() {
+ return Sonar.create(getSonarURL());
+ }
+
+ public static String getSonarURL() {
+ return StringUtils.defaultIfEmpty(System.getProperty("sonar.url"), "http://localhost:9000");
+ }
+
+
+}
diff --git a/tests/integration/tests/src/it/java/org/sonar/tests/integration/ServerTest.java b/tests/integration/tests/src/it/java/org/sonar/tests/integration/ServerTest.java
index 19a1fbc31cc..80968f3468c 100644
--- a/tests/integration/tests/src/it/java/org/sonar/tests/integration/ServerTest.java
+++ b/tests/integration/tests/src/it/java/org/sonar/tests/integration/ServerTest.java
@@ -21,17 +21,24 @@ package org.sonar.tests.integration;
import org.junit.Test;
import org.sonar.wsclient.Sonar;
+import org.sonar.wsclient.services.Server;
import org.sonar.wsclient.services.ServerQuery;
import static org.hamcrest.Matchers.endsWith;
+import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
public class ServerTest {
@Test
- public void getVersion() {
- Sonar sonar = Sonar.create("http://localhost:9000");
- System.out.println(sonar.find(new ServerQuery()).getVersion());
+ public void shouldGetVersion() {
+ Sonar sonar = ITUtils.createSonarWsClient();
assertThat(sonar.find(new ServerQuery()).getVersion(), endsWith("-SNAPSHOT"));
}
+
+ @Test
+ public void shouldGetStatus() {
+ Sonar sonar = ITUtils.createSonarWsClient();
+ assertThat(sonar.find(new ServerQuery()).getStatus(), is(Server.Status.UP));
+ }
}
diff --git a/tests/integration/tests/src/it/java/org/sonar/tests/integration/Struts139Test.java b/tests/integration/tests/src/it/java/org/sonar/tests/integration/Struts139Test.java
index 0ffda3a252c..e6962275719 100644
--- a/tests/integration/tests/src/it/java/org/sonar/tests/integration/Struts139Test.java
+++ b/tests/integration/tests/src/it/java/org/sonar/tests/integration/Struts139Test.java
@@ -50,7 +50,7 @@ public class Struts139Test {
@BeforeClass
public static void buildServer() {
- sonar = Sonar.create("http://localhost:9000");
+ sonar = ITUtils.createSonarWsClient();
}
@Test
diff --git a/tests/integration/tests/src/it/java/org/sonar/tests/integration/UpdateCenterTest.java b/tests/integration/tests/src/it/java/org/sonar/tests/integration/UpdateCenterTest.java
index f49ad613b52..9ba4c33cb8a 100644
--- a/tests/integration/tests/src/it/java/org/sonar/tests/integration/UpdateCenterTest.java
+++ b/tests/integration/tests/src/it/java/org/sonar/tests/integration/UpdateCenterTest.java
@@ -37,7 +37,7 @@ public class UpdateCenterTest {
@Test
public void shouldGetInstalledPlugins() {
- Sonar sonar = Sonar.create("http://localhost:9000");
+ Sonar sonar = ITUtils.createSonarWsClient();
List<Plugin> plugins = sonar.findAll(UpdateCenterQuery.createForInstalledPlugins());
assertThat(plugins.size(), greaterThan(0));
diff --git a/tests/integration/tests/src/it/java/org/sonar/tests/integration/selenium/SonarTestCase.java b/tests/integration/tests/src/it/java/org/sonar/tests/integration/selenium/SonarTestCase.java
index 4e22057584b..fa56aac27e6 100644
--- a/tests/integration/tests/src/it/java/org/sonar/tests/integration/selenium/SonarTestCase.java
+++ b/tests/integration/tests/src/it/java/org/sonar/tests/integration/selenium/SonarTestCase.java
@@ -22,6 +22,7 @@ package org.sonar.tests.integration.selenium;
import com.thoughtworks.selenium.DefaultSelenium;
import org.junit.After;
import org.junit.Before;
+import org.sonar.tests.integration.ITUtils;
/**
* To execute selenium tests in IDE, you have to run the selenium server first :
@@ -33,7 +34,7 @@ public abstract class SonarTestCase {
@Before
public void before() throws Exception {
// TODO the browser and the url must be configurable
- selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost:9000");
+ selenium = new DefaultSelenium("localhost", 4444, "*firefox", ITUtils.getSonarURL());
selenium.start();
}