summaryrefslogtreecommitdiffstats
path: root/x-net
diff options
context:
space:
mode:
authorHuahui Wu <hwu@google.com>2010-04-20 16:37:52 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-04-20 16:37:52 -0700
commit5ad219161613be9f5bf5d3acd2720d70595edcc6 (patch)
treef5cfc154b731cda4c2afe7ca351ec43b84f65052 /x-net
parent2f633269e71f3fb0b6248cc695cf37c5cbaf7e60 (diff)
parent3513161ea66a299be4a3a1ca908379ef63d5a6e4 (diff)
downloadlibcore-5ad219161613be9f5bf5d3acd2720d70595edcc6.zip
libcore-5ad219161613be9f5bf5d3acd2720d70595edcc6.tar.gz
libcore-5ad219161613be9f5bf5d3acd2720d70595edcc6.tar.bz2
am 91be9e67: am 9cfe27bd: am 8068ea8d: Update the ssl test so the client reads something from the server. This is needed when cut-through feature is needed as in b/2586347. Dr. No approved in http://b/issue?id=2511073 .
Merge commit '91be9e671d7db5444aa8fa5f0101867ba8a73075' into dalvik-dev * commit '91be9e671d7db5444aa8fa5f0101867ba8a73075': Update the ssl test so the client reads something from the server.
Diffstat (limited to 'x-net')
-rw-r--r--x-net/src/test/java/tests/api/javax/net/ssl/HandshakeCompletedEventTest.java45
-rw-r--r--x-net/src/test/java/tests/api/javax/net/ssl/SSLSessionTest.java22
2 files changed, 51 insertions, 16 deletions
diff --git a/x-net/src/test/java/tests/api/javax/net/ssl/HandshakeCompletedEventTest.java b/x-net/src/test/java/tests/api/javax/net/ssl/HandshakeCompletedEventTest.java
index fa36d0c..aebde6b 100644
--- a/x-net/src/test/java/tests/api/javax/net/ssl/HandshakeCompletedEventTest.java
+++ b/x-net/src/test/java/tests/api/javax/net/ssl/HandshakeCompletedEventTest.java
@@ -500,8 +500,8 @@ public class HandshakeCompletedEventTest extends TestCase {
/**
* Implements a test SSL socket server. It wait for a connection on a given
- * port, requests client authentication (if specified), and read 256 bytes
- * from the socket.
+ * port, requests client authentication (if specified), reads 256 bytes
+ * from the socket, and writes 256 bytes to the socket.
*/
class TestServer implements Runnable {
@@ -551,16 +551,26 @@ public class HandshakeCompletedEventTest extends TestCase {
SSLSocket clientSocket = (SSLSocket)serverSocket.accept();
- InputStream stream = clientSocket.getInputStream();
+ InputStream istream = clientSocket.getInputStream();
for (int i = 0; i < 256; i++) {
- int j = stream.read();
+ int j = istream.read();
if (i != j) {
throw new RuntimeException("Error reading socket, expected " + i + ", got " + j);
}
}
- stream.close();
+ istream.close();
+
+ OutputStream ostream = clientSocket.getOutputStream();
+
+ for (int i = 0; i < 256; i++) {
+ ostream.write(i);
+ }
+
+ ostream.flush();
+ ostream.close();
+
clientSocket.close();
serverSocket.close();
@@ -581,7 +591,8 @@ public class HandshakeCompletedEventTest extends TestCase {
/**
* Implements a test SSL socket client. It open a connection to localhost on
- * a given port and writes 256 bytes to the socket.
+ * a given port, writes 256 bytes to the socket, and reads 256 bytes from the
+ * socket.
*/
class TestClient implements Runnable {
@@ -614,14 +625,26 @@ public class HandshakeCompletedEventTest extends TestCase {
socket.addHandshakeCompletedListener(listener);
socket.startHandshake();
- OutputStream stream = socket.getOutputStream();
+ OutputStream ostream = socket.getOutputStream();
for (int i = 0; i < 256; i++) {
- stream.write(i);
+ ostream.write(i);
}
- stream.flush();
- stream.close();
+ ostream.flush();
+ ostream.close();
+
+ InputStream istream = socket.getInputStream();
+
+ for (int i = 0; i < 256; i++) {
+ int j = istream.read();
+ if (i != j) {
+ throw new RuntimeException("Error reading socket, expected " + i + ", got " + j);
+ }
+ }
+
+ istream.close();
+
socket.close();
} catch (Exception ex) {
@@ -649,7 +672,7 @@ public class HandshakeCompletedEventTest extends TestCase {
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(inputStream, PASSWORD.toCharArray());
inputStream.close();
-
+
String algorithm = KeyManagerFactory.getDefaultAlgorithm();
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(algorithm);
keyManagerFactory.init(keyStore, PASSWORD.toCharArray());
diff --git a/x-net/src/test/java/tests/api/javax/net/ssl/SSLSessionTest.java b/x-net/src/test/java/tests/api/javax/net/ssl/SSLSessionTest.java
index 430d117..384084f 100644
--- a/x-net/src/test/java/tests/api/javax/net/ssl/SSLSessionTest.java
+++ b/x-net/src/test/java/tests/api/javax/net/ssl/SSLSessionTest.java
@@ -706,8 +706,8 @@ public class SSLSessionTest extends TestCase {
/**
* Implements a test SSL socket server. It waits for a connection on a given
- * port, requests client authentication (if specified), and reads
- * from the socket.
+ * port, requests client authentication (if specified), reads from the socket,
+ * and writes to the socket.
*/
class TestServer implements Runnable {
@@ -761,8 +761,16 @@ public class SSLSessionTest extends TestCase {
SSLSocket clientSocket = (SSLSocket)serverSocket.accept();
+ InputStream istream = clientSocket.getInputStream();
+ byte[] buffer = new byte[1024];
+ istream.read(buffer);
+
+ OutputStream ostream = clientSocket.getOutputStream();
+ ostream.write(testData.getBytes());
+ ostream.flush();
+
while (notFinished) {
- clientSocket.getInputStream().read();
+ Thread.currentThread().sleep(500);
}
clientSocket.close();
@@ -788,8 +796,8 @@ public class SSLSessionTest extends TestCase {
}
/**
- * Implements a test SSL socket client. It open a connection to localhost on
- * a given port and writes to the socket.
+ * Implements a test SSL socket client. It opens a connection to localhost on
+ * a given port, writes to the socket, and reads from the socket.
*/
class TestClient implements Runnable {
@@ -826,6 +834,10 @@ public class SSLSessionTest extends TestCase {
ostream.write(testData.getBytes());
ostream.flush();
+ InputStream istream = socket.getInputStream();
+ byte[] buffer = new byte[1024];
+ istream.read(buffer);
+
clientSession = socket.getSession();
while (notFinished) {
Thread.currentThread().sleep(500);