diff options
Diffstat (limited to 'sonar-testing-harness/src')
3 files changed, 0 insertions, 80 deletions
diff --git a/sonar-testing-harness/src/main/java/org/sonar/test/TestUtils.java b/sonar-testing-harness/src/main/java/org/sonar/test/TestUtils.java index 037ac7c3d13..5e579a15ed7 100644 --- a/sonar-testing-harness/src/main/java/org/sonar/test/TestUtils.java +++ b/sonar-testing-harness/src/main/java/org/sonar/test/TestUtils.java @@ -19,13 +19,8 @@ */ package org.sonar.test; -import java.io.File; import java.lang.reflect.Constructor; import java.lang.reflect.Modifier; -import java.net.URL; -import java.nio.file.Files; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; /** * Utilities for unit tests @@ -38,39 +33,6 @@ public final class TestUtils { } /** - * Search for a test resource in the classpath. For example getResource("org/sonar/MyClass/foo.txt"); - * - * @param path the starting slash is optional - * @return the resource. Null if resource not found - */ - public static File getResource(String path) { - String resourcePath = path; - if (!resourcePath.startsWith("/")) { - resourcePath = "/" + resourcePath; - } - URL url = TestUtils.class.getResource(resourcePath); - if (url != null) { - return FileUtils.toFile(url); - } - return null; - } - - /** - * Search for a resource in the classpath. For example calling the method getResource(getClass(), "myTestName/foo.txt") from - * the class org.sonar.Foo loads the file $basedir/src/test/resources/org/sonar/Foo/myTestName/foo.txt - * - * @return the resource. Null if resource not found - */ - public static File getResource(Class baseClass, String path) { - String resourcePath = StringUtils.replaceChars(baseClass.getCanonicalName(), '.', '/'); - if (!path.startsWith("/")) { - resourcePath += "/"; - } - resourcePath += path; - return getResource(resourcePath); - } - - /** * Asserts that all constructors are private, usually for helper classes with * only static methods. If a constructor does not have any parameters, then * it's instantiated. @@ -90,12 +52,4 @@ public final class TestUtils { } return ok; } - - public static File newTempDir(String prefix) { - try { - return Files.createTempDirectory(prefix).toFile(); - } catch (Exception e) { - throw new IllegalStateException("Fail to create temp dir", e); - } - } } diff --git a/sonar-testing-harness/src/test/java/org/sonar/test/TestUtilsTest.java b/sonar-testing-harness/src/test/java/org/sonar/test/TestUtilsTest.java index d89f8858b35..88f6360a69a 100644 --- a/sonar-testing-harness/src/test/java/org/sonar/test/TestUtilsTest.java +++ b/sonar-testing-harness/src/test/java/org/sonar/test/TestUtilsTest.java @@ -21,33 +21,12 @@ package org.sonar.test; import org.junit.Test; -import java.io.File; - import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.fail; -import static org.sonar.test.TestUtils.getResource; public class TestUtilsTest { @Test - public void testResource() { - File file = getResource("org/sonar/test/TestUtilsTest/getResource/foo.txt"); - assertThat(file).exists(); - - file = getResource("/org/sonar/test/TestUtilsTest/getResource/foo.txt"); - assertThat(file).exists(); - - file = getResource(getClass(), "getResource/foo.txt"); - assertThat(file).exists(); - } - - @Test - public void testResourceNotFound() { - File file = getResource("org/sonar/test/TestUtilsTest/unknown.txt"); - assertThat(file).isNull(); - } - - @Test public void hasOnlyPrivateConstructors() { assertThat(TestUtils.hasOnlyPrivateConstructors(TestUtils.class)).isTrue(); assertThat(TestUtils.hasOnlyPrivateConstructors(OnlyPrivateConstructors.class)).isTrue(); @@ -60,18 +39,6 @@ public class TestUtilsTest { } } - @Test - public void newTempDir() throws Exception { - File dir1 = TestUtils.newTempDir("foo"); - assertThat(dir1).exists().isDirectory(); - assertThat(dir1.listFiles()).isEmpty(); - - File dir2 = TestUtils.newTempDir("foo"); - assertThat(dir2).exists().isDirectory(); - assertThat(dir2.listFiles()).isEmpty(); - assertThat(dir2.getCanonicalPath()).isNotEqualTo(dir1.getCanonicalPath()); - } - public static class OnlyPrivateConstructors { private OnlyPrivateConstructors() { } diff --git a/sonar-testing-harness/src/test/resources/org/sonar/test/TestUtilsTest/getResource/foo.txt b/sonar-testing-harness/src/test/resources/org/sonar/test/TestUtilsTest/getResource/foo.txt deleted file mode 100644 index 19102815663..00000000000 --- a/sonar-testing-harness/src/test/resources/org/sonar/test/TestUtilsTest/getResource/foo.txt +++ /dev/null @@ -1 +0,0 @@ -foo
\ No newline at end of file |