diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-09-25 23:29:55 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-09-25 23:29:55 +0200 |
commit | 9654662b48c918b55383846c6575b7f809437108 (patch) | |
tree | f9e52606b25e3ea61e18fe2dd411feb789d18a79 /sonar-testing-harness/src | |
parent | 4a5a256eefb9dd6173b2155bb6994d88da612d5f (diff) | |
download | sonarqube-9654662b48c918b55383846c6575b7f809437108.tar.gz sonarqube-9654662b48c918b55383846c6575b7f809437108.zip |
SONAR-4898 add missing tests
Diffstat (limited to 'sonar-testing-harness/src')
-rw-r--r-- | sonar-testing-harness/src/main/java/org/sonar/test/TestUtils.java | 16 |
1 files changed, 16 insertions, 0 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 e537466d262..0a5d8fcaef0 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 @@ -23,8 +23,13 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import java.io.File; +import java.lang.reflect.Constructor; +import java.lang.reflect.Modifier; import java.net.URL; +import static org.fest.assertions.Assertions.assertThat; +import static org.fest.assertions.Fail.fail; + /** * Utilities for unit tests * @@ -67,4 +72,15 @@ public final class TestUtils { resourcePath += path; return getResource(resourcePath); } + + public static void assertPrivateConstructor(Class clazz) { + try { + Constructor constructor = clazz.getDeclaredConstructor(); + assertThat(Modifier.isPrivate(constructor.getModifiers())).isTrue(); + constructor.setAccessible(true); + constructor.newInstance(); + } catch (Exception e) { + fail("Fail to instantiate " + clazz, e); + } + } } |