harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r730659 [4/4] - in /harmony/enhanced/classlib/trunk/modules/prefs/src: main/java/java/util/prefs/ test/java/org/apache/harmony/prefs/tests/ test/java/org/apache/harmony/prefs/tests/java/util/prefs/
Date Fri, 02 Jan 2009 02:52:35 GMT
Modified: harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AllTests.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AllTests.java?rev=730659&r1=730658&r2=730659&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AllTests.java (original)
+++ harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AllTests.java Thu Jan  1 18:52:34 2009
@@ -25,24 +25,24 @@
  */
 public class AllTests {
 
-	public static void main(String[] args) {
-		junit.textui.TestRunner.run(AllTests.suite());
-	}
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(AllTests.suite());
+    }
 
-	public static Test suite() {
-		TestSuite suite = new TestSuite("Suite for org.apache.harmony.prefs.tests.java.util.prefs");
-		// $JUnit-BEGIN$
-		suite.addTestSuite(NodeChangeListenerTest.class);
-		suite.addTestSuite(PreferenceChangeListenerTest.class);
-		suite.addTestSuite(PreferencesFactoryTest.class);
-		suite.addTestSuite(BackingStoreExceptionTest.class);
-		suite.addTestSuite(InvalidPreferencesFormatExceptionTest.class);
-		suite.addTestSuite(PreferenceChangeEventTest.class);
-		suite.addTestSuite(NodeChangeEventTest.class);
-		suite.addTestSuite(PreferencesTest.class);
-		suite.addTestSuite(AbstractPreferencesTest.class);
+    public static Test suite() {
+        TestSuite suite = new TestSuite("Suite for org.apache.harmony.prefs.tests.java.util.prefs");
+        // $JUnit-BEGIN$
+        suite.addTestSuite(NodeChangeListenerTest.class);
+        suite.addTestSuite(PreferenceChangeListenerTest.class);
+        suite.addTestSuite(PreferencesFactoryTest.class);
+        suite.addTestSuite(BackingStoreExceptionTest.class);
+        suite.addTestSuite(InvalidPreferencesFormatExceptionTest.class);
+        suite.addTestSuite(PreferenceChangeEventTest.class);
+        suite.addTestSuite(NodeChangeEventTest.class);
+        suite.addTestSuite(PreferencesTest.class);
+        suite.addTestSuite(AbstractPreferencesTest.class);
         suite.addTestSuite(FilePreferencesImplTest.class);
-		// $JUnit-END$
-		return suite;
-	}
+        // $JUnit-END$
+        return suite;
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/FilePreferencesImplTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/FilePreferencesImplTest.java?rev=730659&r1=730658&r2=730659&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/FilePreferencesImplTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/FilePreferencesImplTest.java Thu Jan  1 18:52:34 2009
@@ -27,204 +27,204 @@
 public class FilePreferencesImplTest extends TestCase {
 
     private String prevFactory;
-	private Preferences uroot;
-	private Preferences sroot;
-    
+    private Preferences uroot;
+    private Preferences sroot;
+
     public FilePreferencesImplTest() {
         super();
     }
-    
+
     @Override
     protected void setUp() throws Exception {
         prevFactory = System.getProperty("java.util.prefs.PreferencesFactory");
         System.setProperty("java.util.prefs.PreferencesFactory", "java.util.prefs.FilePreferencesFactoryImpl");
-        
+
         uroot = Preferences.userRoot();
         sroot = Preferences.systemRoot();
     }
-    
+
     @Override
     protected void tearDown() throws Exception {
         if (prevFactory != null)
             System.setProperty("java.util.prefs.PreferencesFactory", prevFactory);
-        
+
         uroot = null;
         sroot = null;
     }
 
-	public void testPutGet() throws IOException, BackingStoreException {
-		uroot.put("ukey1", "value1");
-		assertEquals("value1", uroot.get("ukey1", null));
-		String[] names = uroot.keys();
-		assertEquals(1, names.length);
-
-		uroot.put("ukey2", "value3");
-		assertEquals("value3", uroot.get("ukey2", null));
-		uroot.put("\u4e2d key1", "\u4e2d value1");
-		assertEquals("\u4e2d value1", uroot.get("\u4e2d key1", null));
-		names = uroot.keys();
-		assertEquals(3, names.length);
-
-		uroot.flush();
-		uroot.clear();
-		names = uroot.keys();
-		assertEquals(0, names.length);
-
-		sroot.put("skey1", "value1");
-		assertEquals("value1", sroot.get("skey1", null));
-		sroot.put("\u4e2d key1", "\u4e2d value1");
-		assertEquals("\u4e2d value1", sroot.get("\u4e2d key1", null));
-	}
-
-	public void testChildNodes() throws Exception {
-		Preferences child1 = uroot.node("child1");
-		Preferences child2 = uroot.node("\u4e2d child2");
-		Preferences grandchild = child1.node("grand");
+    public void testPutGet() throws IOException, BackingStoreException {
+        uroot.put("ukey1", "value1");
+        assertEquals("value1", uroot.get("ukey1", null));
+        String[] names = uroot.keys();
+        assertEquals(1, names.length);
+
+        uroot.put("ukey2", "value3");
+        assertEquals("value3", uroot.get("ukey2", null));
+        uroot.put("\u4e2d key1", "\u4e2d value1");
+        assertEquals("\u4e2d value1", uroot.get("\u4e2d key1", null));
+        names = uroot.keys();
+        assertEquals(3, names.length);
+
+        uroot.flush();
+        uroot.clear();
+        names = uroot.keys();
+        assertEquals(0, names.length);
+
+        sroot.put("skey1", "value1");
+        assertEquals("value1", sroot.get("skey1", null));
+        sroot.put("\u4e2d key1", "\u4e2d value1");
+        assertEquals("\u4e2d value1", sroot.get("\u4e2d key1", null));
+    }
+
+    public void testChildNodes() throws Exception {
+        Preferences child1 = uroot.node("child1");
+        Preferences child2 = uroot.node("\u4e2d child2");
+        Preferences grandchild = child1.node("grand");
         assertNotNull(grandchild);
 
-		String[] childNames = uroot.childrenNames();
-		assertEquals(2, childNames.length);
-		for (int i = 0; i < childNames.length; i++) {
-			System.out.println(childNames[i]);
-		}
-
-		childNames = child1.childrenNames();
-		assertEquals(1, childNames.length);
-		for (int i = 0; i < childNames.length; i++) {
-			System.out.println(childNames[i]);
-		}
-
-		childNames = child2.childrenNames();
-		assertEquals(0, childNames.length);
-		for (int i = 0; i < childNames.length; i++) {
-			System.out.println(childNames[i]);
-		}
-
-		child1.removeNode();
-		childNames = uroot.childrenNames();
-		assertEquals(1, childNames.length);
-		for (int i = 0; i < childNames.length; i++) {
-			System.out.println(childNames[i]);
-		}
-		// child2.removeNode();
-		// childNames = uroot.childrenNames();
-		// assertEquals(0, childNames.length);
-
-		child1 = sroot.node("child1");
-		child2 = sroot.node("child2");
-		grandchild = child1.node("grand");
-
-		childNames = sroot.childrenNames();
-
-		for (int i = 0; i < childNames.length; i++) {
-			System.out.println(childNames[i]);
-		}
-		assertEquals(2, childNames.length);
-
-		childNames = child1.childrenNames();
-		assertEquals(1, childNames.length);
-		for (int i = 0; i < childNames.length; i++) {
-			System.out.println(childNames[i]);
-		}
-
-		childNames = child2.childrenNames();
-		assertEquals(0, childNames.length);
-		for (int i = 0; i < childNames.length; i++) {
-			System.out.println(childNames[i]);
-		}
-
-		child1.removeNode();
-		assertNotSame(child1, sroot.node("child1"));
-		assertSame(sroot.node("child1"), sroot.node("child1"));
-		sroot.node("child1").removeNode();
-		childNames = sroot.childrenNames();
-		assertEquals(1, childNames.length);
-		for (int i = 0; i < childNames.length; i++) {
-			System.out.println(childNames[i]);
-		}
-		child2.removeNode();
-		childNames = sroot.childrenNames();
-		assertEquals(0, childNames.length);
-	}
-
-	public void testSecurityException() throws BackingStoreException {
-		Preferences child1 = uroot.node("child1");
-		MockFileSecurityManager manager = new MockFileSecurityManager();
-		manager.install();
-		try {
-			try {
-				uroot.node("securityNode");
-				fail("should throw security exception");
-			} catch (SecurityException e) {
-			}
-			try {
-				// need FilePermission(delete);
-				child1.removeNode();
-				fail("should throw security exception");
-			} catch (SecurityException e) {
-			}
-			try {
-				uroot.childrenNames();
-				fail("should throw security exception");
-			} catch (SecurityException e) {
-			}
-			uroot.keys();
-			uroot.put("securitykey", "value1");
-			uroot.remove("securitykey");
-			try {
-				uroot.flush();
-				fail("should throw security exception");
-			} catch (SecurityException e) {
-			} catch (BackingStoreException e) {
-				assertTrue(e.getCause() instanceof SecurityException);
-			}
-			try {
-				uroot.sync();
-				fail("should throw security exception");
-			} catch (SecurityException e) {
-			} catch (BackingStoreException e) {
-				assertTrue(e.getCause() instanceof SecurityException);
-			}
-		} finally {
-			manager.restoreDefault();
-		}
-	}
-
-	static class MockFileSecurityManager extends SecurityManager {
-
-		SecurityManager dflt;
-
-		public MockFileSecurityManager() {
-			super();
-			dflt = System.getSecurityManager();
-		}
-
-		public void install() {
-			System.setSecurityManager(this);
-		}
-
-		public void restoreDefault() {
-			System.setSecurityManager(dflt);
-		}
+        String[] childNames = uroot.childrenNames();
+        assertEquals(2, childNames.length);
+        for (int i = 0; i < childNames.length; i++) {
+            System.out.println(childNames[i]);
+        }
+
+        childNames = child1.childrenNames();
+        assertEquals(1, childNames.length);
+        for (int i = 0; i < childNames.length; i++) {
+            System.out.println(childNames[i]);
+        }
+
+        childNames = child2.childrenNames();
+        assertEquals(0, childNames.length);
+        for (int i = 0; i < childNames.length; i++) {
+            System.out.println(childNames[i]);
+        }
+
+        child1.removeNode();
+        childNames = uroot.childrenNames();
+        assertEquals(1, childNames.length);
+        for (int i = 0; i < childNames.length; i++) {
+            System.out.println(childNames[i]);
+        }
+        // child2.removeNode();
+        // childNames = uroot.childrenNames();
+        // assertEquals(0, childNames.length);
+
+        child1 = sroot.node("child1");
+        child2 = sroot.node("child2");
+        grandchild = child1.node("grand");
+
+        childNames = sroot.childrenNames();
+
+        for (int i = 0; i < childNames.length; i++) {
+            System.out.println(childNames[i]);
+        }
+        assertEquals(2, childNames.length);
+
+        childNames = child1.childrenNames();
+        assertEquals(1, childNames.length);
+        for (int i = 0; i < childNames.length; i++) {
+            System.out.println(childNames[i]);
+        }
+
+        childNames = child2.childrenNames();
+        assertEquals(0, childNames.length);
+        for (int i = 0; i < childNames.length; i++) {
+            System.out.println(childNames[i]);
+        }
+
+        child1.removeNode();
+        assertNotSame(child1, sroot.node("child1"));
+        assertSame(sroot.node("child1"), sroot.node("child1"));
+        sroot.node("child1").removeNode();
+        childNames = sroot.childrenNames();
+        assertEquals(1, childNames.length);
+        for (int i = 0; i < childNames.length; i++) {
+            System.out.println(childNames[i]);
+        }
+        child2.removeNode();
+        childNames = sroot.childrenNames();
+        assertEquals(0, childNames.length);
+    }
+
+    public void testSecurityException() throws BackingStoreException {
+        Preferences child1 = uroot.node("child1");
+        MockFileSecurityManager manager = new MockFileSecurityManager();
+        manager.install();
+        try {
+            try {
+                uroot.node("securityNode");
+                fail("should throw security exception");
+            } catch (SecurityException e) {
+            }
+            try {
+                // need FilePermission(delete);
+                child1.removeNode();
+                fail("should throw security exception");
+            } catch (SecurityException e) {
+            }
+            try {
+                uroot.childrenNames();
+                fail("should throw security exception");
+            } catch (SecurityException e) {
+            }
+            uroot.keys();
+            uroot.put("securitykey", "value1");
+            uroot.remove("securitykey");
+            try {
+                uroot.flush();
+                fail("should throw security exception");
+            } catch (SecurityException e) {
+            } catch (BackingStoreException e) {
+                assertTrue(e.getCause() instanceof SecurityException);
+            }
+            try {
+                uroot.sync();
+                fail("should throw security exception");
+            } catch (SecurityException e) {
+            } catch (BackingStoreException e) {
+                assertTrue(e.getCause() instanceof SecurityException);
+            }
+        } finally {
+            manager.restoreDefault();
+        }
+    }
+
+    static class MockFileSecurityManager extends SecurityManager {
+
+        SecurityManager dflt;
 
-		@Override
+        public MockFileSecurityManager() {
+            super();
+            dflt = System.getSecurityManager();
+        }
+
+        public void install() {
+            System.setSecurityManager(this);
+        }
+
+        public void restoreDefault() {
+            System.setSecurityManager(dflt);
+        }
+
+        @Override
         public void checkPermission(Permission perm) {
-			if (perm instanceof FilePermission) {
-				throw new SecurityException();
-			} else if (dflt != null) {
-				dflt.checkPermission(perm);
-			}
-		}
+            if (perm instanceof FilePermission) {
+                throw new SecurityException();
+            } else if (dflt != null) {
+                dflt.checkPermission(perm);
+            }
+        }
 
-		@Override
+        @Override
         public void checkPermission(Permission perm, Object ctx) {
-			if (perm instanceof FilePermission) {
-				System.out.println(perm.getActions());
-				throw new SecurityException();
-			} else if (dflt != null) {
-				dflt.checkPermission(perm, ctx);
-			}
-		}
+            if (perm instanceof FilePermission) {
+                System.out.println(perm.getActions());
+                throw new SecurityException();
+            } else if (dflt != null) {
+                dflt.checkPermission(perm, ctx);
+            }
+        }
 
-	}
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/InvalidPreferencesFormatExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/InvalidPreferencesFormatExceptionTest.java?rev=730659&r1=730658&r2=730659&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/InvalidPreferencesFormatExceptionTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/InvalidPreferencesFormatExceptionTest.java Thu Jan  1 18:52:34 2009
@@ -32,7 +32,7 @@
      */
     public void testInvalidPreferencesFormatExceptionString() {
         InvalidPreferencesFormatException e = new InvalidPreferencesFormatException(
-                "msg");
+        "msg");
         assertNull(e.getCause());
         assertEquals("msg", e.getMessage());
     }
