Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 62058 invoked from network); 20 Nov 2006 14:09:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Nov 2006 14:09:34 -0000 Received: (qmail 20355 invoked by uid 500); 20 Nov 2006 14:09:44 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 20313 invoked by uid 500); 20 Nov 2006 14:09:44 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 20304 invoked by uid 99); 20 Nov 2006 14:09:44 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Nov 2006 06:09:44 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Nov 2006 06:09:33 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id B0EB31A9846; Mon, 20 Nov 2006 06:08:59 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r477181 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/net/URLConnection.java test/java/tests/api/java/net/URLConnectionTest.java Date: Mon, 20 Nov 2006 14:08:59 -0000 To: commits@harmony.apache.org From: pyang@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061120140859.B0EB31A9846@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pyang Date: Mon Nov 20 06:08:58 2006 New Revision: 477181 URL: http://svn.apache.org/viewvc?view=rev&rev=477181 Log: Apply patch for HARMONY-2221 ([classlib][luni]method URLConnection.getRequestProperty should throw IllegalStateException if already connected) Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLConnectionTest.java Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java?view=diff&rev=477181&r1=477180&r2=477181 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java (original) +++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java Mon Nov 20 06:08:58 2006 @@ -648,14 +648,19 @@ * @param field * the field to get the property for * @return the field to look up + * @throws IllegalStateException - + * if connection already established * * @see #getDefaultRequestProperty * @see #setDefaultRequestProperty * @see #setRequestProperty */ - public String getRequestProperty(String field) { - return null; - } + public String getRequestProperty(String field) { + if (this.connected == true) { + throw new IllegalStateException(Msg.getString("K0037")); //$NON-NLS-1$ + } + return null; + } /** * Answers the URL of this connection Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLConnectionTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLConnectionTest.java?view=diff&rev=477181&r1=477180&r2=477181 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLConnectionTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLConnectionTest.java Mon Nov 20 06:08:58 2006 @@ -34,6 +34,7 @@ import java.net.SocketPermission; import java.net.URL; import java.net.URLConnection; +import java.net.URLStreamHandler; import java.security.Permission; import java.util.Calendar; import java.util.GregorianCalendar; @@ -838,6 +839,43 @@ assertNull("Wrong property returned: " + uc.getRequestProperty("No"), uc.getRequestProperty("No")); } + + /** + * @tests java.net.URLConnection#getRequestProperty(java.lang.String) + */ + public void test_getRequestProperty_LString_Exception() throws IOException { + class NewHandler extends URLStreamHandler { + protected URLConnection openConnection(URL u) + throws java.io.IOException { + return new HttpURLConnection(u) { + @Override + public void disconnect() { + // do nothing + } + @Override + public boolean usingProxy() { + return false; + } + @Override + public void connect() throws IOException { + connected = true; + } + }; + } + } + URL url = new URL("http", "test", 80, "index.html", new NewHandler()); + URLConnection urlCon = url.openConnection(); + urlCon.setRequestProperty("test", "testProperty"); + assertNull(urlCon.getRequestProperty("test")); + + urlCon.connect(); + try { + urlCon.getRequestProperty("test"); + fail("should throw IllegalStateException"); + } catch (IllegalStateException e) { + // expected + } + } /** * @tests java.net.URLConnection#getURL()