}
// PASS
logger.fine("'doPrivileged' method returned " + obj
+ " as expected.");
final PEAThrowingCheckedEx peaEx = new PEAThrowingCheckedEx(perm);
try {
callDoPrivileged(peaEx);
// FAIL
throw new TestException(
"Method did not throw any exception while "
+ "PrivilegedActionException was expected.");
} catch (PrivilegedActionException pae) {
if (peaEx.getException() != pae.getException()) {
// FAIL
throw new TestException(
"'doPrivileged' method threw exception containing "
+ pae.getException() + " while "
+ peaEx.getException() + " was expected.");
}
}
// PASS
logger.fine("PrivilegedActionException containing FakeException "
+ "was thrown as expected.");
if (peaEx.getCombiner() != null) {
// FAIL
throw new TestException(
"DomainCombiner inside 'doPrivileged' method of "
+ peaEx + " was " + peaEx.getCombiner()
+ " while null was expected.");
}
// PASS
logger.fine("DomainCombiner inside 'doPrivileged' method of "
+ peaEx + " was null as expected.");
if (!peaEx.isGrantedPerm()) {
// FAIL
throw new TestException(
"Privileges are not enabled inside 'doPrivileged' "
+ "method.");
}
// PASS
logger.fine("Privileges are enabled inside 'doPrivileged' "
+ "method as expected.");
final PEAThrowingCheckedEx peaEx1 = new PEAThrowingCheckedEx(perm1);
try {
try {
AccessController.doPrivileged(
new PrivilegedExceptionAction() {
public Object run() throws Exception {
return callDoPrivileged(peaEx1);
}
}, acc);
} catch (PrivilegedActionException e) {
throw e.getException();
}
// FAIL
throw new TestException(
"Method did not throw any exception while "
+ "PrivilegedActionException was expected.");
} catch (PrivilegedActionException pae) {
if (peaEx1.getException() != pae.getException()) {
// FAIL
throw new TestException(
"'doPrivileged' method threw exception containing "
+ pae.getException() + " while "
+ peaEx1.getException() + " was expected.");
}
}
if (peaEx1.getCombiner() != comb) {
// FAIL
throw new TestException(
"DomainCombiner inside 'doPrivileged' method of "
+ peaEx1 + " was " + peaEx1.getCombiner()
+ " while " + comb + " was expected.");
}
// PASS
logger.fine("DomainCombiner inside 'doPrivileged' method of "
+ peaEx1 + " was " + comb + " as expected.");
if (!peaEx1.isGrantedPerm()) {
// FAIL
throw new TestException(
"Privileges are not enabled inside 'doPrivileged' "
+ "method.");
}