harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r447288 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/net/ main/java/org/apache/harmony/luni/net/ test/java/tests/api/java/net/
Date Mon, 18 Sep 2006 06:49:59 GMT
Author: pyang
Date: Sun Sep 17 23:49:58 2006
New Revision: 447288

URL: http://svn.apache.org/viewvc?view=rev&rev=447288
Log:
Patch applied for HARMONY-1117 ([classlib][net] Harmony implementation of SocketImpl.getFileDescriptor()
return real object, but RI return null)

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/DatagramSocketImplTest.java
  (with props)
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocketImpl.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/SocketImpl.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainDatagramSocketImpl.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/AllTests.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketImplTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocketImpl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocketImpl.java?view=diff&rev=447288&r1=447287&r2=447288
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocketImpl.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocketImpl.java
Sun Sep 17 23:49:58 2006
@@ -37,7 +37,8 @@
 	 * Constructs an unbound datagram socket implementation.
 	 */
 	public DatagramSocketImpl() {
-		initializeSocket();
+        localPort = -1;
+        receiveTimeout = 0;
 	}
 
 	/**
@@ -126,16 +127,6 @@
 	 *                The exception description.
 	 */
 	protected abstract int getTimeToLive() throws IOException;
-
-	/**
-	 * Allocate a FileDescriptor and flag the localPort, so that a lookup to the
-	 * IP stack is forced in <code>getLocalPort</code>.
-	 */
-	void initializeSocket() {
-		fd = new FileDescriptor();
-		localPort = -1;
-		receiveTimeout = 0;
-	}
 
 	/**
 	 * Add this socket to the multicast group. A socket must join a group before

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/SocketImpl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/SocketImpl.java?view=diff&rev=447288&r1=447287&r2=447288
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/SocketImpl.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/SocketImpl.java
Sun Sep 17 23:49:58 2006
@@ -73,7 +73,6 @@
 	 * @see SocketImplFactory
 	 */
 	public SocketImpl() {
-		initializeSocket();
         this.netImpl = Platform.getNetworkSystem();        
 	}
 
