FileDocCategorySizeDatePackage
TestSmallDocumentBlockList.javaAPI DocApache Poi 3.0.12713Mon Jan 01 12:39:44 GMT 2007org.apache.poi.poifs.storage

TestSmallDocumentBlockList

public class TestSmallDocumentBlockList extends TestCase
Class to test SmallDocumentBlockList functionality
author
Marc Johnson

Fields Summary
Constructors Summary
public TestSmallDocumentBlockList(String name)
Constructor TestSmallDocumentBlockList

param
name

        super(name);
    
Methods Summary
public static voidmain(java.lang.String[] ignored_args)
main method to run the unit tests

param
ignored_args

        System.out.println(
            "Testing org.apache.poi.poifs.storage.SmallDocumentBlockList");
        junit.textui.TestRunner.run(TestSmallDocumentBlockList.class);
    
public voidtestConstructor()
Test creating a SmallDocumentBlockList

exception
IOException

        byte[] data = new byte[ 2560 ];

        for (int j = 0; j < 2560; j++)
        {
            data[ j ] = ( byte ) j;
        }
        ByteArrayInputStream stream = new ByteArrayInputStream(data);
        RawDataBlock[]       blocks = new RawDataBlock[ 5 ];

        for (int j = 0; j < 5; j++)
        {
            blocks[ j ] = new RawDataBlock(stream);
        }
        SmallDocumentBlockList sdbl =
            new SmallDocumentBlockList(SmallDocumentBlock.extract(blocks));

        // proof we added the blocks
        for (int j = 0; j < 40; j++)
        {
            sdbl.remove(j);
        }
        try
        {
            sdbl.remove(41);
            fail("there should have been an Earth-shattering ka-boom!");
        }
        catch (IOException ignored)
        {

            // it better have thrown one!!
        }