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;
@Before
public void before() {
client = new HttpClient();
- method = new GetMethod("http://localhost:9000");
+ method = new GetMethod(ITUtils.getSonarURL());
}
@After
--- /dev/null
+/*
+ * 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");
+ }
+
+
+}
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));
+ }
}
@BeforeClass
public static void buildServer() {
- sonar = Sonar.create("http://localhost:9000");
+ sonar = ITUtils.createSonarWsClient();
}
@Test
@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));
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 :
@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();
}