@@ -69,7 +69,7 @@
     public void testSerializationSelf() throws Exception {
 
         SerializationTest.verifySelf(new InvalidPreferencesFormatException(
-                "msg"));
+        "msg"));
     }
 
     /**

Modified: harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockAbstractPreferences.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockAbstractPreferences.java?rev=730659&r1=730658&r2=730659&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockAbstractPreferences.java (original)
+++ harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockAbstractPreferences.java Thu Jan  1 18:52:34 2009
@@ -24,231 +24,231 @@
 import java.util.prefs.BackingStoreException;
 
 public class MockAbstractPreferences extends AbstractPreferences {
-	static final int NORMAL = 0;
+    static final int NORMAL = 0;
 
-	static final int backingException = 1;
+    static final int backingException = 1;
 
-	static final int runtimeException = 2;
+    static final int runtimeException = 2;
 
-	static final int returnNull = 3;
+    static final int returnNull = 3;
 
-	int result = NORMAL;
+    int result = NORMAL;
 
-	Properties attr = new Properties();
+    Properties attr = new Properties();
 
-	Map<String, MockAbstractPreferences> childs = new HashMap<String, MockAbstractPreferences>();
+    Map<String, MockAbstractPreferences> childs = new HashMap<String, MockAbstractPreferences>();
 
-	private int flushedTimes;
+    private int flushedTimes;
 
-	private int syncTimes;
+    private int syncTimes;
 
-	protected MockAbstractPreferences(AbstractPreferences parent, String name) {
-		this(parent, name, false);
+    protected MockAbstractPreferences(AbstractPreferences parent, String name) {
+        this(parent, name, false);
 
-	}
+    }
 
-	protected MockAbstractPreferences(AbstractPreferences parent, String name,
-			boolean newNode) {
-		super(parent, name);
-		super.newNode = newNode;
-		if (parent instanceof MockAbstractPreferences) {
-			((MockAbstractPreferences) parent).addChild(this);
-		}
-	}
+    protected MockAbstractPreferences(AbstractPreferences parent, String name,
+            boolean newNode) {
+        super(parent, name);
+        super.newNode = newNode;
+        if (parent instanceof MockAbstractPreferences) {
+            ((MockAbstractPreferences) parent).addChild(this);
+        }
+    }
 
-	public int getFlushedTimes() {
-		return flushedTimes;
-	}
+    public int getFlushedTimes() {
+        return flushedTimes;
+    }
 
-	public void resetFlushedTimes() {
-		flushedTimes = 0;
-	}
+    public void resetFlushedTimes() {
+        flushedTimes = 0;
+    }
 
-	public int getSyncTimes() {
-		return syncTimes;
-	}
+    public int getSyncTimes() {
+        return syncTimes;
+    }
 
-	public void resetSyncTimes() {
-		syncTimes = 0;
-	}
+    public void resetSyncTimes() {
+        syncTimes = 0;
+    }
 
-	private void addChild(MockAbstractPreferences c) {
-		childs.put(c.name(), c);
-	}
+    private void addChild(MockAbstractPreferences c) {
+        childs.put(c.name(), c);
+    }
 
-	public void setResult(int r) {
-		result = r;
-	}
+    public void setResult(int r) {
+        result = r;
+    }
 
-	public Object lock() {
-		return lock;
-	}
+    public Object lock() {
+        return lock;
+    }
 
-	@Override
+    @Override
     protected String[] childrenNamesSpi() throws BackingStoreException {
-		checkException();
-		if (result == returnNull)
-			return null;
-		String[] r = new String[childs.size()];
-		childs.keySet().toArray(r);
-		return r;
-	}
-
-	private void checkException() throws BackingStoreException {
-		switch (result) {
-		case NORMAL:
-			return;
-		case backingException:
-			throw new BackingStoreException("test");
-		case runtimeException:
-			throw new MockRuntimeException("test");
-		}
-	}
-
-	public AbstractPreferences publicChildSpi(String name) {
-		return childSpi(name);
-	}
+        checkException();
+        if (result == returnNull)
+            return null;
+        String[] r = new String[childs.size()];
+        childs.keySet().toArray(r);
+        return r;
+    }
+
+    private void checkException() throws BackingStoreException {
+        switch (result) {
+        case NORMAL:
+            return;
+        case backingException:
+            throw new BackingStoreException("test");
+        case runtimeException:
+            throw new MockRuntimeException("test");
+        }
+    }
+
+    public AbstractPreferences publicChildSpi(String name) {
+        return childSpi(name);
+    }
 
-	@Override
+    @Override
     protected AbstractPreferences childSpi(String name) {
-		try {
-			checkException();
-		} catch (BackingStoreException e) {
-		}
-		if (result == returnNull)
-			return null;
-		AbstractPreferences r = childs.get(name);
-		if (r == null) {
-			r = new MockAbstractPreferences(this, name, true);
-
-		}
-		return r;
-	}
+        try {
+            checkException();
+        } catch (BackingStoreException e) {
+        }
+        if (result == returnNull)
+            return null;
+        AbstractPreferences r = childs.get(name);
+        if (r == null) {
+            r = new MockAbstractPreferences(this, name, true);
+
+        }
+        return r;
+    }
 
-	@Override
+    @Override
     protected void flushSpi() throws BackingStoreException {
-		checkException();
-		flushedTimes++;
-	}
+        checkException();
+        flushedTimes++;
+    }
 
-	@Override
+    @Override
     protected String getSpi(String key) {
-		try {
-			checkException();
-		} catch (BackingStoreException e) {
-		}
-		if (null == key) {
-			return null;
-		}
-		return result == returnNull ? null : attr.getProperty(key);
-	}
+        try {
+            checkException();
+        } catch (BackingStoreException e) {
+        }
+        if (null == key) {
+            return null;
+        }
+        return result == returnNull ? null : attr.getProperty(key);
+    }
 
-	@Override
+    @Override
     protected String[] keysSpi() throws BackingStoreException {
-		checkException();
-		Set<Object> keys = attr.keySet();
-		String[] results = new String[keys.size()];
-		keys.toArray(results);
-		return result == returnNull ? null : results;
-	}
+        checkException();
+        Set<Object> keys = attr.keySet();
+        String[] results = new String[keys.size()];
+        keys.toArray(results);
+        return result == returnNull ? null : results;
+    }
 
-	@Override
+    @Override
     protected void putSpi(String name, String value) {
-		try {
-			checkException();
-		} catch (BackingStoreException e) {
-		}
-		if (name == null || value == null) {
-			return;
-		}
-		attr.put(name, value);
-	}
+        try {
+            checkException();
+        } catch (BackingStoreException e) {
+        }
+        if (name == null || value == null) {
+            return;
+        }
+        attr.put(name, value);
+    }
 
-	@Override
+    @Override
     protected void removeNodeSpi() throws BackingStoreException {
-		checkException();
-		((MockAbstractPreferences) parent()).childs.remove(name());
-	}
+        checkException();
+        ((MockAbstractPreferences) parent()).childs.remove(name());
+    }
 
-	@Override
+    @Override
     protected void removeSpi(String key) {
-		try {
-			checkException();
-		} catch (BackingStoreException e) {
-		}
-		if (null == key) {
-			return;
-		}
-		attr.remove(key);
-	}
+        try {
+            checkException();
+        } catch (BackingStoreException e) {
+        }
+        if (null == key) {
+            return;
+        }
+        attr.remove(key);
+    }
 
-	@Override
+    @Override
     protected void syncSpi() throws BackingStoreException {
-		checkException();
-		syncTimes++;
-	}
-
-	public boolean getNewNode() {
-		return newNode;
-	}
-
-	public Object getLock() {
-		return lock;
-	}
-
-	public void protectedAbstractMethod() {
-		try {
-			childrenNamesSpi();
-		} catch (BackingStoreException e) {
-		}
-		childSpi("mock");
-		try {
-			flushSpi();
-		} catch (BackingStoreException e1) {
-		}
-		getSpi(null);
-		isRemoved();
-		try {
-			keysSpi();
-		} catch (BackingStoreException e2) {
-		}
-		putSpi(null, null);
-		try {
-			removeNodeSpi();
-		} catch (BackingStoreException e3) {
-		}
-		removeSpi(null);
-		try {
-			syncSpi();
-		} catch (BackingStoreException e4) {
-		}
-	}
-
-	public boolean isRemovedImpl() {
-		return super.isRemoved();
-	}
-
-	public AbstractPreferences getChildImpl(String name)
-			throws BackingStoreException {
-		return super.getChild(name);
-	}
-
-	public AbstractPreferences[] cachedChildrenImpl() {
-		return super.cachedChildren();
-	}
+        checkException();
+        syncTimes++;
+    }
+
+    public boolean getNewNode() {
+        return newNode;
+    }
+
+    public Object getLock() {
+        return lock;
+    }
+
+    public void protectedAbstractMethod() {
+        try {
+            childrenNamesSpi();
+        } catch (BackingStoreException e) {
+        }
+        childSpi("mock");
+        try {
+            flushSpi();
+        } catch (BackingStoreException e1) {
+        }
+        getSpi(null);
+        isRemoved();
+        try {
+            keysSpi();
+        } catch (BackingStoreException e2) {
+        }
+        putSpi(null, null);
+        try {
+            removeNodeSpi();
+        } catch (BackingStoreException e3) {
+        }
+        removeSpi(null);
+        try {
+            syncSpi();
+        } catch (BackingStoreException e4) {
+        }
+    }
+
+    public boolean isRemovedImpl() {
+        return super.isRemoved();
+    }
+
+    public AbstractPreferences getChildImpl(String name)
+    throws BackingStoreException {
+        return super.getChild(name);
+    }
+
+    public AbstractPreferences[] cachedChildrenImpl() {
+        return super.cachedChildren();
+    }
 
 }
 
 class MockRuntimeException extends RuntimeException {
 
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
-	public MockRuntimeException(String s) {
-		super(s);
-	}
-
-	public MockRuntimeException() {
-		super();
-	}
+    public MockRuntimeException(String s) {
+        super(s);
+    }
+
+    public MockRuntimeException() {
+        super();
+    }
 }
 

Modified: harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockPreferencesFactory.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockPreferencesFactory.java?rev=730659&r1=730658&r2=730659&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockPreferencesFactory.java (original)
+++ harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockPreferencesFactory.java Thu Jan  1 18:52:34 2009
@@ -23,20 +23,20 @@
  * 
  */
 public class MockPreferencesFactory implements PreferencesFactory {
-	static MockAbstractPreferences userRoot = new MockAbstractPreferences(null,
-			"");
+    static MockAbstractPreferences userRoot = new MockAbstractPreferences(null,
+    "");
 
-	static MockAbstractPreferences systemRoot = new MockAbstractPreferences(
-			null, "");
+    static MockAbstractPreferences systemRoot = new MockAbstractPreferences(
+            null, "");
 
-	public MockPreferencesFactory() {
-	}
+    public MockPreferencesFactory() {
+    }
 
-	public Preferences userRoot() {
-		return userRoot;
-	}
+    public Preferences userRoot() {
+        return userRoot;
+    }
 
-	public Preferences systemRoot() {
-		return systemRoot;
-	}
+    public Preferences systemRoot() {
+        return systemRoot;
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockSecurityManager.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockSecurityManager.java?rev=730659&r1=730658&r2=730659&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockSecurityManager.java (original)
+++ harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockSecurityManager.java Thu Jan  1 18:52:34 2009
@@ -24,39 +24,39 @@
  */
 class MockSecurityManager extends SecurityManager {
 
-	SecurityManager dflt;
+    SecurityManager dflt;
 
-	public MockSecurityManager() {
-		super();
-		dflt = System.getSecurityManager();
-	}
-
-	public void install() {
-		System.setSecurityManager(this);
-	}
-
-	public void restoreDefault() {
-		System.setSecurityManager(dflt);
-	}
+    public MockSecurityManager() {
+        super();
+        dflt = System.getSecurityManager();
+    }
+
+    public void install() {
+        System.setSecurityManager(this);
+    }
+
+    public void restoreDefault() {
+        System.setSecurityManager(dflt);
+    }
 
-	@Override
+    @Override
     public void checkPermission(Permission perm) {
-		if (perm instanceof RuntimePermission
-				&& perm.getName().equals("preferences")) {
-			throw new SecurityException();
-		} else if (dflt != null) {
-			dflt.checkPermission(perm);
-		}
-	}
+        if (perm instanceof RuntimePermission
+                && perm.getName().equals("preferences")) {
+            throw new SecurityException();
+        } else if (dflt != null) {
+            dflt.checkPermission(perm);
+        }
+    }
 
-	@Override
+    @Override
     public void checkPermission(Permission perm, Object ctx) {
-		if (perm instanceof RuntimePermission
-				&& perm.getName().equals("preferences")) {
-			throw new SecurityException();
-		} else if (dflt != null) {
-			dflt.checkPermission(perm, ctx);
-		}
-	}
+        if (perm instanceof RuntimePermission
+                && perm.getName().equals("preferences")) {
+            throw new SecurityException();
+        } else if (dflt != null) {
+            dflt.checkPermission(perm, ctx);
+        }
+    }
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/NodeChangeListenerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/NodeChangeListenerTest.java?rev=730659&r1=730658&r2=730659&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/NodeChangeListenerTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/NodeChangeListenerTest.java Thu Jan  1 18:52:34 2009
@@ -27,43 +27,43 @@
  */
 public class NodeChangeListenerTest extends TestCase {
 
-	NodeChangeListener l;
+    NodeChangeListener l;
 
-	/*
-	 * @see TestCase#setUp()
-	 */
-	@Override
+    /*
+     * @see TestCase#setUp()
+     */
+    @Override
     protected void setUp() throws Exception {
-		super.setUp();
-		l = new NodeChangeListenerImpl();
-	}
-
-	/*
-	 * @see TestCase#tearDown()
-	 */
-	@Override
+        super.setUp();
+        l = new NodeChangeListenerImpl();
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    @Override
     protected void tearDown() throws Exception {
-		super.tearDown();
-	}
+        super.tearDown();
+    }
 
-	public void testChildAdded() {
-		l.childAdded(new NodeChangeEvent(Preferences.userRoot(), Preferences
-				.userRoot()));
-	}
+    public void testChildAdded() {
+        l.childAdded(new NodeChangeEvent(Preferences.userRoot(), Preferences
+                .userRoot()));
+    }
 
-	public void testChildRemoved() {
-		l.childRemoved(new NodeChangeEvent(Preferences.userRoot(), Preferences
-				.userRoot()));
-	}
+    public void testChildRemoved() {
+        l.childRemoved(new NodeChangeEvent(Preferences.userRoot(), Preferences
+                .userRoot()));
+    }
 
-	public static class NodeChangeListenerImpl implements NodeChangeListener {
+    public static class NodeChangeListenerImpl implements NodeChangeListener {
 
-		public void childAdded(NodeChangeEvent e) {
-		}
+        public void childAdded(NodeChangeEvent e) {
+        }
 
-		public void childRemoved(NodeChangeEvent e) {
-		}
+        public void childRemoved(NodeChangeEvent e) {
+        }
 
-	}
+    }
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferenceChangeEventTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferenceChangeEventTest.java?rev=730659&r1=730658&r2=730659&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferenceChangeEventTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferenceChangeEventTest.java Thu Jan  1 18:52:34 2009
@@ -67,7 +67,7 @@
 
     public void testConstructor() {
         event = new PreferenceChangeEvent(Preferences.userRoot(), "key",
-                "value");
+        "value");
         assertEquals("key", event.getKey());
         assertEquals("value", event.getNewValue());
         assertSame(Preferences.userRoot(), event.getNode());
@@ -76,7 +76,7 @@
 
     public void testSerialization() throws Exception {
         event = new PreferenceChangeEvent(Preferences.userRoot(), "key",
-                "value");
+        "value");
         try {
             SerializationTest.copySerializable(event);
             fail("No expected NotSerializableException");

Modified: harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferenceChangeListenerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferenceChangeListenerTest.java?rev=730659&r1=730658&r2=730659&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferenceChangeListenerTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferenceChangeListenerTest.java Thu Jan  1 18:52:34 2009
@@ -27,27 +27,27 @@
  */
 public class PreferenceChangeListenerTest extends TestCase {
 
-	PreferenceChangeListener l;
+    PreferenceChangeListener l;
 
-	/*
-	 * @see TestCase#setUp()
-	 */
-	@Override
+    /*
+     * @see TestCase#setUp()
+     */
+    @Override
     protected void setUp() throws Exception {
-		super.setUp();
-		l = new PreferenceChangeListenerImpl();
-	}
-
-	public void testPreferenceChange() {
-		l.preferenceChange(new PreferenceChangeEvent(Preferences.userRoot(),
-				"", ""));
-	}
-
-	public static class PreferenceChangeListenerImpl implements
-			PreferenceChangeListener {
-		public void preferenceChange(PreferenceChangeEvent pce) {
-		}
+        super.setUp();
+        l = new PreferenceChangeListenerImpl();
+    }
+
+    public void testPreferenceChange() {
+        l.preferenceChange(new PreferenceChangeEvent(Preferences.userRoot(),
+                "", ""));
+    }
+
+    public static class PreferenceChangeListenerImpl implements
+    PreferenceChangeListener {
+        public void preferenceChange(PreferenceChangeEvent pce) {
+        }
 
-	}
+    }
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesFactoryTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesFactoryTest.java?rev=730659&r1=730658&r2=730659&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesFactoryTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesFactoryTest.java Thu Jan  1 18:52:34 2009
@@ -26,35 +26,35 @@
  */
 public class PreferencesFactoryTest extends TestCase {
 
-	PreferencesFactory f;
+    PreferencesFactory f;
 
-	/*
-	 * @see TestCase#setUp()
-	 */
-	@Override
+    /*
+     * @see TestCase#setUp()
+     */
+    @Override
     protected void setUp() throws Exception {
-		super.setUp();
-		f = new PreferencesFactoryImpl();
-	}
+        super.setUp();
+        f = new PreferencesFactoryImpl();
+    }
 
-	public void testUserRoot() {
-		f.userRoot();
-	}
+    public void testUserRoot() {
+        f.userRoot();
+    }
 
-	public void testSystemRoot() {
-		f.systemRoot();
-	}
+    public void testSystemRoot() {
+        f.systemRoot();
+    }
 
-	public static class PreferencesFactoryImpl implements PreferencesFactory {
+    public static class PreferencesFactoryImpl implements PreferencesFactory {
 
-		public Preferences userRoot() {
-			return null;
-		}
+        public Preferences userRoot() {
+            return null;
+        }
 
-		public Preferences systemRoot() {
-			return null;
-		}
+        public Preferences systemRoot() {
+            return null;
+        }
 
-	}
+    }
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesTest.java?rev=730659&r1=730658&r2=730659&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesTest.java Thu Jan  1 18:52:34 2009
@@ -35,48 +35,48 @@
  */
 public class PreferencesTest extends TestCase {
 
-	MockSecurityManager manager = new MockSecurityManager();
+    MockSecurityManager manager = new MockSecurityManager();
 
-	MockInputStream stream = null;
+    MockInputStream stream = null;
 
-	InputStream in;
+    InputStream in;
 
-	/*
-	 * @see TestCase#setUp()
-	 */
-	@Override
+    /*
+     * @see TestCase#setUp()
+     */
+    @Override
     protected void setUp() throws Exception {
-		super.setUp();
-		in = new ByteArrayInputStream("<!DOCTYPE preferences SYSTEM \"http://java.sun.com/dtd/preferences.dtd\"><preferences><root type=\"user\"><map></map></root></preferences>".getBytes("UTF-8"));
-		stream = new MockInputStream(in);
-	}
-
-	/*
-	 * @see TestCase#tearDown()
-	 */
-	@Override
+        super.setUp();
+        in = new ByteArrayInputStream("<!DOCTYPE preferences SYSTEM \"http://java.sun.com/dtd/preferences.dtd\"><preferences><root type=\"user\"><map></map></root></preferences>".getBytes("UTF-8"));
+        stream = new MockInputStream(in);
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    @Override
     protected void tearDown() throws Exception {
-		super.tearDown();
-		stream.close();
-	}
+        super.tearDown();
+        stream.close();
+    }
 
-	public void testSystemNodeForPackage() throws BackingStoreException {
-		Preferences p = null;
+    public void testSystemNodeForPackage() throws BackingStoreException {
+        Preferences p = null;
         try {
             p = Preferences.systemNodeForPackage(Object.class);
         } catch (SecurityException e) {
             // may be caused by absence of privileges on the underlying OS 
             return;
         }
-		assertEquals("/java/lang", p.absolutePath());
-		assertTrue(p instanceof AbstractPreferences);
-		Preferences root = Preferences.systemRoot();
-		Preferences parent = root.node("java");
-		assertSame(parent, p.parent());
-		assertFalse(p.isUserNode());
-		assertEquals("lang", p.name());
-		assertEquals("System Preference Node: " + p.absolutePath(), p
-				.toString());
+        assertEquals("/java/lang", p.absolutePath());
+        assertTrue(p instanceof AbstractPreferences);
+        Preferences root = Preferences.systemRoot();
+        Preferences parent = root.node("java");
+        assertSame(parent, p.parent());
+        assertFalse(p.isUserNode());
+        assertEquals("lang", p.name());
+        assertEquals("System Preference Node: " + p.absolutePath(), p
+                .toString());
         try {
             assertEquals(0, p.childrenNames().length);
         } catch (BackingStoreException e) {
@@ -98,469 +98,469 @@
         } catch (NullPointerException e) {
             // expected
         }
-	}
+    }
 
-	public void testSystemRoot() throws BackingStoreException {
-		Preferences p = Preferences.systemRoot();
-		assertTrue(p instanceof AbstractPreferences);
-		assertEquals("/", p.absolutePath());
-		assertSame(null, p.parent());
-		assertFalse(p.isUserNode());
-		assertEquals("", p.name());
-		assertEquals("System Preference Node: " + p.absolutePath(), p
-				.toString());
-		// assertEquals(0, p.childrenNames().length);
-		// assertEquals(0, p.keys().length);
-	}
-
-	public void testConsts() {
-		assertEquals(80, Preferences.MAX_KEY_LENGTH);
-		assertEquals(80, Preferences.MAX_NAME_LENGTH);
-		assertEquals(8192, Preferences.MAX_VALUE_LENGTH);
-	}
-
-	public void testUserNodeForPackage() throws BackingStoreException {
-		Preferences p = Preferences.userNodeForPackage(Object.class);
-		assertEquals("/java/lang", p.absolutePath());
-		assertTrue(p instanceof AbstractPreferences);
-		Preferences root = Preferences.userRoot();
-		Preferences parent = root.node("java");
-		assertSame(parent, p.parent());
-		assertTrue(p.isUserNode());
-		assertEquals("lang", p.name());
-		assertEquals("User Preference Node: " + p.absolutePath(), p.toString());
-		assertEquals(0, p.childrenNames().length);
-		assertEquals(0, p.keys().length);
-
-		try {
-			p = Preferences.userNodeForPackage(null);
-			fail();
-		} catch (NullPointerException e) {
-		}
-	}
-
-	public void testUserRoot() throws BackingStoreException {
-		Preferences p = Preferences.userRoot();
-		assertTrue(p instanceof AbstractPreferences);
-		assertEquals("/", p.absolutePath());
-		assertSame(null, p.parent());
-		assertTrue(p.isUserNode());
-		assertEquals("", p.name());
-		assertEquals("User Preference Node: " + p.absolutePath(), p.toString());
-		// assertEquals(0, p.childrenNames().length);
-		// assertEquals(p.keys().length, 0);
-	}
-
-	public void testImportPreferences() throws Exception {
-		Preferences prefs = null;
-		try {
-			prefs = Preferences.userNodeForPackage(PreferencesTest.class);
-			// assertEquals(0, prefs.childrenNames().length);
-			// assertFalse(prefs.nodeExists("mock/child/grandson"));
-
-			prefs.put("prefskey", "oldvalue");
-			prefs.put("prefskey2", "oldvalue2");
-			in = PreferencesTest.class.getResourceAsStream("/prefs/java/util/prefs/userprefs.xml");
-			Preferences.importPreferences(in);
-
-			prefs = Preferences.userNodeForPackage(PreferencesTest.class);
-			assertEquals(1, prefs.childrenNames().length);
-			assertTrue(prefs.nodeExists("mock/child/grandson"));
-			assertEquals("newvalue", prefs.get("prefskey", null));
-			assertEquals("oldvalue2", prefs.get("prefskey2", null));
-			assertEquals("newvalue3", prefs.get("prefskey3", null));
-
-			in = PreferencesTest.class
-					.getResourceAsStream("/prefs/java/util/prefs/userprefs-badform.xml");
-			try {
-				Preferences.importPreferences(in);
-				fail();
-			} catch (InvalidPreferencesFormatException e) {
-			}
-
-			in = PreferencesTest.class
-					.getResourceAsStream("/prefs/java/util/prefs/userprefs-badtype.xml");
-			try {
-				Preferences.importPreferences(in);
-				fail();
-			} catch (InvalidPreferencesFormatException e) {
-			}
-
-			in = PreferencesTest.class
-					.getResourceAsStream("/prefs/java/util/prefs/userprefs-badencoding.xml");
-			try {
-				Preferences.importPreferences(in);
-				fail();
-			} catch (InvalidPreferencesFormatException e) {
-			}
-
-			in = PreferencesTest.class
-					.getResourceAsStream("/prefs/java/util/prefs/userprefs-higherversion.xml");
-			try {
-				Preferences.importPreferences(in);
-				fail();
-			} catch (InvalidPreferencesFormatException e) {
-			}
-
-			in = PreferencesTest.class
-					.getResourceAsStream("/prefs/java/util/prefs/userprefs-ascii.xml");
-			Preferences.importPreferences(in);
-			prefs = Preferences.userNodeForPackage(PreferencesTest.class);
-		} finally {
-			try {
-				prefs = Preferences.userRoot().node("tests");
-				prefs.removeNode();
-			} catch (Exception e) {
-			}
-		}
-	}
-
-	public void testImportPreferencesException() throws Exception {
-		try {
-			Preferences.importPreferences(null);
-			fail();
-		} catch (MalformedURLException e) {
-		}
-
-		byte[] source = new byte[0];
-		InputStream in = new ByteArrayInputStream(source);
-		try {
-			Preferences.importPreferences(in);
-			fail();
-		} catch (InvalidPreferencesFormatException e) {
-		}
-
-		stream.setResult(MockInputStream.exception);
-		try {
-			Preferences.importPreferences(stream);
-			fail();
-		} catch (IOException e) {
-		}
-
-		stream.setResult(MockInputStream.runtimeException);
-		try {
-			Preferences.importPreferences(stream);
-			fail();
-		} catch (RuntimeException e) {
-		}
-	}
-
-	public void testSecurity() throws InvalidPreferencesFormatException,
-			IOException {
-		try {
-			manager.install();
-			try {
-				Preferences.userRoot();
-				fail();
-			} catch (SecurityException e) {
-			}
-			try {
-				Preferences.systemRoot();
-				fail();
-			} catch (SecurityException e) {
-			}
-			try {
-				Preferences.userNodeForPackage(null);
-				fail();
-			} catch (SecurityException e) {
-			}
-
-			try {
-				Preferences.systemNodeForPackage(null);
-				fail();
-			} catch (SecurityException e) {
-			}
-
-			try {
-				Preferences.importPreferences(stream);
-				fail();
-			} catch (SecurityException e) {
-			}
-		} finally {
-			manager.restoreDefault();
-		}
-	}
-
-	public void testAbstractMethods() {
-		Preferences p = new MockPreferences();
-		p.absolutePath();
-		try {
-			p.childrenNames();
-		} catch (BackingStoreException e4) {
-		}
-		try {
-			p.clear();
-		} catch (BackingStoreException e5) {
-		}
-		try {
-			p.exportNode(null);
-		} catch (IOException e6) {
-		} catch (BackingStoreException e6) {
-		}
-		try {
-			p.exportSubtree(null);
-		} catch (IOException e7) {
-		} catch (BackingStoreException e7) {
-		}
-		try {
-			p.flush();
-		} catch (BackingStoreException e8) {
-		}
-		p.get(null, null);
-		p.getBoolean(null, false);
-		p.getByteArray(null, null);
-		p.getFloat(null, 0.1f);
-		p.getDouble(null, 0.1);
-		p.getInt(null, 1);
-		p.getLong(null, 1l);
-		p.isUserNode();
-		try {
-			p.keys();
-		} catch (BackingStoreException e) {
-		}
-		p.name();
-		p.node(null);
-		try {
-			p.nodeExists(null);
-		} catch (BackingStoreException e1) {
-		}
-		p.parent();
-		p.put(null, null);
-		p.putBoolean(null, false);
-		p.putByteArray(null, null);
-		p.putDouble(null, 1);
-		p.putFloat(null, 1f);
-		p.putInt(null, 1);
-		p.putLong(null, 1l);
-		p.remove(null);
-		try {
-			p.removeNode();
-		} catch (BackingStoreException e2) {
-		}
-		p.addNodeChangeListener(null);
-		p.addPreferenceChangeListener(null);
-		p.removeNodeChangeListener(null);
-		p.removePreferenceChangeListener(null);
-		try {
-			p.sync();
-		} catch (BackingStoreException e3) {
-		}
-		p.toString();
-	}
-
-	static class MockInputStream extends InputStream {
-
-		static final int normal = 0;
-
-		static final int exception = 1;
-
-		static final int runtimeException = 2;
-
-		int result = normal;
-
-		InputStream wrapper;
-
-		public void setResult(int i) {
-			result = i;
-		}
-
-		private void checkException() throws IOException {
-			switch (result) {
-			case normal:
-				return;
-			case exception:
-				throw new IOException("test");
-			case runtimeException:
-				throw new RuntimeException("test");
-			}
-		}
-
-		public MockInputStream(InputStream in) {
-			wrapper = in;
-		}
+    public void testSystemRoot() throws BackingStoreException {
+        Preferences p = Preferences.systemRoot();
+        assertTrue(p instanceof AbstractPreferences);
+        assertEquals("/", p.absolutePath());
+        assertSame(null, p.parent());
+        assertFalse(p.isUserNode());
+        assertEquals("", p.name());
+        assertEquals("System Preference Node: " + p.absolutePath(), p
+                .toString());
+        // assertEquals(0, p.childrenNames().length);
+        // assertEquals(0, p.keys().length);
+    }
+
+    public void testConsts() {
+        assertEquals(80, Preferences.MAX_KEY_LENGTH);
+        assertEquals(80, Preferences.MAX_NAME_LENGTH);
+        assertEquals(8192, Preferences.MAX_VALUE_LENGTH);
+    }
+
+    public void testUserNodeForPackage() throws BackingStoreException {
+        Preferences p = Preferences.userNodeForPackage(Object.class);
+        assertEquals("/java/lang", p.absolutePath());
+        assertTrue(p instanceof AbstractPreferences);
+        Preferences root = Preferences.userRoot();
+        Preferences parent = root.node("java");
+        assertSame(parent, p.parent());
+        assertTrue(p.isUserNode());
+        assertEquals("lang", p.name());
+        assertEquals("User Preference Node: " + p.absolutePath(), p.toString());
+        assertEquals(0, p.childrenNames().length);
+        assertEquals(0, p.keys().length);
 
-		@Override
+        try {
+            p = Preferences.userNodeForPackage(null);
+            fail();
+        } catch (NullPointerException e) {
+        }
+    }
+
+    public void testUserRoot() throws BackingStoreException {
+        Preferences p = Preferences.userRoot();
+        assertTrue(p instanceof AbstractPreferences);
+        assertEquals("/", p.absolutePath());
+        assertSame(null, p.parent());
+        assertTrue(p.isUserNode());
+        assertEquals("", p.name());
+        assertEquals("User Preference Node: " + p.absolutePath(), p.toString());
+        // assertEquals(0, p.childrenNames().length);
+        // assertEquals(p.keys().length, 0);
+    }
+
+    public void testImportPreferences() throws Exception {
+        Preferences prefs = null;
+        try {
+            prefs = Preferences.userNodeForPackage(PreferencesTest.class);
+            // assertEquals(0, prefs.childrenNames().length);
+            // assertFalse(prefs.nodeExists("mock/child/grandson"));
+
+            prefs.put("prefskey", "oldvalue");
+            prefs.put("prefskey2", "oldvalue2");
+            in = PreferencesTest.class.getResourceAsStream("/prefs/java/util/prefs/userprefs.xml");
+            Preferences.importPreferences(in);
+
+            prefs = Preferences.userNodeForPackage(PreferencesTest.class);
+            assertEquals(1, prefs.childrenNames().length);
+            assertTrue(prefs.nodeExists("mock/child/grandson"));
+            assertEquals("newvalue", prefs.get("prefskey", null));
+            assertEquals("oldvalue2", prefs.get("prefskey2", null));
+            assertEquals("newvalue3", prefs.get("prefskey3", null));
+
+            in = PreferencesTest.class
+            .getResourceAsStream("/prefs/java/util/prefs/userprefs-badform.xml");
+            try {
+                Preferences.importPreferences(in);
+                fail();
+            } catch (InvalidPreferencesFormatException e) {
+            }
+
+            in = PreferencesTest.class
+            .getResourceAsStream("/prefs/java/util/prefs/userprefs-badtype.xml");
+            try {
+                Preferences.importPreferences(in);
+                fail();
+            } catch (InvalidPreferencesFormatException e) {
+            }
+
+            in = PreferencesTest.class
+            .getResourceAsStream("/prefs/java/util/prefs/userprefs-badencoding.xml");
+            try {
+                Preferences.importPreferences(in);
+                fail();
+            } catch (InvalidPreferencesFormatException e) {
+            }
+
+            in = PreferencesTest.class
+            .getResourceAsStream("/prefs/java/util/prefs/userprefs-higherversion.xml");
+            try {
+                Preferences.importPreferences(in);
+                fail();
+            } catch (InvalidPreferencesFormatException e) {
+            }
+
+            in = PreferencesTest.class
+            .getResourceAsStream("/prefs/java/util/prefs/userprefs-ascii.xml");
+            Preferences.importPreferences(in);
+            prefs = Preferences.userNodeForPackage(PreferencesTest.class);
+        } finally {
+            try {
+                prefs = Preferences.userRoot().node("tests");
+                prefs.removeNode();
+            } catch (Exception e) {
+            }
+        }
+    }
+
+    public void testImportPreferencesException() throws Exception {
+        try {
+            Preferences.importPreferences(null);
+            fail();
+        } catch (MalformedURLException e) {
+        }
+
+        byte[] source = new byte[0];
+        InputStream in = new ByteArrayInputStream(source);
+        try {
+            Preferences.importPreferences(in);
+            fail();
+        } catch (InvalidPreferencesFormatException e) {
+        }
+
+        stream.setResult(MockInputStream.exception);
+        try {
+            Preferences.importPreferences(stream);
+            fail();
+        } catch (IOException e) {
+        }
+
+        stream.setResult(MockInputStream.runtimeException);
+        try {
+            Preferences.importPreferences(stream);
+            fail();
+        } catch (RuntimeException e) {
+        }
+    }
+
+    public void testSecurity() throws InvalidPreferencesFormatException,
+    IOException {
+        try {
+            manager.install();
+            try {
+                Preferences.userRoot();
+                fail();
+            } catch (SecurityException e) {
+            }
+            try {
+                Preferences.systemRoot();
+                fail();
+            } catch (SecurityException e) {
+            }
+            try {
+                Preferences.userNodeForPackage(null);
+                fail();
+            } catch (SecurityException e) {
+            }
+
+            try {
+                Preferences.systemNodeForPackage(null);
+                fail();
+            } catch (SecurityException e) {
+            }
+
+            try {
+                Preferences.importPreferences(stream);
+                fail();
+            } catch (SecurityException e) {
+            }
+        } finally {
+            manager.restoreDefault();
+        }
+    }
+
+    public void testAbstractMethods() {
+        Preferences p = new MockPreferences();
+        p.absolutePath();
+        try {
+            p.childrenNames();
+        } catch (BackingStoreException e4) {
+        }
+        try {
+            p.clear();
+        } catch (BackingStoreException e5) {
+        }
+        try {
+            p.exportNode(null);
+        } catch (IOException e6) {
+        } catch (BackingStoreException e6) {
+        }
+        try {
+            p.exportSubtree(null);
+        } catch (IOException e7) {
+        } catch (BackingStoreException e7) {
+        }
+        try {
+            p.flush();
+        } catch (BackingStoreException e8) {
+        }
+        p.get(null, null);
+        p.getBoolean(null, false);
+        p.getByteArray(null, null);
+        p.getFloat(null, 0.1f);
+        p.getDouble(null, 0.1);
+        p.getInt(null, 1);
+        p.getLong(null, 1l);
+        p.isUserNode();
+        try {
+            p.keys();
+        } catch (BackingStoreException e) {
+        }
+        p.name();
+        p.node(null);
+        try {
+            p.nodeExists(null);
+        } catch (BackingStoreException e1) {
+        }
+        p.parent();
+        p.put(null, null);
+        p.putBoolean(null, false);
+        p.putByteArray(null, null);
+        p.putDouble(null, 1);
+        p.putFloat(null, 1f);
+        p.putInt(null, 1);
+        p.putLong(null, 1l);
+        p.remove(null);
+        try {
+            p.removeNode();
+        } catch (BackingStoreException e2) {
+        }
+        p.addNodeChangeListener(null);
+        p.addPreferenceChangeListener(null);
+        p.removeNodeChangeListener(null);
+        p.removePreferenceChangeListener(null);
+        try {
+            p.sync();
+        } catch (BackingStoreException e3) {
+        }
+        p.toString();
+    }
+
+    static class MockInputStream extends InputStream {
+
+        static final int normal = 0;
+
+        static final int exception = 1;
+
+        static final int runtimeException = 2;
+
+        int result = normal;
+
+        InputStream wrapper;
+
+        public void setResult(int i) {
+            result = i;
+        }
+
+        private void checkException() throws IOException {
+            switch (result) {
+            case normal:
+                return;
+            case exception:
+                throw new IOException("test");
+            case runtimeException:
+                throw new RuntimeException("test");
+            }
+        }
+
+        public MockInputStream(InputStream in) {
+            wrapper = in;
+        }
+
+        @Override
         public int read() throws IOException {
-			checkException();
-			return wrapper.read();
-		}
-	}
-
-	static class MockPreferences extends Preferences {
-
-		public MockPreferences() {
-			super();
-		}
+            checkException();
+            return wrapper.read();
+        }
+    }
+
+    static class MockPreferences extends Preferences {
+
+        public MockPreferences() {
+            super();
+        }
 
-		@Override
+        @Override
         public String absolutePath() {
-			return null;
-		}
+            return null;
+        }
 
-		@Override
+        @Override
         public String[] childrenNames() throws BackingStoreException {
-			return null;
-		}
+            return null;
+        }
 
-		@Override
+        @Override
         public void clear() throws BackingStoreException {
-		}
+        }
 
