@Test public void delegateCheckConnectWithContext() { int port = 234; Object context = new Object(); managerWithOriginal.checkConnect("host", port, context); verify(originalSecurityManager).checkConnect("host", port, context); }
@Test public void delegateCheckMulticastWithTtl() { InetAddress inetAddress = mock(InetAddress.class); byte ttl = 24; managerWithOriginal.checkMulticast(inetAddress, ttl); verify(originalSecurityManager).checkMulticast(inetAddress, ttl); }
@Test public void delegateCheckPermission_Permission_Object() { Permission permission = mock(Permission.class); Object context = new Object(); managerWithOriginal.checkPermission(permission, context); verify(originalSecurityManager).checkPermission(permission, context); }
@Test public void delegateCheckMemberAccess() { Class<?> arbitraryClass = Integer.class; int which = 394; managerWithOriginal.checkMemberAccess(arbitraryClass, which); verify(originalSecurityManager).checkMemberAccess(arbitraryClass, which); }
@Test public void should_Call_Hook_And_Throw_Error_If_Runtime_Halt_Was_Called() { StackTraceElement[] stackTrace = array(methodInRuntime("halt")); when(stackTraces.stackTraceInCurrentThread()).thenReturn(stackTrace); thrown.expect(ExitException.class); securityManager.checkExit(0); verify(hook).exitCalled(0); }
@Test public void should_Not_Call_Hook_And_Throw_Error_If_Method_Called_Is_In_Runtime_But_Is_Not_Exit_Or_Halt() { StackTraceElement[] stackTrace = array(methodInRuntime("availableProcessors")); when(stackTraces.stackTraceInCurrentThread()).thenReturn(stackTrace); securityManager.checkExit(0); verifyZeroInteractions(hook); }
@Test public void should_Not_Call_Hook_And_Throw_Error_If_Method_Called_Is_Not_Runtime_Exit_Or_Halt() { StackTraceElement e = new StackTraceElement(String.class.getName(), "substring", "String.java", 0); StackTraceElement[] stackTrace = array(e); when(stackTraces.stackTraceInCurrentThread()).thenReturn(stackTrace); securityManager.checkExit(0); verifyZeroInteractions(hook); }
@Test public void provideThreadGroupOfOriginalSecurityManager() { ThreadGroup threadGroup = new ThreadGroup("dummy name"); when(originalSecurityManager.getThreadGroup()).thenReturn(threadGroup); assertThat(managerWithOriginal.getThreadGroup(), is(threadGroup)); }
@Test public void dontFailWithoutParentForCheckSecurityAccess() { managerWithoutOriginal.checkSecurityAccess("arbitrary target"); }
@Test public void dontFailWithoutParentForCheckSystemClipboardAccess() { managerWithoutOriginal.checkSystemClipboardAccess(); }
@Test public void delegateCheckCreateClassLoader() { managerWithOriginal.checkCreateClassLoader(); verify(originalSecurityManager).checkCreateClassLoader(); }
@Test public void delegateCheckPermission_Permission() { Permission permission = mock(Permission.class); managerWithOriginal.checkPermission(permission); verify(originalSecurityManager).checkPermission(permission); }
@Test public void provideSecurityContextOfOriginalSecurityManager() { Object context = new Object(); when(originalSecurityManager.getSecurityContext()).thenReturn(context); assertThat(managerWithOriginal.getSecurityContext(), is(context)); }
@Test public void delegateCheckSetFactory() { managerWithOriginal.checkSetFactory(); verify(originalSecurityManager).checkSetFactory(); }
@Test public void dontFailWithoutParentForCheckPackageDefinition() { managerWithoutOriginal.checkPackageDefinition("dummy package"); }
@Test public void delegateCheckPackageDefinition() { managerWithOriginal.checkPackageDefinition("arbitrary package"); verify(originalSecurityManager).checkPackageDefinition("arbitrary package"); }
@Test public void dontFailWithoutParentForCheckPackageAccess() { managerWithoutOriginal.checkPackageAccess("dummy package"); }
@Test public void dontFailWithoutParentForCheckAwtEventQueueAccess() { managerWithoutOriginal.checkAwtEventQueueAccess(); }
@Test public void delegateCheckAwtEventQueueAccess() { managerWithOriginal.checkAwtEventQueueAccess(); verify(originalSecurityManager).checkAwtEventQueueAccess(); }
@Test public void dontFailWithoutParentForGetThreadGroup() { managerWithoutOriginal.getThreadGroup(); }
@Test public void isNeverInCheckWithoutParent() { assertThat(managerWithoutOriginal.getInCheck(), is(false)); }
@Test public void delegateGetInCheck() { when(originalSecurityManager.getInCheck()).thenReturn(true); assertThat(managerWithOriginal.getInCheck(), is(true)); }
@Test public void dontFailWithoutParentForGetSecurityContext() { managerWithoutOriginal.getSecurityContext(); }
@Test public void dontFailWithoutParentForCheckSetFactory() { managerWithoutOriginal.checkSetFactory(); }
@Test public void dontFailWithoutParentForCheckPermission_Permission() { Permission permission = mock(Permission.class); managerWithoutOriginal.checkPermission(permission); }
@Test public void dontFailWithoutParentForCheckMemberAccess() { Class<?> arbitraryClass = Integer.class; int which = 394; managerWithoutOriginal.checkMemberAccess(arbitraryClass, which); }
@Test public void dontFailWithoutParentForCheckPermission_Permission_Object() { Permission permission = mock(Permission.class); Object context = new Object(); managerWithoutOriginal.checkPermission(permission, context); }
@Test public void delegateCheckSecurityAccess() { managerWithOriginal.checkSecurityAccess("arbitrary target"); verify(originalSecurityManager).checkSecurityAccess("arbitrary target"); }
@Test public void dontFailWithoutParentForCheckCreateClassLoader() { managerWithoutOriginal.checkCreateClassLoader(); }
@Test public void delegateCheckSystemClipboardAccess() { managerWithOriginal.checkSystemClipboardAccess(); verify(originalSecurityManager).checkSystemClipboardAccess(); }