You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gh...@apache.org on 2006/04/12 12:03:29 UTC

svn commit: r393425 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/net/ test/java/tests/api/java/net/

Author: gharley
Date: Wed Apr 12 03:03:21 2006
New Revision: 393425

URL: http://svn.apache.org/viewcvs?rev=393425&view=rev
Log:
HARMONY 301 : Java 5 Enhancement: A new method "setPerformancePreferences" is added in java.net.Socket, SocketImpl and ServerSocket classes.

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ServerSocket.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/SocketImpl.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/ServerSocketTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketImplTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ServerSocket.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ServerSocket.java?rev=393425&r1=393424&r2=393425&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ServerSocket.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ServerSocket.java Wed Apr 12 03:03:21 2006
@@ -1,4 +1,4 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+/* 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.
@@ -41,7 +41,7 @@
 	private boolean isBound = false;
 
 	private boolean isClosed = false;
-
+	
 	/**
 	 * Construct a ServerSocket, which is not bound to any port. The default
 	 * number of pending connections may be backlogged.
@@ -500,4 +500,21 @@
 		checkClosedAndCreate(true);
 		return ((Integer) impl.getOption(SocketOptions.SO_RCVBUF)).intValue();
 	}
+	
+    /**
+	 * sets performance preference for connectionTime,latency and bandwidth
+	 * 
+	 * @param connectionTime
+	 *            the importance of connect time
+	 * @param latency
+	 *            the importance of latency
+	 * @param bandwidth
+	 *            the importance of bandwidth
+	 */
+    public void setPerformancePreferences(int connectionTime, int latency,
+            int bandwidth) {
+        // Our socket implementation only provide one protocol: TCP/IP, so 
+        // we do nothing for this method
+    }
+
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java?rev=393425&r1=393424&r2=393425&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java Wed Apr 12 03:03:21 2006
@@ -1,4 +1,4 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+/* 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.
@@ -1045,5 +1045,20 @@
 			return true;
 		return false;
 	}
-
+    
+    /**
+	 * sets performance preference for connectionTime,latency and bandwidth
+	 * 
+	 * @param connectionTime
+	 *            the importance of connect time
+	 * @param latency
+	 *            the importance of latency
+	 * @param bandwidth
+	 *            the importance of bandwidth
+	 */
+	public void setPerformancePreferences(int connectionTime, int latency,
+            int bandwidth) {
+        // Our socket implementation only provide one protocol: TCP/IP, so 
+        // we do nothing for this method
+    }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/SocketImpl.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/SocketImpl.java?rev=393425&r1=393424&r2=393425&view=diff
==============================================================================
--- 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 Wed Apr 12 03:03:21 2006
@@ -1,4 +1,4 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+/* 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.
@@ -500,8 +500,24 @@
 	 *                when an error occurs sending urgent data
 	 */
 	protected abstract void sendUrgentData(int value) throws IOException;
-
-//	static native boolean supportsUrgentDataImpl(FileDescriptor fd);
+    
+    /**
+     * sets performance preference for connectionTime,latency and bandwidth
+     * defaultly does nothing at all.
+     * @param connectionTime
+     *            the importance of connect time
+     * @param latency
+     *            the importance of latency
+     * @param bandwidth
+     *            the importance of bandwidth
+     */
+    protected void setPerformancePreferences(int connectionTime, int latency,
+            int bandwidth) {
+        // Our socket implementation only provide one protocol: TCP/IP, so 
+        // we do nothing for this method
+    }
+    
+// static native boolean supportsUrgentDataImpl(FileDescriptor fd);
 //
 //	static native boolean sendUrgentDataImpl(FileDescriptor fd, byte value);
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/ServerSocketTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/ServerSocketTest.java?rev=393425&r1=393424&r2=393425&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/ServerSocketTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/ServerSocketTest.java Wed Apr 12 03:03:21 2006
@@ -1,4 +1,4 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+/* 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.
@@ -880,6 +880,14 @@
 		} catch (Exception e) {
 			handleException(e, SO_RCVBUF);
 		}
+	}
+	
+	/*
+	* @tests java.net.ServerSocket#setPerformancePreference()
+	*/
+	public void test_setPerformancePreference_Int_Int_Int() throws Exception {
+		ServerSocket theSocket = new ServerSocket();
+		theSocket.setPerformancePreferences(1,1,1);
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketImplTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketImplTest.java?rev=393425&r1=393424&r2=393425&view=diff
==============================================================================
--- 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 Wed Apr 12 03:03:21 2006
@@ -1,4 +1,4 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+/* 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.
@@ -16,8 +16,13 @@
 package tests.api.java.net;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.OutputStream;
+import java.net.InetAddress;
 import java.net.Socket;
+import java.net.SocketAddress;
+import java.net.SocketException;
+import java.net.SocketImpl;
 
 import tests.support.Support_Configuration;
 
@@ -60,6 +65,71 @@
 			assertTrue("Exception should have been thrown", exception);
 		} finally {
 			System.setProperties(null);
+		}
+	}
+	
+	/*
+	* @tests java.net.SocketImpl#setPerformancePreference()
+	*/
+	public void test_setPerformancePreference_Int_Int_Int() throws Exception {
+		MockSocketImpl theSocket = new MockSocketImpl();
+		theSocket.setPerformancePreference(1,1,1);
+	}
+	
+	
+	// the mock class for test, leave all method empty
+	class MockSocketImpl extends SocketImpl{
+		
+		protected void accept(SocketImpl newSocket) throws IOException {
+		}
+
+		protected int available() throws IOException {
+			return 0;
+		}
+
+		protected void bind(InetAddress address, int port) throws IOException {
+		}
+
+		protected void close() throws IOException {
+		}
+
+		protected void connect(String host, int port) throws IOException {
+		}
+
+		protected void connect(InetAddress address, int port) throws IOException {
+		}
+
+		protected void create(boolean isStreaming) throws IOException {
+		}
+
+		protected InputStream getInputStream() throws IOException {
+			return null;
+		}
+
+		public Object getOption(int optID) throws SocketException {
+			return null;
+		}
+
+		protected OutputStream getOutputStream() throws IOException {
+			return null;
+		}
+
+		protected void listen(int backlog) throws IOException {
+		}
+
+		public void setOption(int optID, Object val) throws SocketException {
+		}
+
+		protected void connect(SocketAddress remoteAddr, int timeout) throws IOException {
+		}
+
+		protected void sendUrgentData(int value) throws IOException {
+		}
+		
+		public void setPerformancePreference(int connectionTime,
+                int latency,
+                int bandwidth){
+			super.setPerformancePreferences(connectionTime, latency, bandwidth);
 		}
 	}
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java?rev=393425&r1=393424&r2=393425&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java Wed Apr 12 03:03:21 2006
@@ -1,4 +1,4 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+/* 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.
@@ -2498,6 +2498,14 @@
 		}
 	}
 
+	/*
+	* @tests java.net.Socket#setPerformancePreference()
+	*/
+	public void test_setPerformancePreference_Int_Int_Int() throws Exception {
+		Socket theSocket = new Socket();
+		theSocket.setPerformancePreferences(1,1,1);
+	}
+	
 	/**
 	 * 
 	 */