# # Copyright (c) 2003, Benja Fallenstein # # This file is part of Storm. # # Storm is free software; you can redistribute it and/or modify it under # the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Storm is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General # Public License for more details. # # You should have received a copy of the GNU Lesser General # Public License along with Storm; if not, write to the Free # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # # """ 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 org, java def testServers(): s1, s2 = servers p1 = org.nongnu.storm.impl.TransientPool(java.util.Collections.EMPTY_SET) p2 = org.nongnu.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 = org.nongnu.storm.util.CopyUtil.readBytes(bos.getBlock().getInputStream()) b2 = org.nongnu.storm.util.CopyUtil.readBytes(s2.download(url)) assert b1 == b2