/[gzz]/gzz/lava/test/gzz/storm/StormPoolTest.java
ViewVC logotype

Diff of /gzz/lava/test/gzz/storm/StormPoolTest.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by benja, Sat Nov 16 04:38:04 2002 UTC revision 1.12 by benja, Sat Nov 16 05:59:46 2002 UTC
# Line 286  public class StormPoolTest { Line 286  public class StormPoolTest {
286          } catch(FileNotFoundException e) {          } catch(FileNotFoundException e) {
287          }          }
288      }      }
289    
290        /** Test adding a block with an old-style id from a different pool. */
291        public void testAddBlock00(StormPool pool) throws IOException {
292            final byte[] bytes =
293                ("X-Injected-By: hastrup@io\r\n"+
294                 "Date: Sun, 12 Aug 2001 16:13:26 +0000\r\n"+
295                 "Content-Type: application/x-gzigzag-GZZ1\r\n"+
296                 "Content-Transfer-Encoding: binary\r\n"+
297                 "\r\n"+
298                 "GZZ1\n1\n"+
299                 "0000000008000000E8473B08AE0004BE303AB79A49A5918F2E41123D2380983EC246EF82C8581F\n"+
300                 "N\n0\nS\n0\n00\n").getBytes("US-ASCII");
301          
302            final BlockId id = new BlockId("storm:block:0000000008000000E8478C8E0100044374AF00D9DBBA68A5B6A3B9B0FA610AA36135EB49A3B2D1");
303            final BlockId badid = new BlockId(
304                "storm:block:01E88CEE70319F016EEF00B315C0B930C953DB7776");
305    
306            Block orig = new Block() {
307                    public BlockId getId() { return id; }
308                    public StormPool getPool() { return null; }
309                    public Header822 getHeader() { return null; }
310                    public InputStream getInputStream() throws IOException {
311                        return new ByteArrayInputStream("foo".getBytes("US-ASCII"));
312                    }
313                    public InputStream getRawInputStream() {
314                        return new ByteArrayInputStream(bytes);
315                    }
316                };
317    
318            Block badBlock = new Block() {
319                    public BlockId getId() { return badid; }
320                    public StormPool getPool() { return null; }
321                    public Header822 getHeader() { return null; }
322                    public InputStream getInputStream() throws IOException {
323                        return new ByteArrayInputStream("foo".getBytes("US-ASCII"));
324                    }
325                    public InputStream getRawInputStream() {
326                        return new ByteArrayInputStream(bytes);
327                    }
328                };
329    
330            pool.add(orig);
331            Block b = pool.get(id);
332            
333            String s = new String(CopyUtil.readBytes(b.getInputStream()));
334            if(!s.startsWith("GZZ1\n1\n")) throw new Error();
335            if(!b.getHeader().get("X-injected-by").equals("hastrup@io"))
336                throw new Error();
337    
338            try {
339                pool.add(badBlock);
340                throw new Error();
341            } catch(IOException e) {
342            }
343    
344            try {
345                pool.get(badid);
346                throw new Error();
347            } catch(FileNotFoundException e) {
348            }
349        }
350  }  }

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26