harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r414559 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/net/URLConnection.java test/java/org/apache/harmony/tests/java/net/URLConnectionTest.java
Date Thu, 15 Jun 2006 11:19:35 GMT
Author: smishura
Date: Thu Jun 15 04:19:34 2006
New Revision: 414559

URL: http://svn.apache.org/viewvc?rev=414559&view=rev
Log:
Fixing method setRequestProperty() (the same as for addRequestProperty())

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLConnectionTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java?rev=414559&r1=414558&r2=414559&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java
Thu Jun 15 04:19:34 2006
@@ -907,12 +907,20 @@
 	 * @param newValue
 	 *            the field's new value
 	 * 
+	 * @throws IllegalStateException - if connection already established
+	 * @throws NullPointerException - if field is null
+	 * 
 	 * @see #getDefaultRequestProperty
 	 * @see #setDefaultRequestProperty
 	 * @see #getRequestProperty
 	 */
 	public void setRequestProperty(String field, String newValue) {
-
+        if (connected) {
+            throw new IllegalStateException(Msg.getString("K0037"));
+        }
+        if (field == null) {
+            throw new NullPointerException(Msg.getString("KA007"));
+        }
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLConnectionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLConnectionTest.java?rev=414559&r1=414558&r2=414559&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLConnectionTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLConnectionTest.java
Thu Jun 15 04:19:34 2006
@@ -52,6 +52,32 @@
     }
 
     /**
+     * @tests java.net.URLConnection#setRequestProperty(String, String)
+     */
+    public void test_setRequestProperty() throws MalformedURLException,
+            IOException {
+
+        MockURLConnection u = new MockURLConnection(new URL(
+                "http://www.apache.org"));
+        try {
+            u.setRequestProperty(null, "someValue");
+            fail("Expected NullPointerException");
+        } catch (NullPointerException e) {
+            // expected
+        }
+        
+        u.connect();
+        try {
+            // state of connection is checked first
+            // so no NPE in case of null 'field' param
+            u.setRequestProperty(null, "someValue");
+            fail("Expected IllegalStateException");
+        } catch (IllegalStateException e) {
+            // expected
+        }
+    }
+
+    /**
      * @tests java.net.URLConnection#setUseCaches(boolean)
      */
     public void test_setUseCachesZ() throws MalformedURLException, IOException {



Mime
View raw message