anchor.diff:      });
       return pumpEventQueue().then((_) => expect(assertCount, equals(2)));
     }
  -
  -  static void setUp() {
  -    var inputStream = new StreamController<List<int>>();
  -    inputSink = new IOSink(inputStream);
  -    var outputStream = new StreamController<List<int>>();
  -    outputLineStream = outputStream.stream
  -        .transform((new Utf8Codec()).decoder)
  -        .transform(new LineSplitter());
  -    outputSink = new IOSink(outputStream);
  -    channel = new ByteStreamClientChannel(inputStream.stream, outputSink);
  -  }
   }
   
  +@reflectiveTest
   class ByteStreamServerChannelTest {
  -  static ByteStreamServerChannel channel;
  +  ByteStreamServerChannel channel;
   
     /**
      * Sink that may be used to deliver data to the channel, as though it's
      * coming from the client.
      */
  -  static IOSink inputSink;
  +  IOSink inputSink;
   
     /**
      * Stream of lines sent back to the client by the channel.
      */
  -  static Stream<String> outputLineStream;
  +  Stream<String> outputLineStream;
   
     /**
      * Stream of requests received from the channel via [listen()].
      */
  -  static Stream<Request> requestStream;
  +  Stream<Request> requestStream;
   
     /**
      * Stream of errors received from the channel via [listen()].
      */
  -  static Stream errorStream;
  +  Stream errorStream;
   
     /**
      * Future which is completed when then [listen()] reports [onDone].
      */
  -  static Future doneFuture;
  -
  -  static Future closed() {
  -    return inputSink
  -        .close()
  -        .then((_) => channel.closed.timeout(new Duration(seconds: 1)));
  -  }
  -
  -  static Future listen_invalidJson() {
  -    inputSink.writeln('{"id":');
  -    return inputSink
  -        .flush()
  -        .then((_) => outputLineStream.first.timeout(new Duration(seconds: 1)))
  -        .then((String response) {
  -      var jsonResponse = new JsonCodec().decode(response);
  -      expect(jsonResponse, isMap);
  -      expect(jsonResponse, contains('error'));
  -      expect(jsonResponse['error'], isNotNull);
  -    });
  -  }
  -
  -  static Future listen_invalidRequest() {
  -    inputSink.writeln('{"id":"0"}');
  -    return inputSink
  -        .flush()
  -        .then((_) => outputLineStream.first.timeout(new Duration(seconds: 1)))
  -        .then((String response) {
  -      var jsonResponse = new JsonCodec().decode(response);
  -      expect(jsonResponse, isMap);
  -      expect(jsonResponse, contains('error'));
  -      expect(jsonResponse['error'], isNotNull);
  -    });
  -  }
  -
  -  static Future listen_streamDone() {
  -    return inputSink
  -        .close()
  -        .then((_) => doneFuture.timeout(new Duration(seconds: 1)));
  -  }
  -
  -  static Future listen_streamError() {
  -    var error = new Error();
  -    inputSink.addError(error);
  -    return inputSink
  -        .flush()
  -        .then((_) => errorStream.first.timeout(new Duration(seconds: 1)))
  -        .then((var receivedError) {
  -      expect(receivedError, same(error));
  -    });
  -  }
  -
  -  static Future listen_wellFormedRequest() {
  -    inputSink.writeln('{"id":"0","method":"server.version"}');
  -    return inputSink
  -        .flush()
  -        .then((_) => requestStream.first.timeout(new Duration(seconds: 1)))
  -        .then((Request request) {
  -      expect(request.id, equals("0"));
  -      expect(request.method, equals("server.version"));
  -    });
  -  }
  -
  -  static Future sendNotification() {
  -    channel.sendNotification(new Notification('foo'));
  -    return outputLineStream.first
  -        .timeout(new Duration(seconds: 1))
  -        .then((String notification) {
  -      var jsonNotification = new JsonCodec().decode(notification);
  -      expect(jsonNotification, isMap);
  -      expect(jsonNotification, contains('event'));
  -      expect(jsonNotification['event'], equals('foo'));
  -    });
  -  }
  -
  -  static Future sendResponse() {
  -    channel.sendResponse(new Response('foo'));
  -    return outputLineStream.first
  -        .timeout(new Duration(seconds: 1))
  -        .then((String response) {
  -      var jsonResponse = new JsonCodec().decode(response);
  -      expect(jsonResponse, isMap);
  -      expect(jsonResponse, contains('id'));
  -      expect(jsonResponse['id'], equals('foo'));
  -    });
  -  }
  -
  -  static void setUp() {
  +  Future doneFuture;
  +
  +  void setUp() {
       StreamController<List<int>> inputStream = new StreamController<List<int>>();
       inputSink = new IOSink(inputStream);
       StreamController<List<int>> outputStream =
  
positive.code:     });
    }
  
    static Future listen_notification() {
      List<Notification> notifications = [];
      channel.notificationStream.forEach((n) => notifications.add(n));
      inputSink.writeln('{"event":"server.connected"}');
  
negative.code:       doneCompleter.complete();
      });
    }
  
    test_closed() {
      return inputSink
          .close()
          .then((_) => channel.closed.timeout(new Duration(seconds: 1)));
    }
  
    test_listen_invalidJson() {
      inputSink.writeln('{"id":');
      return inputSink
          .flush()
          .then((_) => outputLineStream.first.timeout(new Duration(seconds: 1)))
          .then((String response) {
        var jsonResponse = new JsonCodec().decode(response);
        expect(jsonResponse, isMap);
        expect(jsonResponse, contains('error'));
        expect(jsonResponse['error'], isNotNull);
      });
    }
  
    test_listen_invalidRequest() {
      inputSink.writeln('{"id":"0"}');
      return inputSink
          .flush()
          .then((_) => outputLineStream.first.timeout(new Duration(seconds: 1)))
          .then((String response) {
        var jsonResponse = new JsonCodec().decode(response);
        expect(jsonResponse, isMap);
        expect(jsonResponse, contains('error'));
        expect(jsonResponse['error'], isNotNull);
      });
    }
  
    test_listen_streamDone() {
      return inputSink
          .close()
          .then((_) => doneFuture.timeout(new Duration(seconds: 1)));
    }
  
    test_listen_streamError() {
      var error = new Error();
      inputSink.addError(error);
      return inputSink
          .flush()
          .then((_) => errorStream.first.timeout(new Duration(seconds: 1)))
          .then((var receivedError) {
        expect(receivedError, same(error));
      });
    }
  
    test_listen_wellFormedRequest() {
      inputSink.writeln('{"id":"0","method":"server.version"}');
      return inputSink
          .flush()
          .then((_) => requestStream.first.timeout(new Duration(seconds: 1)))
          .then((Request request) {
        expect(request.id, equals("0"));
        expect(request.method, equals("server.version"));
      });
    }
  
    test_sendNotification() {
      channel.sendNotification(new Notification('foo'));
      return outputLineStream.first
          .timeout(new Duration(seconds: 1))
          .then((String notification) {
        var jsonNotification = new JsonCodec().decode(notification);
        expect(jsonNotification, isMap);
        expect(jsonNotification, contains('event'));
        expect(jsonNotification['event'], equals('foo'));
      });
    }
  
    test_sendResponse() {
      channel.sendResponse(new Response('foo'));
      return outputLineStream.first
          .timeout(new Duration(seconds: 1))
          .then((String response) {
        var jsonResponse = new JsonCodec().decode(response);
        expect(jsonResponse, isMap);
        expect(jsonResponse, contains('id'));
        expect(jsonResponse['id'], equals('foo'));
      });
    }
  }
  