'Test the RETR command in non-passive mode.
Like L{test_passiveRETR} but in the configuration where the server
establishes the data connection to the client, rather than the other
way around.'

def test_RETR(self):

    self.client.passive = False
    def generatePort(portCmd):
        portCmd.text = ('PORT    %s' % (ftp.encodeHostPort('127.0.0.1', 9876),))
        portCmd.protocol.makeConnection(proto_helpers.StringTransport())
        portCmd.protocol.dataReceived(('x' * 1000))
        portCmd.protocol.connectionLost(failure.Failure(error.ConnectionDone('')))
    def cbRetr(res, proto):
        self.assertEqual(proto.buffer, ('x' * 1000))
    self.client.generatePortCommand = generatePort
    self._testLogin()
    proto = _BufferingProtocol()
    d = self.client.retrieveFile('spam', proto)
    d.addCallback(cbRetr, proto)
    self.assertEqual(self.transport.value(), ('PORT    %s\r\n' % (ftp.encodeHostPort('127.0.0.1', 9876),)).encode(self.client._encoding))
    self.transport.clear()
    self.client.lineReceived('200    PORT    OK')
    self.assertEqual(self.transport.value(), 'RETR    spam\r\n')
    self.transport.clear()
    self.client.lineReceived('226    Transfer    Complete.')
    return d
