コード例 #1
0
 @Test
 public void delegateCheckConnectWithContext() {
   int port = 234;
   Object context = new Object();
   managerWithOriginal.checkConnect("host", port, context);
   verify(originalSecurityManager).checkConnect("host", port, context);
 }
コード例 #2
0
 @Test
 public void delegateCheckMulticastWithTtl() {
   InetAddress inetAddress = mock(InetAddress.class);
   byte ttl = 24;
   managerWithOriginal.checkMulticast(inetAddress, ttl);
   verify(originalSecurityManager).checkMulticast(inetAddress, ttl);
 }
コード例 #3
0
 @Test
 public void delegateCheckPermission_Permission_Object() {
   Permission permission = mock(Permission.class);
   Object context = new Object();
   managerWithOriginal.checkPermission(permission, context);
   verify(originalSecurityManager).checkPermission(permission, context);
 }
コード例 #4
0
 @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);
 }
コード例 #8
0
 @Test
 public void provideThreadGroupOfOriginalSecurityManager() {
   ThreadGroup threadGroup = new ThreadGroup("dummy name");
   when(originalSecurityManager.getThreadGroup()).thenReturn(threadGroup);
   assertThat(managerWithOriginal.getThreadGroup(), is(threadGroup));
 }
コード例 #9
0
 @Test
 public void dontFailWithoutParentForCheckSecurityAccess() {
   managerWithoutOriginal.checkSecurityAccess("arbitrary target");
 }
コード例 #10
0
 @Test
 public void dontFailWithoutParentForCheckSystemClipboardAccess() {
   managerWithoutOriginal.checkSystemClipboardAccess();
 }
コード例 #11
0
 @Test
 public void delegateCheckCreateClassLoader() {
   managerWithOriginal.checkCreateClassLoader();
   verify(originalSecurityManager).checkCreateClassLoader();
 }
コード例 #12
0
 @Test
 public void delegateCheckPermission_Permission() {
   Permission permission = mock(Permission.class);
   managerWithOriginal.checkPermission(permission);
   verify(originalSecurityManager).checkPermission(permission);
 }
コード例 #13
0
 @Test
 public void provideSecurityContextOfOriginalSecurityManager() {
   Object context = new Object();
   when(originalSecurityManager.getSecurityContext()).thenReturn(context);
   assertThat(managerWithOriginal.getSecurityContext(), is(context));
 }
コード例 #14
0
 @Test
 public void delegateCheckSetFactory() {
   managerWithOriginal.checkSetFactory();
   verify(originalSecurityManager).checkSetFactory();
 }
コード例 #15
0
 @Test
 public void dontFailWithoutParentForCheckPackageDefinition() {
   managerWithoutOriginal.checkPackageDefinition("dummy package");
 }
コード例 #16
0
 @Test
 public void delegateCheckPackageDefinition() {
   managerWithOriginal.checkPackageDefinition("arbitrary package");
   verify(originalSecurityManager).checkPackageDefinition("arbitrary package");
 }
コード例 #17
0
 @Test
 public void dontFailWithoutParentForCheckPackageAccess() {
   managerWithoutOriginal.checkPackageAccess("dummy package");
 }
コード例 #18
0
 @Test
 public void dontFailWithoutParentForCheckAwtEventQueueAccess() {
   managerWithoutOriginal.checkAwtEventQueueAccess();
 }
コード例 #19
0
 @Test
 public void delegateCheckAwtEventQueueAccess() {
   managerWithOriginal.checkAwtEventQueueAccess();
   verify(originalSecurityManager).checkAwtEventQueueAccess();
 }
コード例 #20
0
 @Test
 public void dontFailWithoutParentForGetThreadGroup() {
   managerWithoutOriginal.getThreadGroup();
 }
コード例 #21
0
 @Test
 public void isNeverInCheckWithoutParent() {
   assertThat(managerWithoutOriginal.getInCheck(), is(false));
 }
コード例 #22
0
 @Test
 public void delegateGetInCheck() {
   when(originalSecurityManager.getInCheck()).thenReturn(true);
   assertThat(managerWithOriginal.getInCheck(), is(true));
 }
コード例 #23
0
 @Test
 public void dontFailWithoutParentForGetSecurityContext() {
   managerWithoutOriginal.getSecurityContext();
 }
コード例 #24
0
 @Test
 public void dontFailWithoutParentForCheckSetFactory() {
   managerWithoutOriginal.checkSetFactory();
 }
コード例 #25
0
 @Test
 public void dontFailWithoutParentForCheckPermission_Permission() {
   Permission permission = mock(Permission.class);
   managerWithoutOriginal.checkPermission(permission);
 }
コード例 #26
0
 @Test
 public void dontFailWithoutParentForCheckMemberAccess() {
   Class<?> arbitraryClass = Integer.class;
   int which = 394;
   managerWithoutOriginal.checkMemberAccess(arbitraryClass, which);
 }
コード例 #27
0
 @Test
 public void dontFailWithoutParentForCheckPermission_Permission_Object() {
   Permission permission = mock(Permission.class);
   Object context = new Object();
   managerWithoutOriginal.checkPermission(permission, context);
 }
コード例 #28
0
 @Test
 public void delegateCheckSecurityAccess() {
   managerWithOriginal.checkSecurityAccess("arbitrary target");
   verify(originalSecurityManager).checkSecurityAccess("arbitrary target");
 }
コード例 #29
0
 @Test
 public void dontFailWithoutParentForCheckCreateClassLoader() {
   managerWithoutOriginal.checkCreateClassLoader();
 }
コード例 #30
0
 @Test
 public void delegateCheckSystemClipboardAccess() {
   managerWithOriginal.checkSystemClipboardAccess();
   verify(originalSecurityManager).checkSystemClipboardAccess();
 }