Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Unified Diff: pkg/analysis_server/test/integration/asynchrony_test.dart

Issue 668953002: Add an integration test to verify that server I/O is asynchronous. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/test/integration/integration_tests.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/integration/asynchrony_test.dart
diff --git a/pkg/analysis_server/test/integration/asynchrony_test.dart b/pkg/analysis_server/test/integration/asynchrony_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..4ae0e19ce28972de4514b438e357e1a198232589
--- /dev/null
+++ b/pkg/analysis_server/test/integration/asynchrony_test.dart
@@ -0,0 +1,70 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library test.integration.analysis.error;
+
+import 'dart:async';
+
+import 'package:unittest/unittest.dart';
+
+import '../reflective_tests.dart';
+import 'integration_tests.dart';
+
+/**
+ * Verify that the server's input and output streams are asynchronous by
+ * attempting to flood its input buffer with commands without listening to
+ * its output buffer for responses. The server should continue to train its
+ * input buffer even though its output buffer is full.
+ *
+ * Once enough commands have been sent, we begin reading from the server's
+ * output buffer, and verify that it responds to the last command.
+ */
+@ReflectiveTestCase()
+class AsynchronyIntegrationTest {
+ /**
+ * Connection to the analysis server.
+ */
+ final Server server = new Server();
+
+ /**
+ * Number of messages to queue up before listening for responses.
+ */
+ static const MESSAGE_COUNT = 10000;
+
+ Future setUp() {
+ return server.start();
+ }
+
+ test_asynchrony() {
+ // Send MESSAGE_COUNT messages to the server without listening for
+ // responses.
+ Future lastMessageResult;
+ for (int i = 0; i < MESSAGE_COUNT; i++) {
+ lastMessageResult = server.send('server.getVersion', null);
+ }
+
+ // Flush the server's standard input stream to verify that it has really
+ // received them all. If the server is blocked waiting for us to read
+ // its responses, the flush will never complete.
+ return server.flushCommands().then((_) {
danrubel 2014/10/22 14:56:14 Is it possible to add a timeout for the flushComma
+
+ // Begin processing responses from the server.
+ server.listenToOutput((String event, params) {
+ // No notifications are expected.
+ fail('Unexpected notification: $event');
+ });
+
+ // Terminate the test when the response to the last message is received.
+ lastMessageResult.then((_) {
+ server.send("server.shutdown", null).then((_) {
+ return server.exitCode;
+ });
+ });
+ });
+ }
+}
+
+main() {
+ runReflectiveTests(AsynchronyIntegrationTest);
+}
« no previous file with comments | « no previous file | pkg/analysis_server/test/integration/integration_tests.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698