You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by qi...@apache.org on 2009/04/19 13:15:34 UTC
svn commit: r766448 [4/4] - in /harmony/enhanced/classlib/branches/java6: ./
depends/files/ depends/jars/icu4j_3.8/ depends/jars/icu4j_4.0/
depends/manifests/icu4j_3.8/META-INF/ depends/manifests/icu4j_4.0/
depends/manifests/icu4j_4.0/META-INF/ make/ m...
Modified: harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/RegistryPreferencesImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/RegistryPreferencesImpl.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/RegistryPreferencesImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/RegistryPreferencesImpl.java Sun Apr 19 11:15:28 2009
@@ -109,10 +109,10 @@
protected String getSpi(String key) {
int[] error = new int[1];
byte[] result = getValue(path, encodeWindowsStr(key).getBytes(), userNode, error);
- if (error[ERROR_CODE] != 0) {
+ if (error[ERROR_CODE] != RETURN_SUCCESS) {
return null;
}
- return new String(result);
+ return decodeWindowsStr(new String(result));
}
@Override
@@ -133,7 +133,7 @@
@Override
protected void putSpi(String name, String value) {
int[] errorCode = new int[1];
- putValue(path, encodeWindowsStr(name).getBytes(), value.getBytes(), userNode, errorCode);
+ putValue(path, encodeWindowsStr(name).getBytes(), encodeWindowsStr(value).getBytes(), userNode, errorCode);
if (errorCode[ERROR_CODE] == RETURN_ACCESS_DENIED) {
// prefs.E=Access denied\!
throw new SecurityException(Messages.getString("prefs.E")); //$NON-NLS-1$
Modified: harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/org/apache/harmony/prefs/internal/nls/Messages.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/org/apache/harmony/prefs/internal/nls/Messages.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/org/apache/harmony/prefs/internal/nls/Messages.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/org/apache/harmony/prefs/internal/nls/Messages.java Sun Apr 19 11:15:28 2009
@@ -23,7 +23,6 @@
package org.apache.harmony.prefs.internal.nls;
-
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Locale;
Modified: harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java Sun Apr 19 11:15:28 2009
@@ -115,28 +115,33 @@
try {
pref = new MockAbstractPreferences(
(AbstractPreferences) Preferences.userRoot(), "mo/ck");
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
try {
pref = new MockAbstractPreferences(null, "mock");
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
try {
new MockAbstractPreferences(null, " ");
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
try {
new MockAbstractPreferences(pref, "");
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
try {
new MockAbstractPreferences(pref, null);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
if (!(pref instanceof MockAbstractPreferences)) {
return;
@@ -229,8 +234,9 @@
try {
pref.get(null, "abc");
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
pref.get("", "abc");
pref.get("key", null);
@@ -241,21 +247,24 @@
pref.removeNode();
try {
pref.get("key", "abc");
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.get(null, "abc");
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
}
public void testGetBoolean() {
try {
pref.getBoolean(null, false);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
pref.put("testGetBooleanKey", "false");
@@ -267,28 +276,32 @@
public void testPutByteArray() {
try {
pref.putByteArray(null, new byte[0]);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
try {
pref.putByteArray("testPutByteArrayKey4", null);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
pref.putByteArray(longKey, new byte[0]);
try {
pref.putByteArray(longKey + "a", new byte[0]);
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
byte[] longArray = new byte[(int) (Preferences.MAX_VALUE_LENGTH * 0.74)];
byte[] longerArray = new byte[(int) (Preferences.MAX_VALUE_LENGTH * 0.75) + 1];
pref.putByteArray(longKey, longArray);
try {
pref.putByteArray(longKey, longerArray);
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
pref.putByteArray("testPutByteArrayKey", new byte[0]);
@@ -305,8 +318,9 @@
public void testGetByteArray() throws UnsupportedEncodingException {
try {
pref.getByteArray(null, new byte[0]);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
byte[] b64Array = new byte[] { 0x59, 0x57, 0x4a, 0x6a };// BASE64
// encoding for
@@ -335,8 +349,9 @@
public void testGetDouble() {
try {
pref.getDouble(null, 0);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
pref.put("testGetDoubleKey", "1");
@@ -352,8 +367,9 @@
public void testGetFloat() {
try {
pref.getFloat(null, 0f);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
pref.put("testGetFloatKey", "1");
pref.put("testGetFloatKey2", "value");
@@ -364,8 +380,9 @@
public void testGetInt() {
try {
pref.getInt(null, 0);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
pref.put("testGetIntKey", "1");
@@ -377,8 +394,9 @@
public void testGetLong() {
try {
pref.getLong(null, 0);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
pref.put("testGetLongKey", "1");
@@ -459,23 +477,27 @@
public void testNode() throws BackingStoreException {
try {
pref.node(null);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
try {
pref.node("/java/util/prefs/");
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
try {
pref.node("/java//util/prefs");
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
try {
pref.node(longName + "a");
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
assertNotNull(pref.node(longName));
@@ -519,18 +541,21 @@
public void testNodeExists() throws BackingStoreException {
try {
pref.nodeExists(null);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
try {
pref.nodeExists("/java/util/prefs/");
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
try {
pref.nodeExists("/java//util/prefs");
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
assertTrue(pref.nodeExists("/"));
@@ -553,6 +578,25 @@
assertTrue(pref.nodeExists("child2/grandchild"));
}
+ public void test_nodeExists() throws BackingStoreException {
+ AbstractPreferences test = (AbstractPreferences) Preferences.userRoot()
+ .node("test");
+ try {
+ test.nodeExists(null);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+
+ test.removeNode();
+ try {
+ test.nodeExists(null);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ }
+
public void testParent() {
assertSame(parent, pref.parent());
AbstractPreferences child1 = new MockAbstractPreferences(pref, "child1");
@@ -573,51 +617,59 @@
try {
pref.put(null, "value");
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
try {
pref.put("key", null);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
pref.put(longKey, longValue);
try {
pref.put(longKey + 1, longValue);
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
try {
pref.put(longKey, longValue + 1);
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
pref.removeNode();
try {
pref.put(longKey, longValue + 1);
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
try {
pref.put(longKey, longValue);
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
}
public void testPutBoolean() {
try {
pref.putBoolean(null, false);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
pref.putBoolean(longKey, false);
try {
pref.putBoolean(longKey + "a", false);
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
pref.putBoolean("testPutBooleanKey", false);
assertEquals("false", pref.get("testPutBooleanKey", null));
@@ -627,14 +679,16 @@
public void testPutDouble() {
try {
pref.putDouble(null, 3);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
pref.putDouble(longKey, 3);
try {
pref.putDouble(longKey + "a", 3);
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
pref.putDouble("testPutDoubleKey", 3);
assertEquals("3.0", pref.get("testPutDoubleKey", null));
@@ -644,14 +698,16 @@
public void testPutFloat() {
try {
pref.putFloat(null, 3f);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
pref.putFloat(longKey, 3f);
try {
pref.putFloat(longKey + "a", 3f);
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
pref.putFloat("testPutFloatKey", 3f);
assertEquals("3.0", pref.get("testPutFloatKey", null));
@@ -661,14 +717,16 @@
public void testPutInt() {
try {
pref.putInt(null, 3);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
pref.putInt(longKey, 3);
try {
pref.putInt(longKey + "a", 3);
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
pref.putInt("testPutIntKey", 3);
assertEquals("3", pref.get("testPutIntKey", null));
@@ -678,14 +736,16 @@
public void testPutLong() {
try {
pref.putLong(null, 3L);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
pref.putLong(longKey, 3L);
try {
pref.putLong(longKey + "a", 3L);
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
pref.putLong("testPutLongKey", 3L);
assertEquals("3", pref.get("testPutLongKey", null));
@@ -704,14 +764,17 @@
try {
pref.remove(null);
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
pref.removeNode();
try {
pref.remove("key");
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
}
@@ -824,14 +887,14 @@
public void testAddPreferenceChangeListener() {
// TODO: start from here
-
}
public void testRemoveNodeChangeListener() {
try {
pref.removeNodeChangeListener(null);
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
MockNodeChangeListener l1 = new MockNodeChangeListener();
MockNodeChangeListener l2 = new MockNodeChangeListener();
@@ -842,21 +905,24 @@
pref.removeNodeChangeListener(l1);
try {
pref.removeNodeChangeListener(l1);
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
try {
pref.removeNodeChangeListener(l2);
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
}
public void testRemovePreferenceChangeListener() {
try {
pref.removePreferenceChangeListener(null);
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
MockPreferenceChangeListener l1 = new MockPreferenceChangeListener();
MockPreferenceChangeListener l2 = new MockPreferenceChangeListener();
@@ -864,15 +930,17 @@
pref.addPreferenceChangeListener(l1);
try {
pref.removePreferenceChangeListener(l2);
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
pref.removePreferenceChangeListener(l1);
pref.removePreferenceChangeListener(l1);
try {
pref.removePreferenceChangeListener(l1);
- fail();
+ fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
+ // Expected
}
}
@@ -1004,7 +1072,7 @@
public void testExportNode() throws Exception {
try {
pref.exportNode(null);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
// Expected
}
@@ -1056,7 +1124,7 @@
public void testExportSubtree() throws Exception {
try {
pref.exportSubtree(null);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
// Expected
}
@@ -1176,8 +1244,9 @@
p.setResult(MockAbstractPreferences.backingException);
try {
p.childrenNames();
- fail();
+ fail("should throw BackingStoreException");
} catch (BackingStoreException e) {
+ // Expected
}
p.put("exceptionkey", "value");
p.absolutePath();
@@ -1186,8 +1255,9 @@
p.remove("key");
try {
p.clear();
- fail();
+ fail("should throw BackingStoreException");
} catch (BackingStoreException e) {
+ // Expected
}
p.putInt("key", 3);
p.getInt("key", 3);
@@ -1203,27 +1273,31 @@
p.getByteArray("key", new byte[0]);
try {
p.keys();
- fail();
+ fail("should throw BackingStoreException");
} catch (BackingStoreException e) {
+ // Expected
}
try {
p.keys();
- fail();
+ fail("should throw BackingStoreException");
} catch (BackingStoreException e) {
+ // Expected
}
try {
p.childrenNames();
- fail();
+ fail("should throw BackingStoreException");
} catch (BackingStoreException e) {
+ // Expected
}
p.parent();
p.node("");
p.nodeExists("");
try {
p.removeNode();
- fail();
+ fail("should throw BackingStoreException");
} catch (BackingStoreException e) {
+ // Expected
}
p.name();
p.absolutePath();
@@ -1237,29 +1311,34 @@
p.toString();
try {
p.sync();
- fail();
+ fail("should throw BackingStoreException");
} catch (BackingStoreException e) {
+ // Expected
}
try {
p.flush();
- fail();
+ fail("should throw BackingStoreException");
} catch (BackingStoreException e) {
+ // Expected
}
try {
p.exportNode(new ByteArrayOutputStream());
- fail();
+ fail("should throw BackingStoreException");
} catch (BackingStoreException e) {
+ // Expected
}
try {
p.exportSubtree(new ByteArrayOutputStream());
- fail();
+ fail("should throw BackingStoreException");
} catch (BackingStoreException e) {
+ // Expected
}
p.isRemovedImpl();
try {
p.getChildImpl(null);
- fail();
+ fail("should throw BackingStoreException");
} catch (BackingStoreException e) {
+ // Expected
}
p.cachedChildrenImpl();
}
@@ -1273,85 +1352,99 @@
p.setResult(MockAbstractPreferences.runtimeException);
try {
p.childrenNames();
- fail();
+ fail("should throw MockRuntimeException");
} catch (MockRuntimeException e) {
+ // Expected
}
try {
p.put("exceptionkey", "value");
- fail();
+ fail("should throw MockRuntimeException");
} catch (MockRuntimeException e) {
+ // Expected
}
p.absolutePath();
p.toString();
assertEquals("exception default", p.get("key", "exception default"));
try {
p.remove("key");
- fail();
+ fail("should throw MockRuntimeException");
} catch (MockRuntimeException e) {
+ // Expected
}
try {
p.clear();
- fail();
+ fail("should throw MockRuntimeException");
} catch (MockRuntimeException e) {
+ // Expected
}
try {
p.putInt("key", 3);
- fail();
+ fail("should throw MockRuntimeException");
} catch (MockRuntimeException e) {
+ // Expected
}
p.getInt("key", 3);
try {
p.putLong("key", 3l);
- fail();
+ fail("should throw MockRuntimeException");
} catch (MockRuntimeException e) {
+ // Expected
}
p.getLong("key", 3l);
try {
p.putDouble("key", 3);
- fail();
+ fail("should throw MockRuntimeException");
} catch (MockRuntimeException e) {
+ // Expected
}
p.getDouble("key", 3);
try {
p.putBoolean("key", true);
- fail();
+ fail("should throw MockRuntimeException");
} catch (MockRuntimeException e) {
+ // Expected
}
p.getBoolean("key", true);
try {
p.putFloat("key", 3f);
- fail();
+ fail("should throw MockRuntimeException");
} catch (MockRuntimeException e) {
+ // Expected
}
p.getFloat("key", 3f);
try {
p.putByteArray("key", new byte[0]);
- fail();
+ fail("should throw MockRuntimeException");
} catch (MockRuntimeException e) {
+ // Expected
}
p.getByteArray("key", new byte[0]);
try {
p.keys();
- fail();
+ fail("should throw MockRuntimeException");
} catch (MockRuntimeException e) {
+ // Expected
}
try {
p.keys();
- fail();
+ fail("should throw MockRuntimeException");
} catch (MockRuntimeException e) {
+ // Expected
}
try {
p.childrenNames();
- fail();
+ fail("should throw MockRuntimeException");
} catch (MockRuntimeException e) {
+ // Expected
}
p.parent();
p.node("");
p.nodeExists("");
try {
p.removeNode();
- fail();
+ fail("should throw MockRuntimeException");
} catch (MockRuntimeException e) {
+ // Expected
}
p.name();
p.absolutePath();
@@ -1365,29 +1458,34 @@
p.toString();
try {
p.sync();
- fail();
+ fail("should throw MockRuntimeException");
} catch (MockRuntimeException e) {
+ // Expected
}
try {
p.flush();
- fail();
+ fail("should throw MockRuntimeException");
} catch (MockRuntimeException e) {
+ // Expected
}
try {
p.exportNode(new ByteArrayOutputStream());
- fail();
+ fail("should throw MockRuntimeException");
} catch (MockRuntimeException e) {
+ // Expected
}
try {
p.exportSubtree(new ByteArrayOutputStream());
- fail();
+ fail("should throw MockRuntimeException");
} catch (MockRuntimeException e) {
+ // Expected
}
p.isRemovedImpl();
try {
p.getChildImpl(null);
- fail();
+ fail("should throw MockRuntimeException");
} catch (MockRuntimeException e) {
+ // Expected
}
p.cachedChildrenImpl();
}
@@ -1400,8 +1498,9 @@
p.setResult(MockAbstractPreferences.returnNull);
try {
p.childrenNames();
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
p.absolutePath();
p.toString();
@@ -1410,8 +1509,9 @@
p.remove("key");
try {
p.clear();
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
p.putInt("key", 3);
p.getInt("key", 3);
@@ -1428,16 +1528,18 @@
p.keys();
try {
p.childrenNames();
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
p.parent();
p.node("");
p.nodeExists("");
try {
p.removeNode();
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
p.name();
p.absolutePath();
@@ -1453,19 +1555,22 @@
p.flush();
try {
p.exportNode(System.out);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
try {
p.exportSubtree(System.out);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
p.isRemovedImpl();
try {
p.getChildImpl("");
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
p.cachedChildrenImpl();
}
@@ -1487,160 +1592,191 @@
pref.flush();
try {
pref.nodeExists("child");
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.childrenNames();
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.remove(null);
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.clear();
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.get("key", "null default");
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.put("nullkey", "value");
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.putInt("key", 3);
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.getInt("key", 3);
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.putLong("key", 3l);
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.getLong("key", 3l);
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.putDouble("key", 3);
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.getDouble("key", 3);
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.putBoolean("key", true);
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.getBoolean("key", true);
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.putFloat("key", 3f);
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.getFloat("key", 3f);
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.putByteArray("key", new byte[0]);
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.getByteArray("key", new byte[0]);
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.keys();
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.keys();
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.childrenNames();
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.parent();
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.node(null);
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.removeNode();
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref
- .addPreferenceChangeListener(new MockPreferenceChangeListener());
- fail();
+ .addPreferenceChangeListener(new MockPreferenceChangeListener());
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref
- .removePreferenceChangeListener(new MockPreferenceChangeListener());
- fail();
+ .removePreferenceChangeListener(new MockPreferenceChangeListener());
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.addNodeChangeListener(new MockNodeChangeListener());
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.removeNodeChangeListener(new MockNodeChangeListener());
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.sync();
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.exportNode(null);
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
pref.exportSubtree(null);
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
if (!(pref instanceof MockAbstractPreferences)) {
return;
@@ -1650,8 +1786,9 @@
p.cachedChildrenImpl();
try {
p.getChildImpl(null);
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
}
@@ -1663,93 +1800,111 @@
p.removeNode();
try {
p.get(null, "null default");
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
try {
p.put(null, "value");
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
try {
p.putInt(null, 3);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
try {
p.getInt(null, 3);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
try {
p.putLong(null, 3l);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
try {
p.getLong(null, 3l);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
try {
p.putDouble(null, 3);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
try {
p.getDouble(null, 3);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
try {
p.putBoolean(null, true);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
try {
p.getBoolean(null, true);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
try {
p.putFloat(null, 3f);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
try {
p.getFloat(null, 3f);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
try {
p.putByteArray(null, new byte[0]);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
try {
p.getByteArray(null, new byte[0]);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
try {
p.addPreferenceChangeListener(null);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
try {
p.removePreferenceChangeListener(null);
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
try {
p.addNodeChangeListener(null);
- fail();
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
try {
p.removeNodeChangeListener(null);
- fail();
+ fail("should throw IllegalStateException");
} catch (IllegalStateException e) {
+ // Expected
}
}
@@ -1847,4 +2002,3 @@
}
}
-
Modified: harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesFactoryTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesFactoryTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesFactoryTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesFactoryTest.java Sun Apr 19 11:15:28 2009
@@ -38,11 +38,11 @@
}
public void testUserRoot() {
- f.userRoot();
+ assertNull(f.userRoot());
}
public void testSystemRoot() {
- f.systemRoot();
+ assertNull(f.systemRoot());
}
public static class PreferencesFactoryImpl implements PreferencesFactory {
Modified: harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesTest.java Sun Apr 19 11:15:28 2009
@@ -77,26 +77,15 @@
assertEquals("lang", p.name());
assertEquals("System Preference Node: " + p.absolutePath(), p
.toString());
+
+ assertEquals(0, p.childrenNames().length);
+ assertEquals(0, p.keys().length);
+ parent.removeNode();
try {
- assertEquals(0, p.childrenNames().length);
- } catch (BackingStoreException e) {
- // could be thrown according to specification
- }
- try {
- assertEquals(0, p.keys().length);
- } catch (BackingStoreException e) {
- // could be thrown according to specification
- }
- try {
- parent.removeNode();
- } catch (BackingStoreException e) {
- // could be thrown according to specification
- }
- try {
- p = Preferences.userNodeForPackage(null);
- fail("NullPointerException has not been thrown");
+ Preferences.userNodeForPackage(null);
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
- // expected
+ // Expected
}
}
@@ -109,8 +98,6 @@
assertEquals("", p.name());
assertEquals("System Preference Node: " + p.absolutePath(), p
.toString());
- // assertEquals(0, p.childrenNames().length);
- // assertEquals(0, p.keys().length);
}
public void testConsts() {
@@ -133,9 +120,10 @@
assertEquals(0, p.keys().length);
try {
- p = Preferences.userNodeForPackage(null);
- fail();
+ Preferences.userNodeForPackage(null);
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
}
@@ -147,8 +135,6 @@
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 {
@@ -160,7 +146,8 @@
prefs.put("prefskey", "oldvalue");
prefs.put("prefskey2", "oldvalue2");
- in = PreferencesTest.class.getResourceAsStream("/prefs/java/util/prefs/userprefs.xml");
+ in = PreferencesTest.class
+ .getResourceAsStream("/prefs/java/util/prefs/userprefs.xml");
Preferences.importPreferences(in);
prefs = Preferences.userNodeForPackage(PreferencesTest.class);
@@ -171,39 +158,43 @@
assertEquals("newvalue3", prefs.get("prefskey3", null));
in = PreferencesTest.class
- .getResourceAsStream("/prefs/java/util/prefs/userprefs-badform.xml");
+ .getResourceAsStream("/prefs/java/util/prefs/userprefs-badform.xml");
try {
Preferences.importPreferences(in);
- fail();
+ fail("should throw InvalidPreferencesFormatException");
} catch (InvalidPreferencesFormatException e) {
+ // Expected
}
in = PreferencesTest.class
- .getResourceAsStream("/prefs/java/util/prefs/userprefs-badtype.xml");
+ .getResourceAsStream("/prefs/java/util/prefs/userprefs-badtype.xml");
try {
Preferences.importPreferences(in);
- fail();
+ fail("should throw InvalidPreferencesFormatException");
} catch (InvalidPreferencesFormatException e) {
+ // Expected
}
in = PreferencesTest.class
- .getResourceAsStream("/prefs/java/util/prefs/userprefs-badencoding.xml");
+ .getResourceAsStream("/prefs/java/util/prefs/userprefs-badencoding.xml");
try {
Preferences.importPreferences(in);
- fail();
+ fail("should throw InvalidPreferencesFormatException");
} catch (InvalidPreferencesFormatException e) {
+ // Expected
}
in = PreferencesTest.class
- .getResourceAsStream("/prefs/java/util/prefs/userprefs-higherversion.xml");
+ .getResourceAsStream("/prefs/java/util/prefs/userprefs-higherversion.xml");
try {
Preferences.importPreferences(in);
- fail();
+ fail("should throw InvalidPreferencesFormatException");
} catch (InvalidPreferencesFormatException e) {
+ // Expected
}
in = PreferencesTest.class
- .getResourceAsStream("/prefs/java/util/prefs/userprefs-ascii.xml");
+ .getResourceAsStream("/prefs/java/util/prefs/userprefs-ascii.xml");
Preferences.importPreferences(in);
prefs = Preferences.userNodeForPackage(PreferencesTest.class);
} finally {
@@ -211,6 +202,7 @@
prefs = Preferences.userRoot().node("tests");
prefs.removeNode();
} catch (Exception e) {
+ // Ignored
}
}
}
@@ -218,30 +210,34 @@
public void testImportPreferencesException() throws Exception {
try {
Preferences.importPreferences(null);
- fail();
+ fail("should throw MalformedURLException");
} catch (MalformedURLException e) {
+ // Expected
}
byte[] source = new byte[0];
InputStream in = new ByteArrayInputStream(source);
try {
Preferences.importPreferences(in);
- fail();
+ fail("should throw InvalidPreferencesFormatException");
} catch (InvalidPreferencesFormatException e) {
+ // Expected
}
stream.setResult(MockInputStream.exception);
try {
Preferences.importPreferences(stream);
- fail();
+ fail("should throw IOException");
} catch (IOException e) {
+ // Expected
}
stream.setResult(MockInputStream.runtimeException);
try {
Preferences.importPreferences(stream);
- fail();
+ fail("should throw RuntimeException");
} catch (RuntimeException e) {
+ // Expected
}
}
@@ -251,103 +247,41 @@
manager.install();
try {
Preferences.userRoot();
- fail();
+ fail("should throw SecurityException");
} catch (SecurityException e) {
+ // Expected
}
try {
Preferences.systemRoot();
- fail();
+ fail("should throw SecurityException");
} catch (SecurityException e) {
+ // Expected
}
try {
Preferences.userNodeForPackage(null);
- fail();
+ fail("should throw SecurityException");
} catch (SecurityException e) {
+ // Expected
}
try {
Preferences.systemNodeForPackage(null);
- fail();
+ fail("should throw SecurityException");
} catch (SecurityException e) {
+ // Expected
}
try {
Preferences.importPreferences(stream);
- fail();
+ fail("should throw SecurityException");
} catch (SecurityException e) {
+ // Expected
}
} 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;
Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1StringType.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1StringType.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1StringType.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1StringType.java Sun Apr 19 11:15:28 2009
@@ -139,11 +139,15 @@
}
public void setEncodingContent(BerOutputStream out) {
-
- byte[] bytes = ((String) out.content).getBytes();
-
- out.content = bytes;
- out.length = bytes.length;
+ try {
+ byte[] bytes = ((String) out.content).getBytes("UTF-8"); //$NON-NLS-1$
+ out.content = bytes;
+ out.length = bytes.length;
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e.getMessage());
+ }
}
}
+
+
Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1UTCTime.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1UTCTime.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1UTCTime.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1UTCTime.java Sun Apr 19 11:15:28 2009
@@ -23,6 +23,7 @@
package org.apache.harmony.security.asn1;
import java.io.IOException;
+import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
@@ -115,7 +116,11 @@
public void setEncodingContent(BerOutputStream out) {
SimpleDateFormat sdf = new SimpleDateFormat(UTC_PATTERN);
sdf.setTimeZone(TimeZone.getTimeZone("UTC")); //$NON-NLS-1$
- out.content = sdf.format(out.content).getBytes();
+ try {
+ out.content = sdf.format(out.content).getBytes("UTF-8"); //$NON-NLS-1$
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e.getMessage());
+ }
out.length = ((byte[]) out.content).length;
}
-}
\ No newline at end of file
+}
Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/provider/cert/X509CertFactoryImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/provider/cert/X509CertFactoryImpl.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/provider/cert/X509CertFactoryImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/provider/cert/X509CertFactoryImpl.java Sun Apr 19 11:15:28 2009
@@ -25,6 +25,7 @@
import java.io.IOException;
import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
import java.security.cert.CRL;
import java.security.cert.CRLException;
import java.security.cert.CertPath;
@@ -446,8 +447,8 @@
// ------------------------ Staff methods ------------------------------
// ---------------------------------------------------------------------
- private static byte[] pemBegin = "-----BEGIN".getBytes(); //$NON-NLS-1$
- private static byte[] pemClose = "-----END".getBytes(); //$NON-NLS-1$
+ private static byte[] pemBegin;
+ private static byte[] pemClose;
/**
* Code describing free format for PEM boundary suffix:
* "^-----BEGIN.*\n" at the beginning, and<br>
@@ -459,8 +460,18 @@
* "^-----BEGIN CERTIFICATE-----\n" at the beginning, and<br>
* "\n-----END CERTIFICATE-----" at the end.
*/
- private static byte[] CERT_BOUND_SUFFIX =
- " CERTIFICATE-----".getBytes(); //$NON-NLS-1$
+ private static byte[] CERT_BOUND_SUFFIX;
+
+ static {
+ // Initialise statics
+ try {
+ pemBegin = "-----BEGIN".getBytes("UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$
+ pemClose = "-----END".getBytes("UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$
+ CERT_BOUND_SUFFIX = " CERTIFICATE-----".getBytes("UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e.getMessage());
+ }
+ }
/**
* Method retrieves the PEM encoded data from the stream
@@ -929,3 +940,5 @@
}
}
+
+
Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/x501/AttributeTypeAndValue.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/x501/AttributeTypeAndValue.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/x501/AttributeTypeAndValue.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/x501/AttributeTypeAndValue.java Sun Apr 19 11:15:28 2009
@@ -28,6 +28,7 @@
import java.util.Iterator;
import javax.security.auth.x500.X500Principal;
+import java.io.UnsupportedEncodingException;
import org.apache.harmony.security.asn1.ASN1Constants;
import org.apache.harmony.security.asn1.ASN1Oid;
@@ -449,7 +450,11 @@
av.bytes = (byte[]) out.content;
out.content = av;
} else {
- av.bytes = av.rawString.getBytes();
+ try {
+ av.bytes = av.rawString.getBytes("UTF-8"); //$NON-NLS-1$
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e.getMessage());
+ }
out.length = av.bytes.length;
}
}
@@ -538,4 +543,4 @@
}
return intHash & 0x7FFFFFFF; // only positive
}
-}
\ No newline at end of file
+}
Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/x509/GeneralName.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/x509/GeneralName.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/x509/GeneralName.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/x509/GeneralName.java Sun Apr 19 11:15:28 2009
@@ -583,7 +583,7 @@
* The correctness is checked as specified in RFC 1034 p. 10.
*/
public static void checkDNS(String dns) throws IOException {
- byte[] bytes = dns.toLowerCase().getBytes();
+ byte[] bytes = dns.toLowerCase().getBytes("UTF-8"); //$NON-NLS-1$
// indicates if it is a first letter of the label
boolean first_letter = true;
for (int i=0; i<bytes.length; i++) {
@@ -637,7 +637,7 @@
* Converts OID into array of bytes.
*/
public static int[] oidStrToInts(String oid) throws IOException {
- byte[] bytes = oid.getBytes();
+ byte[] bytes = oid.getBytes("UTF-8"); //$NON-NLS-1$
if (bytes[bytes.length-1] == '.') {
throw new IOException(Messages.getString("security.56", oid)); //$NON-NLS-1$
}
@@ -691,7 +691,7 @@
}
// the resulting array
byte[] result = new byte[num_components];
- byte[] ip_bytes = ip.getBytes();
+ byte[] ip_bytes = ip.getBytes("UTF-8"); //$NON-NLS-1$
// number of address component to be read
int component = 0;
// if it is reading the second bound of a range
Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Identity2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Identity2Test.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Identity2Test.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Identity2Test.java Sun Apr 19 11:15:28 2009
@@ -20,6 +20,7 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
import java.security.Identity;
import java.security.IdentityScope;
import java.security.KeyManagementException;
@@ -97,8 +98,7 @@
+ "1777XQ9UEZyrKJvF5ntleeO0ayBqLGVKCWzWZX9YsXCpv47FNLZbupE=\n"
+ "-----END CERTIFICATE-----\n";
- ByteArrayInputStream certArray = new ByteArrayInputStream(certificate
- .getBytes());
+ ByteArrayInputStream certArray;
String certificate2 = "-----BEGIN CERTIFICATE-----\n"
+ "MIICZzCCAdCgAwIBAgIBGzANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQGEwJVUzEY\n"
@@ -116,8 +116,18 @@
+ "VGQRYYlt+myhl2vy6yPzEVCjiKwMEb1Spu0irCf+lFW2hsdjvmSQMtZvOw==\n"
+ "-----END CERTIFICATE-----\n";
- ByteArrayInputStream certArray2 = new ByteArrayInputStream(certificate2
- .getBytes());
+ ByteArrayInputStream certArray2;
+
+ {
+ try {
+ certArray = new ByteArrayInputStream(certificate
+ .getBytes("UTF-8"));
+ certArray2 = new ByteArrayInputStream(certificate2
+ .getBytes("UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e.getMessage());
+ }
+ }
public static class IdentitySubclass extends Identity {
public IdentitySubclass() {
Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStore3Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStore3Test.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStore3Test.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStore3Test.java Sun Apr 19 11:15:28 2009
@@ -22,6 +22,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
import java.security.Key;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
@@ -70,8 +71,14 @@
+ "1777XQ9UEZyrKJvF5ntleeO0ayBqLGVKCWzWZX9YsXCpv47FNLZbupE=\n"
+ "-----END CERTIFICATE-----\n";
- ByteArrayInputStream certArray = new ByteArrayInputStream(
- certificateData.getBytes());
+ ByteArrayInputStream certArray;
+ {
+ try {
+ certArray = new ByteArrayInputStream(certificateData.getBytes("UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e.getMessage());
+ }
+ }
CertificateFactory cf = CertificateFactory.getInstance("X.509");
certificate = cf.generateCertificate(certArray);
}
Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStorePrivateKeyEntryTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStorePrivateKeyEntryTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStorePrivateKeyEntryTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStorePrivateKeyEntryTest.java Sun Apr 19 11:15:28 2009
@@ -18,6 +18,7 @@
package org.apache.harmony.security.tests.java.security;
import java.io.ByteArrayInputStream;
+import java.io.UnsupportedEncodingException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.KeyStore;
@@ -48,8 +49,15 @@
+ "1777XQ9UEZyrKJvF5ntleeO0ayBqLGVKCWzWZX9YsXCpv47FNLZbupE=\n"
+ "-----END CERTIFICATE-----\n";
- ByteArrayInputStream certArray = new ByteArrayInputStream(
- certificateData.getBytes());
+ ByteArrayInputStream certArray;
+ {
+ try{
+ certArray = new ByteArrayInputStream(
+ certificateData.getBytes("UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e.getMessage());
+ }
+ }
CertificateFactory cf = CertificateFactory.getInstance("X.509");
Certificate certificate = cf.generateCertificate(certArray);
assertTrue(certificate instanceof X509Certificate);
Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory4Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory4Test.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory4Test.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory4Test.java Sun Apr 19 11:15:28 2009
@@ -58,12 +58,12 @@
CertificateFactory fact = CertificateFactory.getInstance("X.509");
for (int i = 0; i < CERTIFICATES_ENCODED_X509.length; i++) {
ByteArrayInputStream bais = new ByteArrayInputStream(
- CERTIFICATES_ENCODED_X509[i].getBytes());
+ CERTIFICATES_ENCODED_X509[i].getBytes("UTF-8"));
fact.generateCertificate(bais);
// try again with generateCertificates()
bais = new ByteArrayInputStream(CERTIFICATES_ENCODED_X509[i]
- .getBytes());
+ .getBytes("UTF-8"));
fact.generateCertificate(bais);
}
Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/test/impl/java.injected/java/security/cert/X509CertificateTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/test/impl/java.injected/java/security/cert/X509CertificateTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/test/impl/java.injected/java/security/cert/X509CertificateTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/test/impl/java.injected/java/security/cert/X509CertificateTest.java Sun Apr 19 11:15:28 2009
@@ -263,12 +263,12 @@
ByteArrayInputStream is = null;
CertificateFactory certFactory = CertificateFactory
.getInstance("X.509");
- is = new ByteArrayInputStream(Base64.decode(base64cert.getBytes()));
+ is = new ByteArrayInputStream(Base64.decode(base64cert.getBytes("UTF-8")));
X509Certificate cert = (X509Certificate) certFactory
.generateCertificate(is);
cert.getExtensionValue("1.1.1.1");
- is = new ByteArrayInputStream(Base64.decode(base64crl.getBytes()));
+ is = new ByteArrayInputStream(Base64.decode(base64crl.getBytes("UTF-8")));
X509CRL crl = (X509CRL) certFactory.generateCRL(is);
crl.getExtensionValue("1.1.1.1");
}
@@ -283,3 +283,4 @@
}
}
+
Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertFactoryPerfTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertFactoryPerfTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertFactoryPerfTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertFactoryPerfTest.java Sun Apr 19 11:15:28 2009
@@ -316,7 +316,11 @@
"-----END CERTIFICATE-----\n";
static {
- certEncoding_b64 = base64certEncoding.getBytes();
+ try {
+ certEncoding_b64 = base64certEncoding.getBytes("UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e.getMessage());
+ }
stream_b64 = new ByteArrayInputStream(certEncoding_b64);
stream_b64.mark(certEncoding_b64.length);
}
@@ -840,3 +844,5 @@
}
}
+
+
Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/TestUtils.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/TestUtils.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/TestUtils.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/TestUtils.java Sun Apr 19 11:15:28 2009
@@ -26,6 +26,7 @@
import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.UnsupportedEncodingException;
import java.security.InvalidAlgorithmParameterException;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
@@ -305,7 +306,13 @@
+ "JDSM\n" + "-----END CERTIFICATE-----\n";
public static byte[] getEncodedX509Certificate() {
- return ENCODED_X509_CERTIFICATE.getBytes();
+ byte cert[];
+ try {
+ cert = ENCODED_X509_CERTIFICATE.getBytes("UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e.getMessage());
+ }
+ return cert;
}
/**