diff --git a/src/test/java/org/junit/contrib/java/lang/system/internal/NoExitSecurityManagerTest.java b/src/test/java/org/junit/contrib/java/lang/system/internal/NoExitSecurityManagerTest.java index 76c8d35f..71557b5c 100644 --- a/src/test/java/org/junit/contrib/java/lang/system/internal/NoExitSecurityManagerTest.java +++ b/src/test/java/org/junit/contrib/java/lang/system/internal/NoExitSecurityManagerTest.java @@ -8,8 +8,10 @@ import static org.mockito.Mockito.when; import java.io.FileDescriptor; +import java.lang.reflect.Method; import java.net.InetAddress; import java.security.Permission; +import java.util.ArrayList; import java.util.List; import com.github.stefanbirkner.fishbowl.Statement; @@ -19,6 +21,7 @@ import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; @RunWith(Enclosed.class) @@ -98,6 +101,31 @@ public void evaluate() { } } + @RunWith(Parameterized.class) + public static class public_methods_override { + + @Parameters(name = "{0}") + public static List data() { + List methods = new ArrayList(); + for (Method method : NoExitSecurityManager.class.getMethods()) + if (notDeclaredByObjectClass(method)) + methods.add(new Object[] { testName(method), method }); + return methods; + } + + @Parameter(0) + public String methodName; + + @Parameter(1) + public Method method; + + @Test + public void is_implemented_by_NoExitSecurityManager() { + assertThat(method.getDeclaringClass()) + .isEqualTo(NoExitSecurityManager.class); + } + } + public static class with_original_SecurityManager { @Rule public final TemporaryFolder temporaryFolder = new TemporaryFolder(); @@ -516,4 +544,23 @@ public void getThreadGroup_may_be_called() { managerWithoutOriginal.getThreadGroup(); } } + + private static boolean notDeclaredByObjectClass(Method method) { + return !method.getDeclaringClass().equals(Object.class); + } + + private static String testName(Method method) { + return method.getName() + + "(" + join(method.getParameterTypes()) + ")"; + } + + private static String join(Class[] types) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < types.length; i++) { + if (i != 0) + sb.append(","); + sb.append(types[i].getSimpleName()); + } + return sb.toString(); + } }