FileDocCategorySizeDatePackage
JavaUtilLocale.javaAPI DocAndroid 1.5 API2766Wed May 06 22:41:06 BST 2009tests.security.permissions

JavaUtilLocale

public class JavaUtilLocale extends TestCase

Fields Summary
SecurityManager
old
Constructors Summary
Methods Summary
protected voidsetUp()

        old = System.getSecurityManager();
        super.setUp();
    
protected voidtearDown()

        System.setSecurityManager(old);
        super.tearDown();
    
public voidtest_setDefault()

        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);