You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by sm...@apache.org on 2006/08/24 14:19:49 UTC
svn commit: r434381 [3/4] -
/incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/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/incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AllTests.java?rev=434381&r1=434380&r2=434381&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AllTests.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AllTests.java Thu Aug 24 05:19:47 2006
@@ -1,47 +1,47 @@
-/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.prefs.tests.java.util.prefs;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * Suite for package org.apache.harmony.prefs.tests.java.util.prefs
- *
- */
-public class AllTests {
-
- 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);
- suite.addTestSuite(FilePreferencesImplTest.class);
- // $JUnit-END$
- return suite;
- }
-}
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.prefs.tests.java.util.prefs;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Suite for package org.apache.harmony.prefs.tests.java.util.prefs
+ *
+ */
+public class AllTests {
+
+ 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);
+ suite.addTestSuite(FilePreferencesImplTest.class);
+ // $JUnit-END$
+ return suite;
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AllTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/BackingStoreExceptionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/BackingStoreExceptionTest.java?rev=434381&r1=434380&r2=434381&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/BackingStoreExceptionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/BackingStoreExceptionTest.java Thu Aug 24 05:19:47 2006
@@ -1,60 +1,60 @@
-/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.prefs.tests.java.util.prefs;
-
-import java.io.NotSerializableException;
-import java.util.prefs.BackingStoreException;
-
-import junit.framework.TestCase;
-import tests.util.SerializationTester;
-
-/**
- *
- *
- */
-public class BackingStoreExceptionTest extends TestCase {
-
- /*
- * Class under test for void BackingStoreException(String)
- */
- public void testBackingStoreExceptionString() {
- BackingStoreException e = new BackingStoreException("msg");
- assertNull(e.getCause());
- assertEquals("msg", e.getMessage());
- }
-
- /*
- * Class under test for void BackingStoreException(Throwable)
- */
- public void testBackingStoreExceptionThrowable() {
- Throwable t = new Throwable("msg");
- BackingStoreException e = new BackingStoreException(t);
- assertTrue(e.getMessage().indexOf(t.getClass().getName()) >= 0);
- assertTrue(e.getMessage().indexOf("msg") >= 0);
- assertEquals(t, e.getCause());
- }
-
- public void testSerialization() throws Exception {
- try {
- SerializationTester.writeObject(new BackingStoreException("msg"),
- "test.txt");
- fail();
- } catch (NotSerializableException e) {
- }
- }
-
-}
-
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.prefs.tests.java.util.prefs;
+
+import java.io.NotSerializableException;
+import java.util.prefs.BackingStoreException;
+
+import junit.framework.TestCase;
+import tests.util.SerializationTester;
+
+/**
+ *
+ *
+ */
+public class BackingStoreExceptionTest extends TestCase {
+
+ /*
+ * Class under test for void BackingStoreException(String)
+ */
+ public void testBackingStoreExceptionString() {
+ BackingStoreException e = new BackingStoreException("msg");
+ assertNull(e.getCause());
+ assertEquals("msg", e.getMessage());
+ }
+
+ /*
+ * Class under test for void BackingStoreException(Throwable)
+ */
+ public void testBackingStoreExceptionThrowable() {
+ Throwable t = new Throwable("msg");
+ BackingStoreException e = new BackingStoreException(t);
+ assertTrue(e.getMessage().indexOf(t.getClass().getName()) >= 0);
+ assertTrue(e.getMessage().indexOf("msg") >= 0);
+ assertEquals(t, e.getCause());
+ }
+
+ public void testSerialization() throws Exception {
+ try {
+ SerializationTester.writeObject(new BackingStoreException("msg"),
+ "test.txt");
+ fail();
+ } catch (NotSerializableException e) {
+ }
+ }
+
+}
+
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/BackingStoreExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/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/incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/FilePreferencesImplTest.java?rev=434381&r1=434380&r2=434381&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/FilePreferencesImplTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/FilePreferencesImplTest.java Thu Aug 24 05:19:47 2006
@@ -1,225 +1,225 @@
-/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.prefs.tests.java.util.prefs;
-
-import java.io.FilePermission;
-import java.io.IOException;
-import java.security.Permission;
-import java.util.prefs.BackingStoreException;
-import java.util.prefs.Preferences;
-
-import junit.framework.TestCase;
-
-public class FilePreferencesImplTest extends TestCase {
-
- private String prevFactory;
- private Preferences uroot;
- private Preferences sroot;
-
- public FilePreferencesImplTest() {
- super();
- }
-
- 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();
- }
-
- 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");
- 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);
- }
-
- public void checkPermission(Permission perm) {
- if (perm instanceof FilePermission) {
- throw new SecurityException();
- } else if (dflt != null) {
- dflt.checkPermission(perm);
- }
- }
-
- 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);
- }
- }
-
- }
-}
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.prefs.tests.java.util.prefs;
+
+import java.io.FilePermission;
+import java.io.IOException;
+import java.security.Permission;
+import java.util.prefs.BackingStoreException;
+import java.util.prefs.Preferences;
+
+import junit.framework.TestCase;
+
+public class FilePreferencesImplTest extends TestCase {
+
+ private String prevFactory;
+ private Preferences uroot;
+ private Preferences sroot;
+
+ public FilePreferencesImplTest() {
+ super();
+ }
+
+ 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();
+ }
+
+ 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");
+ 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);
+ }
+
+ public void checkPermission(Permission perm) {
+ if (perm instanceof FilePermission) {
+ throw new SecurityException();
+ } else if (dflt != null) {
+ dflt.checkPermission(perm);
+ }
+ }
+
+ 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);
+ }
+ }
+
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/FilePreferencesImplTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/InvalidPreferencesFormatExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/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/incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockAbstractPreferences.java?rev=434381&r1=434380&r2=434381&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockAbstractPreferences.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockAbstractPreferences.java Thu Aug 24 05:19:47 2006
@@ -1,244 +1,244 @@
-/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.prefs.tests.java.util.prefs;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.prefs.AbstractPreferences;
-import java.util.prefs.BackingStoreException;
-
-public class MockAbstractPreferences extends AbstractPreferences {
- static final int NORMAL = 0;
-
- static final int backingException = 1;
-
- static final int runtimeException = 2;
-
- static final int returnNull = 3;
-
- int result = NORMAL;
-
- Properties attr = new Properties();
-
- Map<String, MockAbstractPreferences> childs = new HashMap<String, MockAbstractPreferences>();
-
- private int flushedTimes;
-
- private int syncTimes;
-
- 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);
- }
- }
-
- public int getFlushedTimes() {
- return flushedTimes;
- }
-
- public void resetFlushedTimes() {
- flushedTimes = 0;
- }
-
- public int getSyncTimes() {
- return syncTimes;
- }
-
- public void resetSyncTimes() {
- syncTimes = 0;
- }
-
- private void addChild(MockAbstractPreferences c) {
- childs.put(c.name(), c);
- }
-
- public void setResult(int r) {
- result = r;
- }
-
- public Object lock() {
- return lock;
- }
-
- 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);
- }
-
- 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;
- }
-
- protected void flushSpi() throws BackingStoreException {
- checkException();
- flushedTimes++;
- }
-
- protected String getSpi(String key) {
- try {
- checkException();
- } catch (BackingStoreException e) {
- }
- if (null == key) {
- return null;
- }
- return result == returnNull ? null : attr.getProperty(key);
- }
-
- 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;
- }
-
- protected void putSpi(String name, String value) {
- try {
- checkException();
- } catch (BackingStoreException e) {
- }
- if (name == null || value == null) {
- return;
- }
- attr.put(name, value);
- }
-
- protected void removeNodeSpi() throws BackingStoreException {
- checkException();
- ((MockAbstractPreferences) parent()).childs.remove(name());
- }
-
- protected void removeSpi(String key) {
- try {
- checkException();
- } catch (BackingStoreException e) {
- }
- if (null == key) {
- return;
- }
- attr.remove(key);
- }
-
- 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();
- }
-
-}
-
-class MockRuntimeException extends RuntimeException {
-
- private static final long serialVersionUID = 1L;
-
- public MockRuntimeException(String s) {
- super(s);
- }
-
- public MockRuntimeException() {
- super();
- }
-}
-
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.prefs.tests.java.util.prefs;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.prefs.AbstractPreferences;
+import java.util.prefs.BackingStoreException;
+
+public class MockAbstractPreferences extends AbstractPreferences {
+ static final int NORMAL = 0;
+
+ static final int backingException = 1;
+
+ static final int runtimeException = 2;
+
+ static final int returnNull = 3;
+
+ int result = NORMAL;
+
+ Properties attr = new Properties();
+
+ Map<String, MockAbstractPreferences> childs = new HashMap<String, MockAbstractPreferences>();
+
+ private int flushedTimes;
+
+ private int syncTimes;
+
+ 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);
+ }
+ }
+
+ public int getFlushedTimes() {
+ return flushedTimes;
+ }
+
+ public void resetFlushedTimes() {
+ flushedTimes = 0;
+ }
+
+ public int getSyncTimes() {
+ return syncTimes;
+ }
+
+ public void resetSyncTimes() {
+ syncTimes = 0;
+ }
+
+ private void addChild(MockAbstractPreferences c) {
+ childs.put(c.name(), c);
+ }
+
+ public void setResult(int r) {
+ result = r;
+ }
+
+ public Object lock() {
+ return lock;
+ }
+
+ 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);
+ }
+
+ 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;
+ }
+
+ protected void flushSpi() throws BackingStoreException {
+ checkException();
+ flushedTimes++;
+ }
+
+ protected String getSpi(String key) {
+ try {
+ checkException();
+ } catch (BackingStoreException e) {
+ }
+ if (null == key) {
+ return null;
+ }
+ return result == returnNull ? null : attr.getProperty(key);
+ }
+
+ 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;
+ }
+
+ protected void putSpi(String name, String value) {
+ try {
+ checkException();
+ } catch (BackingStoreException e) {
+ }
+ if (name == null || value == null) {
+ return;
+ }
+ attr.put(name, value);
+ }
+
+ protected void removeNodeSpi() throws BackingStoreException {
+ checkException();
+ ((MockAbstractPreferences) parent()).childs.remove(name());
+ }
+
+ protected void removeSpi(String key) {
+ try {
+ checkException();
+ } catch (BackingStoreException e) {
+ }
+ if (null == key) {
+ return;
+ }
+ attr.remove(key);
+ }
+
+ 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();
+ }
+
+}
+
+class MockRuntimeException extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public MockRuntimeException(String s) {
+ super(s);
+ }
+
+ public MockRuntimeException() {
+ super();
+ }
+}
+
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockAbstractPreferences.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/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/incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockPreferencesFactory.java?rev=434381&r1=434380&r2=434381&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockPreferencesFactory.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockPreferencesFactory.java Thu Aug 24 05:19:47 2006
@@ -1,41 +1,41 @@
-/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.prefs.tests.java.util.prefs;
-
-import java.util.prefs.Preferences;
-import java.util.prefs.PreferencesFactory;
-
-/**
- *
- */
-public class MockPreferencesFactory implements PreferencesFactory {
- static MockAbstractPreferences userRoot = new MockAbstractPreferences(null,
- "");
-
- static MockAbstractPreferences systemRoot = new MockAbstractPreferences(
- null, "");
-
- public MockPreferencesFactory() {
- }
-
- public Preferences userRoot() {
- return userRoot;
- }
-
- public Preferences systemRoot() {
- return systemRoot;
- }
-}
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.prefs.tests.java.util.prefs;
+
+import java.util.prefs.Preferences;
+import java.util.prefs.PreferencesFactory;
+
+/**
+ *
+ */
+public class MockPreferencesFactory implements PreferencesFactory {
+ static MockAbstractPreferences userRoot = new MockAbstractPreferences(null,
+ "");
+
+ static MockAbstractPreferences systemRoot = new MockAbstractPreferences(
+ null, "");
+
+ public MockPreferencesFactory() {
+ }
+
+ public Preferences userRoot() {
+ return userRoot;
+ }
+
+ public Preferences systemRoot() {
+ return systemRoot;
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockPreferencesFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/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/incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockSecurityManager.java?rev=434381&r1=434380&r2=434381&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockSecurityManager.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockSecurityManager.java Thu Aug 24 05:19:47 2006
@@ -1,59 +1,59 @@
-/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.prefs.tests.java.util.prefs;
-
-import java.security.Permission;
-
-/**
- * utility class for java.util.prefs test
- *
- */
-class MockSecurityManager extends SecurityManager {
-
- SecurityManager dflt;
-
- public MockSecurityManager() {
- super();
- dflt = System.getSecurityManager();
- }
-
- public void install() {
- System.setSecurityManager(this);
- }
-
- public void restoreDefault() {
- System.setSecurityManager(dflt);
- }
-
- public void checkPermission(Permission perm) {
- if (perm instanceof RuntimePermission
- && perm.getName().equals("preferences")) {
- throw new SecurityException();
- } else if (dflt != null) {
- dflt.checkPermission(perm);
- }
- }
-
- 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);
- }
- }
-
-}
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.prefs.tests.java.util.prefs;
+
+import java.security.Permission;
+
+/**
+ * utility class for java.util.prefs test
+ *
+ */
+class MockSecurityManager extends SecurityManager {
+
+ SecurityManager dflt;
+
+ public MockSecurityManager() {
+ super();
+ dflt = System.getSecurityManager();
+ }
+
+ public void install() {
+ System.setSecurityManager(this);
+ }
+
+ public void restoreDefault() {
+ System.setSecurityManager(dflt);
+ }
+
+ public void checkPermission(Permission perm) {
+ if (perm instanceof RuntimePermission
+ && perm.getName().equals("preferences")) {
+ throw new SecurityException();
+ } else if (dflt != null) {
+ dflt.checkPermission(perm);
+ }
+ }
+
+ 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);
+ }
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockSecurityManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/NodeChangeEventTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/NodeChangeEventTest.java?rev=434381&r1=434380&r2=434381&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/NodeChangeEventTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/NodeChangeEventTest.java Thu Aug 24 05:19:47 2006
@@ -1,62 +1,62 @@
-/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.prefs.tests.java.util.prefs;
-
-import java.io.NotSerializableException;
-import java.util.prefs.NodeChangeEvent;
-import java.util.prefs.Preferences;
-
-import junit.framework.TestCase;
-import tests.util.SerializationTester;
-
-/**
- *
- */
-public class NodeChangeEventTest extends TestCase {
-
- NodeChangeEvent event;
-
- public void testConstructor() {
- event = new NodeChangeEvent(Preferences.systemRoot(), Preferences
- .userRoot());
- assertSame(Preferences.systemRoot(), event.getParent());
- assertSame(Preferences.userRoot(), event.getChild());
- assertSame(Preferences.systemRoot(), event.getSource());
- }
-
- public void testConstructorNullParam() {
- try {
- event = new NodeChangeEvent(null, Preferences.userRoot());
- fail();
- } catch (IllegalArgumentException e) {
- }
-
- event = new NodeChangeEvent(Preferences.systemRoot(), null);
- assertSame(Preferences.systemRoot(), event.getParent());
- assertNull(event.getChild());
- assertSame(Preferences.systemRoot(), event.getSource());
- }
-
- public void testSerialization() throws Exception {
- try {
- SerializationTester.writeObject(new NodeChangeEvent(Preferences
- .systemRoot(), null), "test.txt");
- fail();
- } catch (NotSerializableException e) {
- }
- }
-
-}
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.prefs.tests.java.util.prefs;
+
+import java.io.NotSerializableException;
+import java.util.prefs.NodeChangeEvent;
+import java.util.prefs.Preferences;
+
+import junit.framework.TestCase;
+import tests.util.SerializationTester;
+
+/**
+ *
+ */
+public class NodeChangeEventTest extends TestCase {
+
+ NodeChangeEvent event;
+
+ public void testConstructor() {
+ event = new NodeChangeEvent(Preferences.systemRoot(), Preferences
+ .userRoot());
+ assertSame(Preferences.systemRoot(), event.getParent());
+ assertSame(Preferences.userRoot(), event.getChild());
+ assertSame(Preferences.systemRoot(), event.getSource());
+ }
+
+ public void testConstructorNullParam() {
+ try {
+ event = new NodeChangeEvent(null, Preferences.userRoot());
+ fail();
+ } catch (IllegalArgumentException e) {
+ }
+
+ event = new NodeChangeEvent(Preferences.systemRoot(), null);
+ assertSame(Preferences.systemRoot(), event.getParent());
+ assertNull(event.getChild());
+ assertSame(Preferences.systemRoot(), event.getSource());
+ }
+
+ public void testSerialization() throws Exception {
+ try {
+ SerializationTester.writeObject(new NodeChangeEvent(Preferences
+ .systemRoot(), null), "test.txt");
+ fail();
+ } catch (NotSerializableException e) {
+ }
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/NodeChangeEventTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/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/incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/NodeChangeListenerTest.java?rev=434381&r1=434380&r2=434381&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/NodeChangeListenerTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/NodeChangeListenerTest.java Thu Aug 24 05:19:47 2006
@@ -1,66 +1,66 @@
-/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.prefs.tests.java.util.prefs;
-
-import java.util.prefs.NodeChangeEvent;
-import java.util.prefs.NodeChangeListener;
-import java.util.prefs.Preferences;
-
-import junit.framework.TestCase;
-
-/**
- *
- */
-public class NodeChangeListenerTest extends TestCase {
-
- NodeChangeListener l;
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- l = new NodeChangeListenerImpl();
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testChildAdded() {
- l.childAdded(new NodeChangeEvent(Preferences.userRoot(), Preferences
- .userRoot()));
- }
-
- public void testChildRemoved() {
- l.childRemoved(new NodeChangeEvent(Preferences.userRoot(), Preferences
- .userRoot()));
- }
-
- public static class NodeChangeListenerImpl implements NodeChangeListener {
-
- public void childAdded(NodeChangeEvent e) {
- }
-
- public void childRemoved(NodeChangeEvent e) {
- }
-
- }
-
-}
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.prefs.tests.java.util.prefs;
+
+import java.util.prefs.NodeChangeEvent;
+import java.util.prefs.NodeChangeListener;
+import java.util.prefs.Preferences;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ */
+public class NodeChangeListenerTest extends TestCase {
+
+ NodeChangeListener l;
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ l = new NodeChangeListenerImpl();
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testChildAdded() {
+ l.childAdded(new NodeChangeEvent(Preferences.userRoot(), Preferences
+ .userRoot()));
+ }
+
+ public void testChildRemoved() {
+ l.childRemoved(new NodeChangeEvent(Preferences.userRoot(), Preferences
+ .userRoot()));
+ }
+
+ public static class NodeChangeListenerImpl implements NodeChangeListener {
+
+ public void childAdded(NodeChangeEvent e) {
+ }
+
+ public void childRemoved(NodeChangeEvent e) {
+ }
+
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/NodeChangeListenerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/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/incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferenceChangeEventTest.java?rev=434381&r1=434380&r2=434381&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferenceChangeEventTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferenceChangeEventTest.java Thu Aug 24 05:19:47 2006
@@ -1,87 +1,87 @@
-/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.prefs.tests.java.util.prefs;
-
-import java.io.NotSerializableException;
-import java.util.prefs.PreferenceChangeEvent;
-import java.util.prefs.Preferences;
-
-import tests.util.SerializationTester;
-
-import junit.framework.TestCase;
-
-/**
- *
- */
-public class PreferenceChangeEventTest extends TestCase {
-
- PreferenceChangeEvent event;
-
- public void testPreferenceChangeEventException() {
- try {
- event = new PreferenceChangeEvent(null, "key", "value");
- fail();
- } catch (IllegalArgumentException e) {
- }
- }
-
- public void testConstructorNullValue() {
- event = new PreferenceChangeEvent(Preferences.userRoot(), "key", null);
- assertEquals("key", event.getKey());
- assertNull(event.getNewValue());
- assertSame(Preferences.userRoot(), event.getNode());
- assertSame(Preferences.userRoot(), event.getSource());
-
- event = new PreferenceChangeEvent(Preferences.userRoot(), "", null);
- assertEquals("", event.getKey());
- assertNull(event.getNewValue());
- assertSame(Preferences.userRoot(), event.getNode());
- assertSame(Preferences.userRoot(), event.getSource());
-
- event = new PreferenceChangeEvent(Preferences.userRoot(), null, "value");
- assertNull(event.getKey());
- assertEquals("value", event.getNewValue());
- assertSame(Preferences.userRoot(), event.getNode());
- assertSame(Preferences.userRoot(), event.getSource());
-
- event = new PreferenceChangeEvent(Preferences.userRoot(), null, "");
- assertNull(event.getKey());
- assertEquals("", event.getNewValue());
- assertSame(Preferences.userRoot(), event.getNode());
- assertSame(Preferences.userRoot(), event.getSource());
- }
-
- public void testConstructor() {
- event = new PreferenceChangeEvent(Preferences.userRoot(), "key",
- "value");
- assertEquals("key", event.getKey());
- assertEquals("value", event.getNewValue());
- assertSame(Preferences.userRoot(), event.getNode());
- assertSame(Preferences.userRoot(), event.getSource());
- }
-
- public void testSerialization() throws Exception {
- event = new PreferenceChangeEvent(Preferences.userRoot(), "key",
- "value");
- try {
- SerializationTester.writeObject(event, "test.txt");
- fail();
- } catch (NotSerializableException e) {
- }
-
- }
-
-}
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.prefs.tests.java.util.prefs;
+
+import java.io.NotSerializableException;
+import java.util.prefs.PreferenceChangeEvent;
+import java.util.prefs.Preferences;
+
+import tests.util.SerializationTester;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ */
+public class PreferenceChangeEventTest extends TestCase {
+
+ PreferenceChangeEvent event;
+
+ public void testPreferenceChangeEventException() {
+ try {
+ event = new PreferenceChangeEvent(null, "key", "value");
+ fail();
+ } catch (IllegalArgumentException e) {
+ }
+ }
+
+ public void testConstructorNullValue() {
+ event = new PreferenceChangeEvent(Preferences.userRoot(), "key", null);
+ assertEquals("key", event.getKey());
+ assertNull(event.getNewValue());
+ assertSame(Preferences.userRoot(), event.getNode());
+ assertSame(Preferences.userRoot(), event.getSource());
+
+ event = new PreferenceChangeEvent(Preferences.userRoot(), "", null);
+ assertEquals("", event.getKey());
+ assertNull(event.getNewValue());
+ assertSame(Preferences.userRoot(), event.getNode());
+ assertSame(Preferences.userRoot(), event.getSource());
+
+ event = new PreferenceChangeEvent(Preferences.userRoot(), null, "value");
+ assertNull(event.getKey());
+ assertEquals("value", event.getNewValue());
+ assertSame(Preferences.userRoot(), event.getNode());
+ assertSame(Preferences.userRoot(), event.getSource());
+
+ event = new PreferenceChangeEvent(Preferences.userRoot(), null, "");
+ assertNull(event.getKey());
+ assertEquals("", event.getNewValue());
+ assertSame(Preferences.userRoot(), event.getNode());
+ assertSame(Preferences.userRoot(), event.getSource());
+ }
+
+ public void testConstructor() {
+ event = new PreferenceChangeEvent(Preferences.userRoot(), "key",
+ "value");
+ assertEquals("key", event.getKey());
+ assertEquals("value", event.getNewValue());
+ assertSame(Preferences.userRoot(), event.getNode());
+ assertSame(Preferences.userRoot(), event.getSource());
+ }
+
+ public void testSerialization() throws Exception {
+ event = new PreferenceChangeEvent(Preferences.userRoot(), "key",
+ "value");
+ try {
+ SerializationTester.writeObject(event, "test.txt");
+ fail();
+ } catch (NotSerializableException e) {
+ }
+
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferenceChangeEventTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/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/incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferenceChangeListenerTest.java?rev=434381&r1=434380&r2=434381&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferenceChangeListenerTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferenceChangeListenerTest.java Thu Aug 24 05:19:47 2006
@@ -1,51 +1,51 @@
-/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.prefs.tests.java.util.prefs;
-
-import java.util.prefs.PreferenceChangeEvent;
-import java.util.prefs.PreferenceChangeListener;
-import java.util.prefs.Preferences;
-
-import junit.framework.TestCase;
-
-/**
- *
- */
-public class PreferenceChangeListenerTest extends TestCase {
-
- PreferenceChangeListener l;
-
- /*
- * @see TestCase#setUp()
- */
- 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) {
- }
-
- }
-
-}
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.prefs.tests.java.util.prefs;
+
+import java.util.prefs.PreferenceChangeEvent;
+import java.util.prefs.PreferenceChangeListener;
+import java.util.prefs.Preferences;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ */
+public class PreferenceChangeListenerTest extends TestCase {
+
+ PreferenceChangeListener l;
+
+ /*
+ * @see TestCase#setUp()
+ */
+ 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) {
+ }
+
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferenceChangeListenerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/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/incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesFactoryTest.java?rev=434381&r1=434380&r2=434381&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesFactoryTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesFactoryTest.java Thu Aug 24 05:19:47 2006
@@ -1,58 +1,58 @@
-/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.prefs.tests.java.util.prefs;
-
-import java.util.prefs.Preferences;
-import java.util.prefs.PreferencesFactory;
-
-import junit.framework.TestCase;
-
-/**
- *
- */
-public class PreferencesFactoryTest extends TestCase {
-
- PreferencesFactory f;
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- f = new PreferencesFactoryImpl();
- }
-
- public void testUserRoot() {
- f.userRoot();
- }
-
- public void testSystemRoot() {
- f.systemRoot();
- }
-
- public static class PreferencesFactoryImpl implements PreferencesFactory {
-
- public Preferences userRoot() {
- return null;
- }
-
- public Preferences systemRoot() {
- return null;
- }
-
- }
-
-}
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.prefs.tests.java.util.prefs;
+
+import java.util.prefs.Preferences;
+import java.util.prefs.PreferencesFactory;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ */
+public class PreferencesFactoryTest extends TestCase {
+
+ PreferencesFactory f;
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ f = new PreferencesFactoryImpl();
+ }
+
+ public void testUserRoot() {
+ f.userRoot();
+ }
+
+ public void testSystemRoot() {
+ f.systemRoot();
+ }
+
+ public static class PreferencesFactoryImpl implements PreferencesFactory {
+
+ public Preferences userRoot() {
+ return null;
+ }
+
+ public Preferences systemRoot() {
+ return null;
+ }
+
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesFactoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native