MyPrivilegedAction action = new MyPrivilegedAction();
String result = AccessController.doPrivileged(action);
assertEquals("return value not correct", "ok", result);
assertTrue("run method was not called", action.called);
MyPrivilegedAction2 action2 = new MyPrivilegedAction2();
try {
result = AccessController.doPrivileged(action2);
fail("exception expected");
} catch (RuntimeException e) {
// expected exception
}