-		@Override
+        @Override
         public void exportNode(OutputStream ostream) throws IOException,
-				BackingStoreException {
-		}
+        BackingStoreException {
+        }
 
-		@Override
+        @Override
         public void exportSubtree(OutputStream ostream) throws IOException,
-				BackingStoreException {
-		}
+        BackingStoreException {
+        }
 
-		@Override
+        @Override
         public void flush() throws BackingStoreException {
-		}
+        }
 
-		@Override
+        @Override
         public String get(String key, String deflt) {
-			return null;
-		}
+            return null;
+        }
 
-		@Override
+        @Override
         public boolean getBoolean(String key, boolean deflt) {
-			return false;
-		}
+            return false;
+        }
 
-		@Override
+        @Override
         public byte[] getByteArray(String key, byte[] deflt) {
-			return null;
-		}
+            return null;
+        }
 
-		@Override
+        @Override
         public double getDouble(String key, double deflt) {
-			return 0;
-		}
+            return 0;
+        }
 
-		@Override
+        @Override
         public float getFloat(String key, float deflt) {
-			return 0;
-		}
+            return 0;
+        }
 
-		@Override
+        @Override
         public int getInt(String key, int deflt) {
-			return 0;
-		}
+            return 0;
+        }
 
-		@Override
+        @Override
         public long getLong(String key, long deflt) {
-			return 0;
-		}
+            return 0;
+        }
 
