49 |
osw.close() |
osw.close() |
50 |
|
|
51 |
b = pool.get(bos.getBlockId()) |
b = pool.get(bos.getBlockId()) |
52 |
|
|
53 |
assert bos.getBlock().getPool() == b.getPool() == pool |
# We do *not* perform the test on the following line |
54 |
|
# because it is entirely allowable for a pool to |
55 |
|
# proxy block creation requests to another pool, |
56 |
|
# and also to retrieve blocks from a different pool |
57 |
|
# than blocks are written to. |
58 |
|
#assert bos.getBlock().getPool() == b.getPool() == pool |
59 |
|
|
60 |
b.getId().check(CopyUtil.readBytes(b.getInputStream())) |
b.getId().check(CopyUtil.readBytes(b.getInputStream())) |
61 |
|
|
62 |
s = "" |
s = "" |
70 |
|
|
71 |
assert b.getId().getContentType() == "text/plain" |
assert b.getId().getContentType() == "text/plain" |
72 |
|
|
73 |
|
def testCloseBlockOutputStream(): |
74 |
|
"""getBlock() on a non-closed BOS must throw an error""" |
75 |
|
bos = pool.getBlockOutputStream("text/plain") |
76 |
|
|
77 |
|
try: bos.getBlock() |
78 |
|
except: pass |
79 |
|
else: assert 0 |
80 |
|
|
81 |
|
try: bos.getBlockId() |
82 |
|
except: pass |
83 |
|
else: assert 0 |
84 |
|
|
85 |
|
bos.close() |
86 |
|
|
87 |
|
bos.getBlock() |
88 |
|
bos.getBlockId() |
89 |
|
|
90 |
def testBlockTmpFile(): |
def testBlockTmpFile(): |
91 |
""" |
""" |
92 |
Test that creating a blocktmpfile out of a block |
Test that creating a blocktmpfile out of a block |
241 |
|
|
242 |
def testAddBlock(): |
def testAddBlock(): |
243 |
""" |
""" |
244 |
Test adding a block from a different pool. XXX missing!!! |
Test adding a block from a different pool. |
245 |
""" |
""" |
246 |
|
|
247 |
pass |
p2 = org.nongnu.storm.impl.TransientPool(java.util.HashSet()) |
248 |
|
|
249 |
|
bos = p2.getBlockOutputStream("text/plain") |
250 |
|
bos.write("Hi") |
251 |
|
bos.close(); |
252 |
|
|
253 |
|
block = bos.getBlock() |
254 |
|
id = block.getId() |
255 |
|
|
256 |
|
pool.add(block) |
257 |
|
b2 = pool.get(id) |
258 |
|
|
259 |
|
assert b2.getId() == id |
260 |
|
|
261 |
|
stream = b2.getInputStream() |
262 |
|
assert org.nongnu.storm.util.CopyUtil.readString(stream) == "Hi" |
263 |
|
|
264 |
|
|
265 |
|
def testAddBadBlock(): |
266 |
|
""" |
267 |
|
Test adding a spoofed block with a wrong id (XXX missing!) |
268 |
|
Must throw a WrongIdException. |
269 |
|
""" |
270 |
|
pass |