@Test public void testBZip () throws Exception { // Create our serializer KryoSerializer<List<Integer>> serializer = new KryoSerializer<>(new TypeDescriptor(List.class, new TypeDescriptor(Integer.class)), KryoSerializer.Codec.BZIP); // Create a large tile int xN = 256; int yN = 256; int zN = 100; TileIndex index = new TileIndex(0, 0, 0, xN, yN); TileData<List<Integer>> input = new DenseTileData<List<Integer>>(index); for (int x=0; x<xN; ++x) { for (int y=0; y<yN; ++y) { List<Integer> bin = new ArrayList<>(zN); for (int z=0; z<zN; ++z) bin.add((int) Math.floor(Math.random()*1024)); input.setBin(x, y, bin); } } // Write it out ByteArrayOutputStream baos = new ByteArrayOutputStream(); serializer.serialize(input, baos); baos.flush(); baos.close(); // Read it back in ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); TileData<List<Integer>> output = serializer.deserialize(index, bais); assertListTilesEqual(input, output); }
@Test public void testGZip () throws Exception { // Create our serializer KryoSerializer<List<Integer>> serializer = new KryoSerializer<>(new TypeDescriptor(List.class, new TypeDescriptor(Integer.class)), KryoSerializer.Codec.GZIP); // Create a large tile int xN = 256; int yN = 256; int zN = 100; TileIndex index = new TileIndex(0, 0, 0, xN, yN); TileData<List<Integer>> input = new DenseTileData<List<Integer>>(index); for (int x=0; x<xN; ++x) { for (int y=0; y<yN; ++y) { List<Integer> bin = new ArrayList<>(zN); for (int z=0; z<zN; ++z) bin.add((int) Math.floor(Math.random()*1024)); input.setBin(x, y, bin); } } // Write it out ByteArrayOutputStream baos = new ByteArrayOutputStream(); serializer.serialize(input, baos); baos.flush(); baos.close(); // Read it back in ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); TileData<List<Integer>> output = serializer.deserialize(index, bais); assertListTilesEqual(input, output); }
TileData<List<Integer>> output = serializer.deserialize(index, bais); assertListTilesEqual(input, output);