-		@Override
+        @Override
         public boolean isUserNode() {
-			return false;
-		}
+            return false;
+        }
 
-		@Override
+        @Override
         public String[] keys() throws BackingStoreException {
-			return null;
-		}
+            return null;
+        }
 
-		@Override
+        @Override
         public String name() {
-			return null;
-		}
+            return null;
+        }
 
-		@Override
+        @Override
         public Preferences node(String name) {
-			return null;
-		}
+            return null;
+        }
 
-		@Override
+        @Override
         public boolean nodeExists(String name) throws BackingStoreException {
-			return false;
-		}
+            return false;
+        }
 
-		@Override
+        @Override
         public Preferences parent() {
-			return null;
-		}
+            return null;
+        }
 
-		@Override
+        @Override
         public void put(String key, String value) {
 
-		}
+        }
 
-		@Override
+        @Override
         public void putBoolean(String key, boolean value) {
 
-		}
+        }
 
-		@Override
+        @Override
         public void putByteArray(String key, byte[] value) {
 
-		}
+        }
 
-		@Override
+        @Override
         public void putDouble(String key, double value) {
 
-		}
+        }
 
-		@Override
+        @Override
         public void putFloat(String key, float value) {
 
-		}
+        }
 
-		@Override
+        @Override
         public void putInt(String key, int value) {
 
-		}
+        }
 
-		@Override
+        @Override
         public void putLong(String key, long value) {
 
-		}
+        }
 
-		@Override
+        @Override
         public void remove(String key) {
 
-		}
+        }
 
-		@Override
+        @Override
         public void removeNode() throws BackingStoreException {
 
-		}
+        }
 
-		@Override
+        @Override
         public void addNodeChangeListener(NodeChangeListener ncl) {
 
-		}
+        }
 
-		@Override
+        @Override
         public void addPreferenceChangeListener(PreferenceChangeListener pcl) {
 
-		}
+        }
 
-		@Override
+        @Override
         public void removeNodeChangeListener(NodeChangeListener ncl) {
 
-		}
+        }
 
-		@Override
+        @Override
         public void removePreferenceChangeListener(PreferenceChangeListener pcl) {
 
-		}
+        }
 
-		@Override
+        @Override
         public void sync() throws BackingStoreException {
 
-		}
+        }
 
-		@Override
+        @Override
         public String toString() {
-			return null;
-		}
+            return null;
+        }
 
-	}
+    }
 
 }
 



Mime
View raw message