151 |
if(!newIds.contains(bos.getBlockId())) |
if(!newIds.contains(bos.getBlockId())) |
152 |
throw new Error("Id was not added"); |
throw new Error("Id was not added"); |
153 |
} |
} |
154 |
|
|
155 |
|
/** Add a block and check its id. |
156 |
|
*/ |
157 |
|
public void testBlockId(StormPool pool) throws IOException { |
158 |
|
Header822 header = new VerbatimHeader822(); |
159 |
|
header.add("Content-Transfer-Encoding", "binary"); |
160 |
|
header.add("Content-Type","text/plain; charset=UTF-8"); |
161 |
|
header.add("Date", "Tue, 1 Oct 2002 12:30:30 +0000"); |
162 |
|
header.add("X-Injected-By", "benja@joy"); |
163 |
|
|
164 |
|
byte[] body = "foo".getBytes("UTF-8"); |
165 |
|
|
166 |
|
BlockId id = new BlockId( |
167 |
|
"storm:block:01E88CEE7CF19F016EEF00B315C0B930C953DB7EF2"); |
168 |
|
|
169 |
|
BlockOutputStream bos = pool.getBlockOutputStream(header); |
170 |
|
bos.write(body); |
171 |
|
bos.close(); |
172 |
|
|
173 |
|
BlockId |
174 |
|
id1 = bos.getBlockId(), |
175 |
|
id2 = bos.getBlock().getId(); |
176 |
|
|
177 |
|
if(!id.equals(id1)) |
178 |
|
throw new Error("bos.getBlockId() does not match"); |
179 |
|
|
180 |
|
if(!id.equals(id2)) |
181 |
|
throw new Error("bos.getBlock().getId() does not match"); |
182 |
|
} |
183 |
} |
} |