'Test that when a connection is lost, calling a method on a
RemoteReference obtained from it raises L{DeadReferenceError}.'

def test_deadReferenceError(self):

    self.establishClientAndServer()
    rootObjDeferred = self.clientFactory.getRootObject()
    def gotRootObject(rootObj):
        disconnectedDeferred = Deferred()
        rootObj.notifyOnDisconnect(disconnectedDeferred.callback)
        def lostConnection(ign):
            self.assertRaises(pb.DeadReferenceError, rootObj.callRemote, 'method')
        disconnectedDeferred.addCallback(lostConnection)
        self.clientFactory.disconnect()
        self.completeClientLostConnection()
        return disconnectedDeferred
    return rootObjDeferred.addCallback(gotRootObject)
