harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r408876 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni: make/common/ src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/ src/test/java.injected/ src/test/java.injected/java/ src/test/java.injected/java/net/ s...
Date Tue, 23 May 2006 11:56:38 GMT
Author: mloenko
Date: Tue May 23 04:56:37 2006
New Revision: 408876

URL: http://svn.apache.org/viewvc?rev=408876&view=rev
Log:
fixes and regression test for HARMONY-482
Some code compares Strings with == operator 

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java.injected/
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java.injected/java/
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java.injected/java/net/
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java.injected/java/net/HttpURLConnectionAccessor.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/internal/
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/internal/net/
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/internal/net/www/
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/internal/net/www/protocol/
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/internal/net/www/protocol/http/
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/make/common/build.xml
    incubator/harmony/enhanced/classlib/trunk/modules/luni/make/common/hyproperties.xml
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/make/common/build.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/make/common/build.xml?rev=408876&r1=408875&r2=408876&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/make/common/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/make/common/build.xml Tue May 23
04:56:37 2006
@@ -50,6 +50,23 @@
     <target name="compile.tests" depends="copy.test.resources">
         <echo message="Compiling LUNI tests from ${hy.luni.src.test.java}" />
 
+        <mkdir dir="${hy.luni.bin.injected}" />
+
+        <javac srcdir="${hy.luni.src.test.injected}"
+            destdir="${hy.luni.bin.injected}"
+            sourcepath=""
+            source="${hy.javac.source}"
+            target="${hy.javac.target}"
+            debug="${java.debug.option}">
+
+            <bootclasspath>
+                <fileset dir="${hy.target}/jre/lib/boot">
+                    <include name="**/*.jar" />
+                </fileset>
+            </bootclasspath>
+            <classpath location="${hy.tests.support.bin}" />
+        </javac>
+
         <mkdir dir="${hy.luni.bin.test}" />
 
         <javac srcdir="${hy.luni.src.test.java}"
@@ -63,6 +80,7 @@
                 <fileset dir="${hy.target}/jre/lib/boot">
                     <include name="**/*.jar" />
                 </fileset>
+                <pathelement path="${hy.luni.bin.injected}"/>
             </bootclasspath>
             <classpath location="${hy.tests.support.bin}" />
         </javac>
@@ -98,6 +116,8 @@
                 <pathelement path="${hy.luni.bin.test}" />
                 <pathelement path="${hy.tests.support.bin}" />
             </classpath>
+
+            <jvmarg value="-Xbootclasspath/a:${hy.luni.bin.injected}"/>
 
             <formatter type="xml" />
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/make/common/hyproperties.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/make/common/hyproperties.xml?rev=408876&r1=408875&r2=408876&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/make/common/hyproperties.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/make/common/hyproperties.xml Tue
May 23 04:56:37 2006
@@ -25,12 +25,14 @@
          <test>
             <java location="src/test/java" />
             <resources location="src/test/resources" />
+            <injected location="src/test/java.injected" />
          </test>
          <natives location="src/natives" />
       </src>
       <bin>
         <main location="bin/main" />
         <test location="bin/test" />
+        <injected location="bin/test-injected" />
       </bin>
       <packaging>
       </packaging>

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java?rev=408876&r1=408875&r2=408876&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
Tue May 23 04:56:37 2006
@@ -526,7 +526,7 @@
      *         server.
      */
     public InputStream getErrorStream() {
-        if (connected && method != "HEAD" && responseCode >= HTTP_BAD_REQUEST)
+        if (connected && !method.equals("HEAD") && responseCode >= HTTP_BAD_REQUEST)
             return uis;
         return null;
     }
@@ -699,12 +699,12 @@
         }
 
         // they are requesting a stream to write to. This implies a POST method
-        if (method == "GET") {
+        if (method.equals("GET")) {
             method = "POST";
         }
         
         // If the request method is neither PUT or POST, then you're not writing
-        if (method != "PUT" && method != "POST") {
+        if (!method.equals("PUT") && !method.equals("POST")) {
             throw new ProtocolException(Msg.getString("K008f", method));
         }
 
@@ -848,7 +848,7 @@
             }
         } while (getResponseCode() == 100);
 
-        if (method == "HEAD" || (responseCode >= 100 && responseCode < 200)
+        if (method.equals("HEAD") || (responseCode >= 100 && responseCode <
200)
                 || responseCode == HTTP_NO_CONTENT
                 || responseCode == HTTP_NOT_MODIFIED) {
             closeSocket();

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java.injected/java/net/HttpURLConnectionAccessor.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java.injected/java/net/HttpURLConnectionAccessor.java?rev=408876&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java.injected/java/net/HttpURLConnectionAccessor.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java.injected/java/net/HttpURLConnectionAccessor.java
Tue May 23 04:56:37 2006
@@ -0,0 +1,27 @@
+/*
+ *  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 java.net;
+
+/**
+ * Support class for org.apache.harmony.tests.internal.net.www.protocol.http.HttpURLConnectionTest
+ */
+public class HttpURLConnectionAccessor {
+
+    public static void setRequestMethod(HttpURLConnection c, String method) {
+        c.method = method;
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java?rev=408876&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java
Tue May 23 04:56:37 2006
@@ -0,0 +1,88 @@
+/*
+ *  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.tests.internal.net.www.protocol.http;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.HttpURLConnectionAccessor;
+import java.net.ServerSocket;
+import java.net.SocketTimeoutException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Tests for <code>HTTPURLConnection</code> class constructors and methods.
+ * 
+ */
+public class HttpURLConnectionTest extends TestCase {
+    
+    //TODO: replace with connection to a mock server
+    Thread httpServer = new Thread(new Runnable() {
+        public void run() {
+            try {
+                ServerSocket ss = new ServerSocket(port);
+                ss.setSoTimeout(1000);
+                try {
+                    ss.accept().close();
+                } catch (SocketTimeoutException ignore) {
+                }
+                ss.close();
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+        }
+    }, "ServerSocket for HttpURLConnectionTest");
+
+    private int port = 34567;
+     
+    public void setUp() throws Exception {
+        super.setUp();
+        httpServer.start();
+    }
+
+    public void tearDown() throws Exception {
+        super.tearDown();
+        httpServer.join();
+    }
+
+    /**
+     * @tests org.apache.harmony.luni.internal.net.www.http.getOutputStream()
+     */
+    public void testGetOutputStream() throws Exception {
+        // Regression for HARMONY-482
+        HttpURLConnection c = (HttpURLConnection) new URL("http://127.0.0.1:"
+                + port).openConnection();
+
+        c.setDoOutput(true);
+        //use new String("POST") instead of simple "POST" to obtain other 
+        //object instances then those that are in HttpURLConnection classes 
+        HttpURLConnectionAccessor.setRequestMethod(c, new String("POST"));
+        c.getOutputStream();
+
+        //use new String("PUT") instead of simple "PUT" to obtain other 
+        //object instances then those that are in HttpURLConnection classes 
+        HttpURLConnectionAccessor.setRequestMethod(c, new String("PUT"));
+        c.getOutputStream();
+
+        //use new String("GET") instead of simple "GET" to obtain other 
+        //object instances then those that are in HttpURLConnection classes 
+        HttpURLConnectionAccessor.setRequestMethod(c, new String("GET"));
+        c.getOutputStream();
+    }
+}



Mime
View raw message