/* StormPoolTest.java * * Copyright (c) 2002, Anton Feldmann * * You may use and distribute under the terms of either the GNU Lesser * General Public License, either version 2 of the license or, * at your choice, any later version. Alternatively, you may use and * distribute under the terms of the XPL. * * See the LICENSE.lgpl and LICENSE.xpl files for the specific terms of * the licenses. * * This software 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 README * file for more details. * */ /* * Written by Anton Feldmann */ package gzz.storm; import gzz.util.*; import java.io.*; public class StormPoolTest{ public void test(StormPool pool) throws IOException{ BlockOutputStream bos = pool.getBlockOutputStream("text/plain"); OutputStreamWriter osw = new OutputStreamWriter( bos ); osw.write("Hallo, Welt!"); osw.close(); Block b = pool.get(bos.getBlockId()); InputStreamReader isr = new InputStreamReader( b.getInputStream()); char[] array = new char[11]; isr.read(array); if(isr.read() != -1) throw new Error("The block contains too much data!"); if(!(new String(array).equals("Hallo, Welt!"))) throw new Error(); isr.close(); } }