def testDistrib(self):
    r1 = resource.Resource()
    r1.putChild(b'there', static.Data(b'root', 'text/plain'))
    site1 = server.Site(r1)
    self.f1 = PBServerFactory(distrib.ResourcePublisher(site1))
    self.port1 = reactor.listenTCP(0, self.f1)
    self.sub = distrib.ResourceSubscription('127.0.0.1', self.port1.getHost().port)
    r2 = resource.Resource()
    r2.putChild(b'here', self.sub)
    f2 = MySite(r2)
    self.port2 = reactor.listenTCP(0, f2)
    agent = client.Agent(reactor)
    url = 'http://127.0.0.1:{}/here/there'.format(self.port2.getHost().port)
    url = url.encode('ascii')
    d = agent.request(b'GET', url)
    d.addCallback(client.readBody)
    d.addCallback(self.assertEqual, b'root')
    return d
def testDistrib(self):
    r1 = resource.Resource()
    r1.putChild(b'there', static.Data(b'root', 'text/plain'))
    site1 = server.Site(r1)
    self.f1 = PBServerFactory(distrib.ResourcePublisher(site1))
    self.port1 = reactor.listenTCP(0, self.f1)
    self.sub = distrib.ResourceSubscription('127.0.0.1', self.port1.getHost().port)
    r2 = resource.Resource()
    r2.putChild(b'here', self.sub)
    f2 = MySite(r2)
    self.port2 = reactor.listenTCP(0, f2)
    agent = client.Agent(reactor)
    url = 'http://127.0.0.1:{}/here/there'.format(self.port2.getHost().port)
    url = url.encode('ascii')
    d = agent.request(b'GET', url)
    d.addCallback(client.readBody)
    d.addCallback(self.assertEqual, b'root')
    return d