class TestSecurityManager extends SecurityManager {
boolean called = false;
void reset(){
called = false;
}
@Override
public void checkPermission(Permission permission) {
if(permission instanceof PropertyPermission
&& "user.language".equals(permission.getName())
&& "write".equals(permission.getActions())){
called = true;
}
super.checkPermission(permission);
}
}
Locale loc = Locale.getDefault();
TestSecurityManager s = new TestSecurityManager();
System.setSecurityManager(s);
s.reset();
Locale.setDefault(loc);
assertTrue("java.util.Locale.setDefault(Locale) must call checkPermission on security permissions", s.called);