'After a connection is disconnected, L{ITransport.write} and
L{ITransport.writeSequence} are no-ops.'

def test_writeAfterDisconnect(self):

    reactor = self.buildReactor()
    finished = []
    serverConnectionLostDeferred = Deferred()
    protocol = (lambda : ClosingLaterProtocol(serverConnectionLostDeferred))
    portDeferred = self.endpoints.server(reactor).listen(ServerFactory.forProtocol(protocol))
    def listening(port):
        msg(('Listening    on    %r' % (port.getHost(),)))
        endpoint = self.endpoints.client(reactor, port.getHost())
        lostConnectionDeferred = Deferred()
        protocol = (lambda : ClosingLaterProtocol(lostConnectionDeferred))
        client = endpoint.connect(ClientFactory.forProtocol(protocol))
        def write(proto):
            msg(('About    to    write    to    %r' % (proto,)))
            proto.transport.write('x')
        client.addCallbacks(write, lostConnectionDeferred.errback)
        def disconnected(proto):
            msg(('%r    disconnected' % (proto,)))
            proto.transport.write('some    bytes    to    get    lost')
            proto.transport.writeSequence(['some', 'more'])
            finished.append(True)
        lostConnectionDeferred.addCallback(disconnected)
        serverConnectionLostDeferred.addCallback(disconnected)
        return gatherResults([lostConnectionDeferred, serverConnectionLostDeferred])
    def onListen():
        portDeferred.addCallback(listening)
        portDeferred.addErrback(err)
        portDeferred.addCallback((lambda ignored: reactor.stop()))
    needsRunningReactor(reactor, onListen)
    self.runReactor(reactor)
    self.assertEqual(finished, [True, True])
