aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-home
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-02-11 15:52:39 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2013-02-11 15:52:39 +0100
commitefd5716474747b6064e3934d5fe3fe35ebca900d (patch)
tree3ba68a6dede610851868cfed4eae157a03e2fc41 /sonar-home
parent7c10d83bf2d14506f108621c1024c78f2fb4c2f9 (diff)
downloadsonarqube-efd5716474747b6064e3934d5fe3fe35ebca900d.tar.gz
sonarqube-efd5716474747b6064e3934d5fe3fe35ebca900d.zip
SONAR-2291 Fix unit test on Windows
Diffstat (limited to 'sonar-home')
-rw-r--r--sonar-home/src/test/java/org/sonar/home/cache/FileHashesTest.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/sonar-home/src/test/java/org/sonar/home/cache/FileHashesTest.java b/sonar-home/src/test/java/org/sonar/home/cache/FileHashesTest.java
index e7d7ed98d76..c2cd589602a 100644
--- a/sonar-home/src/test/java/org/sonar/home/cache/FileHashesTest.java
+++ b/sonar-home/src/test/java/org/sonar/home/cache/FileHashesTest.java
@@ -21,13 +21,16 @@ package org.sonar.home.cache;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.junit.rules.TemporaryFolder;
import java.io.ByteArrayInputStream;
import java.io.File;
+import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.security.SecureRandom;
@@ -45,6 +48,9 @@ public class FileHashesTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
+ @Rule
+ public TemporaryFolder temp = new TemporaryFolder();
+
@Test
public void test_md5_hash() {
assertThat(hash("sonar")).isEqualTo("d85e336d61f5344395c42126fac239bc");
@@ -73,11 +79,15 @@ public class FileHashesTest {
}
@Test
- public void fail_if_file_does_not_exist() {
+ public void fail_if_file_does_not_exist() throws IOException {
+ File file = temp.newFile("does_not_exist");
+ FileUtils.forceDelete(file);
+
thrown.expect(IllegalStateException.class);
- thrown.expectMessage("Fail to compute hash of: /does/not/exist");
+ thrown.expectMessage("Fail to compute hash of: " + file.getAbsolutePath());
+
- new FileHashes().of(new File("/does/not/exist"));
+ new FileHashes().of(file);
}
@Test