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

def test_STOR(self):

    tr = proto_helpers.StringTransport()
    self.client.passive = False
    def generatePort(portCmd):
        portCmd.text = ('PORT    ' + ftp.encodeHostPort('127.0.0.1', 9876))
        portCmd.protocol.makeConnection(tr)
    def cbStore(sender):
        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(), 'STOR    spam\r\n')
        self.transport.clear()
        self.client.lineReceived('150    File    status    okay;    about    to    open    data    connection.')
        sender.transport.write(('x' * 1000))
        sender.finish()
        sender.connectionLost(failure.Failure(error.ConnectionDone('')))
        self.client.lineReceived('226    Transfer    Complete.')
    def cbFinish(ign):
        self.assertEqual(tr.value(), ('x' * 1000))
    self.client.generatePortCommand = generatePort
    self._testLogin()
    (d1, d2) = self.client.storeFile('spam')
    d1.addCallback(cbStore)
    d2.addCallback(cbFinish)
    return defer.gatherResults([d1, d2])
