harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r372920 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/net/URLEncoder.java test/java/org/apache/harmony/tests/java/net/AllTests.java test/java/org/apache/harmony/tests/java/net/URLEncoderTest.java
Date Fri, 27 Jan 2006 17:19:51 GMT
Author: tellison
Date: Fri Jan 27 09:19:42 2006
New Revision: 372920

URL: http://svn.apache.org/viewcvs?rev=372920&view=rev
Log:
Fix for HARMONY-24 (java.net.URLEncoder.encode(String s, String enc) doesn't throw UnsupportedEncodingException)

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLEncoderTest.java
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLEncoder.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/AllTests.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLEncoder.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLEncoder.java?rev=372920&r1=372919&r2=372920&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLEncoder.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLEncoder.java
Fri Jan 27 09:19:42 2006
@@ -91,6 +91,12 @@
 	 */
 	public static String encode(String s, String enc)
 			throws UnsupportedEncodingException {
+		if (enc == null) {
+			throw new NullPointerException();
+		}
+		// check for UnsupportedEncodingException
+		"".getBytes(enc);
+
 		StringBuffer buf = new StringBuffer();
 		for (int i = 0; i < s.length(); i++) {
 			char ch = s.charAt(i);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/AllTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/AllTests.java?rev=372920&r1=372919&r2=372920&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/AllTests.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/AllTests.java
Fri Jan 27 09:19:42 2006
@@ -29,6 +29,7 @@
 				"Test for org.apache.harmony.tests.java.net");
 		//$JUnit-BEGIN$
 		suite.addTestSuite(URITest.class);
+		suite.addTestSuite(URLEncoderTest.class);
 		//$JUnit-END$
 		return suite;
 	}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLEncoderTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLEncoderTest.java?rev=372920&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLEncoderTest.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLEncoderTest.java
Fri Jan 27 09:19:42 2006
@@ -0,0 +1,35 @@
+/* Copyright 2006 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.tests.java.net;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import junit.framework.TestCase;
+
+public class URLEncoderTest extends TestCase {
+	
+	public void test_encodeLjava_lang_StringLjava_lang_String() {
+		// Regression for HARMONY-24
+        try {
+            URLEncoder.encode("str","unknown_enc");
+            fail("Assert 0: Should throw UEE for invalid encoding");
+        } catch (UnsupportedEncodingException e) {
+            // expected
+        } 
+	}
+
+}



Mime
View raw message