#(c):Benja Fallenstein """ Needs attributes: servers -- a list of two instances of the P2PPool.Server class to be tested. The 'servers' instances must be connected, so that one can download from the other. """ import gzz, java def testServers(): s1, s2 = servers p1 = gzz.storm.impl.TransientPool(java.util.Collections.EMPTY_SET) p2 = gzz.storm.impl.TransientPool(java.util.Collections.EMPTY_SET) s1.setPool(p1); s2.setPool(p2) try: s1.setPool(p1) except java.lang.IllegalStateException: pass else: assert 0 bos = p1.getBlockOutputStream("text/plain") bos.write('foo!') bos.close() url = s1.getURL(bos.getBlockId()) b1 = gzz.util.CopyUtil.readBytes(bos.getBlock().getRawInputStream()) b2 = gzz.util.CopyUtil.readBytes(s2.download(url)) assert b1 == b2