@@ -224,14 +223,6 @@
 	 */
 	protected int getPort() {
 		return port;
-	}
-
-	/**
-	 * Initialize the socket. By default, read & accept operations are blocking.
-	 * The port fields are created with -1 values, to flag them as unset.
-	 */
-	void initializeSocket() {
-		fd = new FileDescriptor();
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainDatagramSocketImpl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainDatagramSocketImpl.java?view=diff&rev=447288&r1=447287&r2=447288
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainDatagramSocketImpl.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainDatagramSocketImpl.java
Sun Sep 17 23:49:58 2006
@@ -107,6 +107,7 @@
 
     public PlainDatagramSocketImpl() {
         super();
+        fd = new FileDescriptor();
     }
 
     @Override

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java?view=diff&rev=447288&r1=447287&r2=447288
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java
Sun Sep 17 23:49:58 2006
@@ -82,6 +82,11 @@
 
     Proxy proxy;
 
+    public PlainSocketImpl() {
+        super();
+        fd = new FileDescriptor();
+    }
+
     @Override
     protected void accept(SocketImpl newImpl) throws IOException {
         if (NetUtil.usingSocks(proxy)) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/AllTests.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/AllTests.java?view=diff&rev=447288&r1=447287&r2=447288
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/AllTests.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/AllTests.java
Sun Sep 17 23:49:58 2006
@@ -36,6 +36,7 @@
 		suite.addTestSuite(ConnectExceptionTest.class);
 		suite.addTestSuite(DatagramPacketTest.class);
 		suite.addTestSuite(DatagramSocketTest.class);
+        suite.addTestSuite(DatagramSocketImplTest.class);
 		suite.addTestSuite(HttpURLConnectionTest.class);
 		suite.addTestSuite(Inet4AddressTest.class);
 		suite.addTestSuite(Inet6AddressTest.class);

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/DatagramSocketImplTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/DatagramSocketImplTest.java?view=auto&rev=447288
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/DatagramSocketImplTest.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/DatagramSocketImplTest.java
Sun Sep 17 23:49:58 2006
@@ -0,0 +1,133 @@
+/* Copyright 1998, 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 tests.api.java.net;
+
+import java.io.FileDescriptor;
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.DatagramSocketImpl;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketAddress;
+import java.net.SocketException;
+
+public class DatagramSocketImplTest extends junit.framework.TestCase {
+    /**
+     * @tests java.net.DatagramSocketImpl#DatagramSocketImpl()
+     */
+    public void test_Constructor() throws Exception {
+        // regression test for Harmony-1117
+        MockDatagramSocketImpl impl = new MockDatagramSocketImpl();
+        assertNull(impl.getFileDescriptor());
+    }
+}
+
+class MockDatagramSocketImpl extends DatagramSocketImpl {
+
+    @Override
+    public FileDescriptor getFileDescriptor() {
+        return super.getFileDescriptor();
+    }
+
+    @Override
+    protected void bind(int port, InetAddress addr) throws SocketException {
+        // empty
+    }
+
+    @Override
+    protected void close() {
+        // empty
+    }
+
+    @Override
+    protected void create() throws SocketException {
+        // empty
+    }
+
+    @Override
+    public Object getOption(int optID) throws SocketException {
+        return null;
+    }
+
+    @Override
+    protected byte getTTL() throws IOException {
+        return 0;
+    }
+
+    @Override
+    protected int getTimeToLive() throws IOException {
+        return 0;
+    }
+
+    @Override
+    protected void join(InetAddress addr) throws IOException {
+        // empty
+    }
+
+    @Override
+    protected void joinGroup(SocketAddress addr, NetworkInterface netInterface)
+            throws IOException {
+        // empty
+    }
+
+    @Override
+    protected void leave(InetAddress addr) throws IOException {
+        // empty
+    }
+
+    @Override
+    protected void leaveGroup(SocketAddress addr, NetworkInterface netInterface)
+            throws IOException {
+        // empty
+    }
+
+    @Override
+    protected int peek(InetAddress sender) throws IOException {
+        return 0;
+    }
+
+    @Override
+    protected int peekData(DatagramPacket pack) throws IOException {
+        return 0;
+    }
+
+    @Override
+    protected void receive(DatagramPacket pack) throws IOException {
+        // empty
+    }
+
+    @Override
+    protected void send(DatagramPacket pack) throws IOException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setOption(int optID, Object val) throws SocketException {
+        // empty
+    }
+
+    @Override
+    protected void setTTL(byte ttl) throws IOException {
+        // empty
+    }
+
+    @Override
+    protected void setTimeToLive(int ttl) throws IOException {
+        // empty
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/DatagramSocketImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketImplTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketImplTest.java?view=diff&rev=447288&r1=447287&r2=447288
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketImplTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketImplTest.java
Sun Sep 17 23:49:58 2006
@@ -15,6 +15,7 @@
 
 package tests.api.java.net;
 
+import java.io.FileDescriptor;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -68,6 +69,12 @@
 		}
 	}
 	
+    public void test_Constructor_fd() throws Exception {
+        // regression test for Harmony-1117
+        MockSocketImpl mockSocketImpl = new MockSocketImpl();
+        assertNull(mockSocketImpl.getFileDescriptor());
+    }
+    
 	/*
 	* @tests java.net.SocketImpl#setPerformancePreference()
 	*/
@@ -131,6 +138,10 @@
                 int bandwidth){
 			super.setPerformancePreferences(connectionTime, latency, bandwidth);
 		}
+
+        public FileDescriptor getFileDescriptor() {
+            return super.getFileDescriptor();
+        }
 	}
 
 	protected void setUp() {



Mime
View raw message