FileDocCategorySizeDatePackage
TestStreamBasics.javaAPI DocApache Poi 3.0.16542Tue Jun 19 20:48:40 BST 2007org.apache.poi.hdgf.streams

TestStreamBasics

public class TestStreamBasics extends StreamTest

Fields Summary
public static final byte[]
compressedStreamDCHeader
The header from when compressedStream is decompressed
public static final byte[]
compressedStream
public static final byte[]
uncompressedStream
Constructors Summary
Methods Summary
public voidtestCompressedStream()


	   
		// Create a fake pointer
		Pointer ptr = new TestPointer(true, 0, compressedStream.length, -1, (short)-1);
		// Now the stream
		Stream stream = Stream.createStream(ptr, compressedStream, null, null);
		
		// Check
		assertNotNull(stream.getPointer());
		assertNotNull(stream.getStore());
		assertTrue(stream.getStore() instanceof StreamStore);
		assertTrue(stream.getStore() instanceof CompressedStreamStore);
		assertTrue(stream instanceof UnknownStream);
		
		// Check the stream store
		CompressedStreamStore ss = (CompressedStreamStore)stream.getStore();
		assertEquals(4, ss._getBlockHeader().length);
		assertEquals(compressedStream.length, ss._getCompressedContents().length);
		assertEquals(uncompressedStream.length, ss.getContents().length);
		
		for(int i=0; i<uncompressedStream.length; i++) {
			assertEquals(uncompressedStream[i], ss.getContents()[i]);
		}
	
public voidtestUncompressedStream()

		// Create a fake pointer
		Pointer ptr = new TestPointer(false, 0, uncompressedStream.length, -1, (short)-1);
		// Now the stream
		Stream stream = Stream.createStream(ptr, uncompressedStream, null, null);
		
		// Check
		assertNotNull(stream.getPointer());
		assertNotNull(stream.getStore());
		assertTrue(stream.getStore() instanceof StreamStore);
		assertFalse(stream.getStore() instanceof CompressedStreamStore);
		assertTrue(stream instanceof UnknownStream);