FileDocCategorySizeDatePackage
SystemPropertiesTest.javaAPI DocAndroid 5.1 API2201Thu Mar 12 22:22:12 GMT 2015android.os

SystemPropertiesTest

public class SystemPropertiesTest extends TestCase

Fields Summary
private static final String
KEY
private static final String
PERSIST_KEY
Constructors Summary
Methods Summary
public voidtestProperties()

        String value;

        SystemProperties.set(KEY, "");
        value = SystemProperties.get(KEY, "default");
        assertEquals("default", value);

        SystemProperties.set(KEY, "SA");
        value = SystemProperties.get(KEY, "default");
        assertEquals("SA", value);

        value = SystemProperties.get(KEY);
        assertEquals("SA", value);

        SystemProperties.set(KEY, "");
        value = SystemProperties.get(KEY, "default");
        assertEquals("default", value);

        value = SystemProperties.get(KEY);
        assertEquals("", value);
    
public voidtestStressMemoryPropertyConsistency()

        for (int i = 0; i < 100; ++i) {
            SystemProperties.set(KEY, Long.toString(i));
            long ret = SystemProperties.getLong(KEY, -1);
            assertEquals(i, ret);
        }
    
public voidtestStressPersistPropertyConsistency()


    
         
        for (int i = 0; i < 100; ++i) {
            SystemProperties.set(PERSIST_KEY, Long.toString(i));
            long ret = SystemProperties.getLong(PERSIST_KEY, -1);
            assertEquals(i, ret);
        }