1 33 34 package edu.rice.cs.util; 35 36 import edu.rice.cs.drjava.DrJavaTestCase; 37 38 42 public class PreventExitSecurityManagerTest extends DrJavaTestCase { 43 private PreventExitSecurityManager _manager; 44 45 46 public void setUp() throws Exception { 47 super.setUp(); 48 _manager = PreventExitSecurityManager.activate(); 49 } 50 51 52 public void tearDown() throws Exception { 53 _manager.deactivate(); 54 super.tearDown(); 55 } 56 57 public void testSystemExitPrevented() { 58 try { 59 System.exit(1); 60 fail("System.exit passed?!"); 61 } 62 catch (ExitingNotAllowedException se) { 63 } 65 } 66 67 public void testExitVMRespectsBlock() { 68 _manager.setBlockExit(true); 69 try { 70 _manager.exitVM(-1); 71 fail("exitVM passed while blocked!"); 72 } 73 catch (ExitingNotAllowedException se) { 74 } 76 } 77 78 public void testCanNotChangeSecurityManager() { 79 try { 80 System.setSecurityManager(null); 81 fail("setSecurityManager passed!"); 82 } 83 catch (SecurityException se) { 84 } 86 } 87 } 88 | Popular Tags |