diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-10-15 15:02:18 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-10-15 15:02:18 +0200 |
commit | 0da499c9a97157c67910f17cd8f8a066cb45081b (patch) | |
tree | a0cd0001184db4ad5e55332192b4efe73b4dac3a /sonar-application | |
parent | 5960329454b96842681cb96f585fda24410ca10a (diff) | |
download | sonarqube-0da499c9a97157c67910f17cd8f8a066cb45081b.tar.gz sonarqube-0da499c9a97157c67910f17cd8f8a066cb45081b.zip |
SONAR-4675 unit test must not generate temp files in sources
Diffstat (limited to 'sonar-application')
-rw-r--r-- | sonar-application/src/test/java/org/sonar/application/StartServerTest.java | 32 |
1 files changed, 17 insertions, 15 deletions
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 f34676e1b09..e3aa3472023 100644 --- a/sonar-application/src/test/java/org/sonar/application/StartServerTest.java +++ b/sonar-application/src/test/java/org/sonar/application/StartServerTest.java @@ -21,9 +21,10 @@ package org.sonar.application; import com.github.kevinsawicki.http.HttpRequest; import org.apache.commons.io.FileUtils; -import org.junit.After; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TemporaryFolder; import java.io.File; import java.io.IOException; @@ -33,14 +34,23 @@ import static org.fest.assertions.Fail.fail; public class StartServerTest { - Env env = new Env(locateFakeConfFile()); - StartServer starter = new StartServer(env); + Env env; + StartServer starter; + + @Rule + public TemporaryFolder temp = new TemporaryFolder(); @Before - @After - public void clean_generated_dirs() throws IOException { - FileUtils.deleteQuietly(env.file("temp")); - FileUtils.deleteQuietly(env.file("logs")); + public void prepare_app() throws IOException { + 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"); + } + + File rootDir = temp.newFolder(); + FileUtils.copyDirectory(confFile.getParentFile().getParentFile(), rootDir); + env = new Env(new File(rootDir, "conf/sonar.properties")); + starter = new StartServer(env); } @Test @@ -123,14 +133,6 @@ public class StartServerTest { starter.stop(); } - private File locateFakeConfFile() { - 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"); - } - return confFile; - } - static class BackgroundThread extends Thread { private StartServer server; |