diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2010-09-23 08:24:10 +0000 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2010-09-23 08:24:10 +0000 |
commit | cc199ff792bc4dd7c82c0facce46345c393ab041 (patch) | |
tree | 348eb79b23e3218f60bfad898ebca14bc025540d /plugins | |
parent | 04ffe3a61b0126eec69ce23c0ddcb523a93a76f9 (diff) | |
download | sonarqube-cc199ff792bc4dd7c82c0facce46345c393ab041.tar.gz sonarqube-cc199ff792bc4dd7c82c0facce46345c393ab041.zip |
findbugs plugin: improve a unit test
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsMavenPluginHandlerTest.java | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsMavenPluginHandlerTest.java b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsMavenPluginHandlerTest.java index 30bbd30d199..63ee8840b04 100644 --- a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsMavenPluginHandlerTest.java +++ b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsMavenPluginHandlerTest.java @@ -26,12 +26,15 @@ import org.hamcrest.core.Is; import static org.hamcrest.text.StringEndsWith.endsWith;
import static org.junit.Assert.assertThat;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.argThat;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
+
+import org.junit.rules.TemporaryFolder;
import org.sonar.api.CoreProperties;
import org.sonar.api.batch.maven.MavenPlugin;
import org.sonar.api.profiles.RulesProfile;
@@ -47,13 +50,16 @@ import java.util.regex.Matcher; import java.util.regex.Pattern;
public class FindbugsMavenPluginHandlerTest {
- private static final String TARGET_TMP_TESTS = "target/tmp-tests";
+ @Rule
+ public TemporaryFolder tempFolder = new TemporaryFolder();
+
private Project project;
private ProjectFileSystem fs;
private File fakeSonarConfig;
private MavenPlugin plugin;
private FindbugsMavenPluginHandler handler;
+ private File findbugsTempDir;
@Before
public void setup() {
@@ -62,6 +68,7 @@ public class FindbugsMavenPluginHandlerTest { fakeSonarConfig = mock(File.class);
plugin = mock(MavenPlugin.class);
handler = createMavenPluginHandler();
+ findbugsTempDir = tempFolder.newFolder("findbugs");
}
@Test
@@ -166,7 +173,7 @@ public class FindbugsMavenPluginHandlerTest { }
private void assertFindbugsIncludeFileIsSaved() {
- File findbugsIncludeFile = new File(TARGET_TMP_TESTS + "/target/sonar/findbugs-include.xml");
+ File findbugsIncludeFile = new File(findbugsTempDir + "/target/sonar/findbugs-include.xml");
assertThat(findbugsIncludeFile.exists(), is(true));
}
@@ -176,7 +183,7 @@ public class FindbugsMavenPluginHandlerTest { private void mockProject(String effort) throws URISyntaxException, IOException {
when(project.getPom()).thenReturn(new MavenProject());
- when(project.getFileSystem()).thenReturn(new SimpleProjectFileSystem(new File(TARGET_TMP_TESTS)));
+ when(project.getFileSystem()).thenReturn(new SimpleProjectFileSystem(findbugsTempDir));
Configuration conf = mock(Configuration.class);
when(project.getConfiguration()).thenReturn(conf);
|