'If a very long string is passed to L{TLSMemoryBIOProtocol.write}, any
trailing part of it which cannot be send immediately is buffered and
sent later.'

def hugeWrite(self, method=TLSv1_METHOD):

    data = 'some    bytes'
    factor = (2 ** 20)
    class SimpleSendingProtocol(Protocol, ):
        def connectionMade(self):
            self.transport.write((data * factor))
    clientFactory = ClientFactory()
    clientFactory.protocol = SimpleSendingProtocol
    clientContextFactory = HandshakeCallbackContextFactory(method=method)
    wrapperFactory = TLSMemoryBIOFactory(clientContextFactory, True, clientFactory)
    sslClientProtocol = wrapperFactory.buildProtocol(None)
    serverProtocol = AccumulatingProtocol((len(data) * factor))
    serverFactory = ServerFactory()
    serverFactory.protocol = (lambda : serverProtocol)
    serverContextFactory = ServerTLSContext(method=method)
    wrapperFactory = TLSMemoryBIOFactory(serverContextFactory, False, serverFactory)
    sslServerProtocol = wrapperFactory.buildProtocol(None)
    connectionDeferred = loopbackAsync(sslServerProtocol, sslClientProtocol)
    def cbConnectionDone(ignored):
        self.assertEqual(''.join(serverProtocol.received), (data * factor))
    connectionDeferred.addCallback(cbConnectionDone)
    return connectionDeferred
