aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-application/src/test/java/org
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-10-23 17:03:19 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2013-10-23 17:03:19 +0200
commit0556987242b2760f59dff632a9b60d8665d9526c (patch)
tree780d0110c9c46904a6cedf0e03247cd90b33e8dc /sonar-application/src/test/java/org
parentc1651de4d5399a592c4537ebce4f7da2840424d1 (diff)
downloadsonarqube-0556987242b2760f59dff632a9b60d8665d9526c.tar.gz
sonarqube-0556987242b2760f59dff632a9b60d8665d9526c.zip
Better error message when wrapper.conf is not correct
Diffstat (limited to 'sonar-application/src/test/java/org')
-rw-r--r--sonar-application/src/test/java/org/sonar/application/EnvTest.java19
-rw-r--r--sonar-application/src/test/java/org/sonar/application/StartServerTest.java4
2 files changed, 18 insertions, 5 deletions
diff --git a/sonar-application/src/test/java/org/sonar/application/EnvTest.java b/sonar-application/src/test/java/org/sonar/application/EnvTest.java
index 27749840297..1400cc8f4ee 100644
--- a/sonar-application/src/test/java/org/sonar/application/EnvTest.java
+++ b/sonar-application/src/test/java/org/sonar/application/EnvTest.java
@@ -27,6 +27,7 @@ import org.junit.rules.TemporaryFolder;
import java.io.File;
import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
public class EnvTest {
@@ -48,7 +49,7 @@ public class EnvTest {
FileUtils.touch(confFile);
FileUtils.touch(logFile);
- Env env = new Env(confFile);
+ Env env = new Env(confFile.toURL());
assertThat(env.rootDir()).isDirectory().exists().isEqualTo(home);
assertThat(env.file("conf/sonar.properties")).isFile().exists().isEqualTo(confFile);
@@ -65,7 +66,7 @@ public class EnvTest {
FileUtils.touch(confFile);
FileUtils.touch(logFile);
- Env env = new Env(confFile);
+ Env env = new Env(confFile.toURL());
File data = env.freshDir("data/h2");
assertThat(data).isDirectory().exists();
@@ -80,7 +81,19 @@ public class EnvTest {
@Test
public void temp_dir_should_be_writable() throws Exception {
- new Env(temp.newFile()).verifyWritableTempDir();
+ new Env(temp.newFile().toURL()).verifyWritableTempDir();
// do not fail
}
+
+ @Test
+ public void fail_if_conf_file_not_found() throws Exception {
+ try {
+ // note that "new Env(null)" would be exact, but let's
+ // keep "new Env()" for increasing code coverage :-)
+ new Env();
+ fail();
+ } catch (IllegalStateException e) {
+ assertThat(e).hasMessage(Env.ERROR_MESSAGE);
+ }
+ }
}
diff --git a/sonar-application/src/test/java/org/sonar/application/StartServerTest.java b/sonar-application/src/test/java/org/sonar/application/StartServerTest.java
index 1a7c9b7e769..590385d939a 100644
--- a/sonar-application/src/test/java/org/sonar/application/StartServerTest.java
+++ b/sonar-application/src/test/java/org/sonar/application/StartServerTest.java
@@ -41,7 +41,7 @@ public class StartServerTest {
public TemporaryFolder temp = new TemporaryFolder();
@Before
- public void prepare_app() throws IOException {
+ public void prepare_app() throws Exception {
File confFile = new File("src/test/fake-app/conf/sonar.properties");
if (!confFile.exists()) {
confFile = new File("sonar-application/src/test/fake-app/conf/sonar.properties");
@@ -49,7 +49,7 @@ public class StartServerTest {
File rootDir = temp.newFolder();
FileUtils.copyDirectory(confFile.getParentFile().getParentFile(), rootDir);
- env = new Env(new File(rootDir, "conf/sonar.properties"));
+ env = new Env(new File(rootDir, "conf/sonar.properties").toURL());
starter = new StartServer(env);
}