aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-07-31 17:42:14 +0000
committerSimon Brandhof <simon.brandhof@gmail.com>2012-07-31 17:42:14 +0000
commitd5409cf932773d8199e7802cc77e76bf4fb2acc3 (patch)
tree0a7f81ac2ac6308dfee2b1bee40ab0665d11da77
parent19e50646269b781e2f9fdedcb06a11c707eb74c9 (diff)
downloadsonar-scanner-cli-d5409cf932773d8199e7802cc77e76bf4fb2acc3.tar.gz
sonar-scanner-cli-d5409cf932773d8199e7802cc77e76bf4fb2acc3.zip
Minimal required version of sonar is upgraded to 2.11
-rw-r--r--pom.xml2
-rw-r--r--src/main/java/org/sonar/runner/Runner.java2
-rw-r--r--src/test/java/org/sonar/runner/LauncherTest.java27
-rw-r--r--src/test/java/org/sonar/runner/RunnerTest.java51
4 files changed, 37 insertions, 45 deletions
diff --git a/pom.xml b/pom.xml
index 91e9404..474a379 100644
--- a/pom.xml
+++ b/pom.xml
@@ -56,7 +56,7 @@
</ciManagement>
<properties>
- <sonar.buildVersion>2.6</sonar.buildVersion>
+ <sonar.buildVersion>2.11</sonar.buildVersion>
</properties>
<dependencies>
diff --git a/src/main/java/org/sonar/runner/Runner.java b/src/main/java/org/sonar/runner/Runner.java
index 1a51496..60784df 100644
--- a/src/main/java/org/sonar/runner/Runner.java
+++ b/src/main/java/org/sonar/runner/Runner.java
@@ -57,7 +57,7 @@ public final class Runner {
/**
* Array of prefixes of versions of Sonar without support of this runner.
*/
- private static final String[] UNSUPPORTED_VERSIONS = {"1", "2.0", "2.1", "2.2", "2.3", "2.4", "2.5"};
+ private static final String[] UNSUPPORTED_VERSIONS = {"1", "2.0", "2.1", "2.2", "2.3", "2.4", "2.5", "2.6", "2.7", "2.8", "2.9", "2.10"};
/**
* Array of all mandatory properties required to execute runner.
diff --git a/src/test/java/org/sonar/runner/LauncherTest.java b/src/test/java/org/sonar/runner/LauncherTest.java
index c22ce16..ceea21c 100644
--- a/src/test/java/org/sonar/runner/LauncherTest.java
+++ b/src/test/java/org/sonar/runner/LauncherTest.java
@@ -28,9 +28,6 @@ import java.io.File;
import java.util.Properties;
import static org.fest.assertions.Assertions.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.startsWith;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
public class LauncherTest {
@@ -38,17 +35,17 @@ public class LauncherTest {
@Test
public void shouldFilterFiles() throws Exception {
File baseDir = new File(getClass().getResource("/org/sonar/runner/LauncherTest/shouldFilterFiles/").toURI());
- assertThat(Launcher.getLibraries(baseDir, "in*.txt").length, is(1));
- assertThat(Launcher.getLibraries(baseDir, "*.txt").length, is(2));
- assertThat(Launcher.getLibraries(baseDir.getParentFile(), "shouldFilterFiles/in*.txt").length, is(1));
- assertThat(Launcher.getLibraries(baseDir.getParentFile(), "shouldFilterFiles/*.txt").length, is(2));
+ assertThat(Launcher.getLibraries(baseDir, "in*.txt").length).isEqualTo(1);
+ assertThat(Launcher.getLibraries(baseDir, "*.txt").length).isEqualTo(2);
+ assertThat(Launcher.getLibraries(baseDir.getParentFile(), "shouldFilterFiles/in*.txt").length).isEqualTo(1);
+ assertThat(Launcher.getLibraries(baseDir.getParentFile(), "shouldFilterFiles/*.txt").length).isEqualTo(2);
}
@Test
public void shouldWorkWithAbsolutePath() throws Exception {
File baseDir = new File("not-exists");
String absolutePattern = new File(getClass().getResource("/org/sonar/runner/LauncherTest/shouldFilterFiles/").toURI()).getAbsolutePath() + "/in*.txt";
- assertThat(Launcher.getLibraries(baseDir.getParentFile(), absolutePattern).length, is(1));
+ assertThat(Launcher.getLibraries(baseDir.getParentFile(), absolutePattern).length).isEqualTo(1);
}
@Test
@@ -58,7 +55,7 @@ public class LauncherTest {
Launcher.getLibraries(baseDir, "*.jar");
fail("Exception expected");
} catch (RunnerException e) {
- assertThat(e.getMessage(), startsWith("No files matching pattern \"*.jar\" in directory "));
+ assertThat(e.getMessage()).contains("No files matching pattern \"*.jar\" in directory");
}
}
@@ -83,26 +80,26 @@ public class LauncherTest {
public void testGetSqlLevel() throws Exception {
Configuration conf = new BaseConfiguration();
- assertThat(Launcher.getSqlLevel(conf), is("WARN"));
+ assertThat(Launcher.getSqlLevel(conf)).isEqualTo("WARN");
conf.setProperty("sonar.showSql", "true");
- assertThat(Launcher.getSqlLevel(conf), is("DEBUG"));
+ assertThat(Launcher.getSqlLevel(conf)).isEqualTo("DEBUG");
conf.setProperty("sonar.showSql", "false");
- assertThat(Launcher.getSqlLevel(conf), is("WARN"));
+ assertThat(Launcher.getSqlLevel(conf)).isEqualTo("WARN");
}
@Test
public void testGetSqlResultsLevel() throws Exception {
Configuration conf = new BaseConfiguration();
- assertThat(Launcher.getSqlResultsLevel(conf), is("WARN"));
+ assertThat(Launcher.getSqlResultsLevel(conf)).isEqualTo("WARN");
conf.setProperty("sonar.showSqlResults", "true");
- assertThat(Launcher.getSqlResultsLevel(conf), is("DEBUG"));
+ assertThat(Launcher.getSqlResultsLevel(conf)).isEqualTo("DEBUG");
conf.setProperty("sonar.showSqlResults", "false");
- assertThat(Launcher.getSqlResultsLevel(conf), is("WARN"));
+ assertThat(Launcher.getSqlResultsLevel(conf)).isEqualTo("WARN");
}
}
diff --git a/src/test/java/org/sonar/runner/RunnerTest.java b/src/test/java/org/sonar/runner/RunnerTest.java
index 877e85d..1099d1d 100644
--- a/src/test/java/org/sonar/runner/RunnerTest.java
+++ b/src/test/java/org/sonar/runner/RunnerTest.java
@@ -17,7 +17,6 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
*/
-
package org.sonar.runner;
import org.junit.Rule;
@@ -30,11 +29,6 @@ import java.io.File;
import java.util.Properties;
import static org.fest.assertions.Assertions.assertThat;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.not;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -50,7 +44,7 @@ public class RunnerTest {
Runner.create(new Properties()).checkMandatoryProperties();
fail("Exception expected");
} catch (RunnerException e) {
- assertThat(e.getMessage(), is("You must define mandatory properties: sonar.projectKey, sonar.projectName, sonar.projectVersion, sources"));
+ assertThat(e).hasMessage("You must define mandatory properties: sonar.projectKey, sonar.projectName, sonar.projectVersion, sources");
}
}
@@ -66,15 +60,16 @@ public class RunnerTest {
@Test
public void shouldCheckVersion() {
- assertThat(Runner.isUnsupportedVersion("1.0"), is(true));
- assertThat(Runner.isUnsupportedVersion("2.0"), is(true));
- assertThat(Runner.isUnsupportedVersion("2.1"), is(true));
- assertThat(Runner.isUnsupportedVersion("2.2"), is(true));
- assertThat(Runner.isUnsupportedVersion("2.3"), is(true));
- assertThat(Runner.isUnsupportedVersion("2.4"), is(true));
- assertThat(Runner.isUnsupportedVersion("2.4.1"), is(true));
- assertThat(Runner.isUnsupportedVersion("2.5"), is(true));
- assertThat(Runner.isUnsupportedVersion("2.6"), is(false));
+ assertThat(Runner.isUnsupportedVersion("1.0")).isTrue();
+ assertThat(Runner.isUnsupportedVersion("2.0")).isTrue();
+ assertThat(Runner.isUnsupportedVersion("2.1")).isTrue();
+ assertThat(Runner.isUnsupportedVersion("2.2")).isTrue();
+ assertThat(Runner.isUnsupportedVersion("2.3")).isTrue();
+ assertThat(Runner.isUnsupportedVersion("2.4")).isTrue();
+ assertThat(Runner.isUnsupportedVersion("2.4.1")).isTrue();
+ assertThat(Runner.isUnsupportedVersion("2.5")).isTrue();
+ assertThat(Runner.isUnsupportedVersion("2.11")).isFalse();
+ assertThat(Runner.isUnsupportedVersion("3.0")).isFalse();
}
/**
@@ -84,29 +79,29 @@ public class RunnerTest {
@Test
public void shouldGetVersion() {
String version = Runner.create(new Properties()).getRunnerVersion();
- assertThat(version.length(), greaterThanOrEqualTo(3));
- assertThat(version, containsString("."));
+ assertThat(version.length()).isGreaterThanOrEqualTo(3);
+ assertThat(version).contains(".");
// test that version is set by Maven build
- assertThat(version, not(containsString("$")));
+ assertThat(version).doesNotContain("$");
}
@Test
public void shouldGetServerUrl() {
Properties properties = new Properties();
Runner runner = Runner.create(properties);
- assertThat("Default value", runner.getServerURL(), is("http://localhost:9000"));
+ assertThat(runner.getServerURL()).isEqualTo("http://localhost:9000");
properties.setProperty("sonar.host.url", "foo");
- assertThat(runner.getServerURL(), is("foo"));
+ assertThat(runner.getServerURL()).isEqualTo("foo");
}
@Test
public void shouldDetermineVerboseMode() {
Properties properties = new Properties();
Runner runner = Runner.create(properties);
- assertThat("Default value", runner.isDebug(), is(false));
+ assertThat(runner.isDebug()).isFalse();
properties.setProperty(Runner.PROPERTY_VERBOSE, "true");
- assertThat(runner.isDebug(), is(true));
+ assertThat(runner.isDebug()).isTrue();
}
@Test
@@ -114,7 +109,7 @@ public class RunnerTest {
Properties properties = new Properties();
Runner runner = Runner.create(properties);
properties.setProperty(Runner.DEBUG_MODE, "true");
- assertThat(runner.isDebug(), is(true));
+ assertThat(runner.isDebug()).isTrue();
}
@Test
@@ -125,8 +120,8 @@ public class RunnerTest {
Runner runner = Runner.create(props);
assertThat(runner.getProperties().get("project.home")).isEqualTo(home.getCanonicalPath());
- assertThat(runner.getProjectDir(), is(home));
- assertThat(runner.getWorkDir(), is(new File(home, ".sonar")));
+ assertThat(runner.getProjectDir()).isEqualTo(home);
+ assertThat(runner.getWorkDir()).isEqualTo(new File(home, ".sonar"));
}
@Test
@@ -143,8 +138,8 @@ public class RunnerTest {
public void shouldInitProjectDirWithCurrentDir() throws Exception {
Runner runner = Runner.create(new Properties());
- assertThat(runner.getProjectDir().isDirectory(), is(true));
- assertThat(runner.getProjectDir().exists(), is(true));
+ assertThat(runner.getProjectDir().isDirectory()).isTrue();
+ assertThat(runner.getProjectDir().exists()).isTrue();
}
@Test