Index: tests/standalone/io/tls_server_stream_test.dart |
diff --git a/tests/standalone/io/tls_server_test.dart b/tests/standalone/io/tls_server_stream_test.dart |
similarity index 71% |
copy from tests/standalone/io/tls_server_test.dart |
copy to tests/standalone/io/tls_server_stream_test.dart |
index 32792d77aec1487320f526cd98756fa13998aff0..1b4599124288638679bc3137b4b4e2efe94b86b9 100644 |
--- a/tests/standalone/io/tls_server_test.dart |
+++ b/tests/standalone/io/tls_server_stream_test.dart |
@@ -7,33 +7,19 @@ import "dart:io"; |
const SERVER_ADDRESS = "127.0.0.1"; |
const HOST_NAME = "localhost"; |
-void WriteAndClose(Socket socket, String message) { |
- var data = message.charCodes; |
- int written = 0; |
- void write() { |
- written += socket.writeList(data, written, data.length - written); |
- if (written < data.length) { |
- socket.onWrite = write; |
- } else { |
- socket.close(true); |
- } |
- } |
- write(); |
-} |
- |
class TlsTestServer { |
void onConnection(Socket connection) { |
- connection.onConnect = () { |
- numConnections++; |
- }; |
+ numConnections++; |
+ var input = connection.inputStream; |
String received = ""; |
- connection.onData = () { |
- received = received.concat(new String.fromCharCodes(connection.read())); |
+ input.onData = () { |
+ received = received.concat(new String.fromCharCodes(input.read())); |
}; |
- connection.onClosed = () { |
+ input.onClosed = () { |
Expect.isTrue(received.contains("Hello from client ")); |
String name = received.substring(received.indexOf("client ") + 7); |
- WriteAndClose(connection, "Welcome, client $name"); |
+ connection.outputStream.write("Welcome, client $name".charCodes); |
+ connection.outputStream.close(); |
}; |
} |
@@ -60,19 +46,16 @@ class TlsTestServer { |
class TlsTestClient { |
TlsTestClient(int this.port, String this.name) { |
socket = new TlsSocket(HOST_NAME, port); |
- socket.onConnect = this.onConnect; |
- socket.onData = () { |
- reply = reply.concat(new String.fromCharCodes(socket.read())); |
+ numRequests++; |
+ socket.outputStream.write("Hello from client $name".charCodes); |
+ socket.outputStream.close(); |
+ socket.inputStream.onData = () { |
+ reply = reply.concat(new String.fromCharCodes(socket.inputStream.read())); |
}; |
- socket.onClosed = done; |
+ socket.inputStream.onClosed = this.done; |
reply = ""; |
} |
- void onConnect() { |
- numRequests++; |
- WriteAndClose(socket, "Hello from client $name"); |
- } |
- |
void done() { |
Expect.equals("Welcome, client $name", reply); |
numReplies++; |