'When a connection is lost, an informative message should be logged
(see L{getExpectedConnectionLostLogMsg}): an address identifying
the port and the fact that it was closed.'

def test_connectionLostLogMsg(self):

    loggedMessages = []
    def logConnectionLostMsg(eventDict):
        loggedMessages.append(log.textFromEventDict(eventDict))
    reactor = self.buildReactor()
    p = self.getListeningPort(reactor, ServerFactory())
    expectedMessage = self.getExpectedConnectionLostLogMsg(p)
    log.addObserver(logConnectionLostMsg)
    def stopReactor(ignored):
        log.removeObserver(logConnectionLostMsg)
        reactor.stop()
    def doStopListening():
        log.addObserver(logConnectionLostMsg)
        maybeDeferred(p.stopListening).addCallback(stopReactor)
    reactor.callWhenRunning(doStopListening)
    reactor.run()
    self.assertIn(expectedMessage, loggedMessages)
