}
// PASS
logger.fine("Method returned correct SecurityContext instance.");
logger.fine("Set policy provider to SCSPolicyProvider.");
SCSPolicyProvider policy = new SCSPolicyProvider();
Policy.setPolicy(policy);
sc = Security.getContext();
if (policy.getCallsNum() != 1) {
// FAIL
throw new TestException(
"'getContext' method of installed policy provider was "
+ "called " + policy.getCallsNum() + " times while 1 "
+ "call was expected.");
}
if (!sc.equals(policy.getContext())) {
// FAIL
throw new TestException(
"'Security.getContext()' method returned " + sc
+ " SecurityPolicy while " + policy.getContext()
+ " was expected.");
}
// PASS
logger.fine("Method works as expected.");
logger.fine("Set security manager to SCSSecurityManager.");
SCSSecurityManager sm = new SCSSecurityManager();
System.setSecurityManager(sm);
policy.resetCallsNum();
sc = Security.getContext();
if (sm.getCallsNum() != 1) {
// FAIL
throw new TestException(
"'getContext' method of installed security manager was "
+ "called " + sm.getCallsNum() + " times while 1 "
+ "call was expected.");
}
if (policy.getCallsNum() != 0) {
// FAIL
throw new TestException(
"'getContext' method of installed policy provider was "
+ "called " + policy.getCallsNum()
+ " times while no calls were expected.");
}
if (!sc.equals(sm.getContext())) {
// FAIL