public void testZipStreams() throws IOException, ClassNotFoundException {
  final IRawStore store=getStore();
  try {
    final IRawStore strategy=ensureStreamStore(store);
    final IPSOutputStream psout=strategy.getOutputStream();
    ObjectOutputStream outdat=new ObjectOutputStream(new GZIPOutputStream(psout));
    final String blobBit="A bit of a blob...";
    for (int i=0; i < 40000; i++)     outdat.writeObject(blobBit);
    outdat.close();
    long addr=psout.getAddr();
    InputStream instr=strategy.getInputStream(addr);
    ObjectInputStream inobj=new ObjectInputStream(new GZIPInputStream(instr));
    for (int i=0; i < 40000; i++) {
      try {
        final String tst=(String)inobj.readObject();
        assertTrue(blobBit.equals(tst));
      }
 catch (      IOException ioe) {
        fail("Problem at " + i,ioe);
      }
    }
    strategy.delete(addr);
  }
  finally {
    store.destroy();
  }
}

public void testZipStreams ( ) throws IOException , ClassNotFoundException { final IRawStore store = getStore ( ) ; try { final IRawStore strategy = ensureStreamStore ( store ) ; final IPSOutputStream psout = strategy . getOutputStream ( ) ; ObjectOutputStream outdat = new ObjectOutputStream ( new GZIPOutputStream ( psout ) ) ; final String blobBit = "A bit of a blob..." ; for ( int i = 0 ; i < 40000 ; i ++ ) outdat . writeObject ( blobBit ) ; outdat . close ( ) ; long addr = psout . getAddr ( ) ; InputStream instr = strategy . getInputStream ( addr ) ; ObjectInputStream inobj = new ObjectInputStream ( new GZIPInputStream ( instr ) ) ; for ( int i = 0 ; i < 40000 ; i ++ ) { try { final String tst = ( String ) inobj . readObject ( ) ; assertTrue ( blobBit . equals ( tst ) ) ; } catch ( IOException ioe ) { fail ( "Problem at " + i , ioe ) ; } } strategy . delete ( addr ) ; } finally { store . destroy ( ) ; } }
this test exercises the stream interface and serves as an example of stream usage for compressed io .
