FileDocCategorySizeDatePackage
TestUnicode.javaAPI DocApache Poi 3.0.14280Mon Jan 01 12:39:44 GMT 2007org.apache.poi.hpsf.basic

TestUnicode

public class TestUnicode extends TestCase

Tests whether Unicode string can be read from a DocumentSummaryInformation.

author
Rainer Klute (klute@rainer-klute.de)
since
2002-12-09
version
$Id: TestUnicode.java 489730 2006-12-22 19:18:16Z bayard $

Fields Summary
static final String
POI_FS
static final String[]
POI_FILES
File
data
POIFile[]
poiFiles
Constructors Summary
public TestUnicode(String name)

Constructor

param
name the test case's name




                 
       
    
        super(name);
    
Methods Summary
public static voidmain(java.lang.String[] args)

Runs the test cases stand-alone.

param
args Command-line arguments.

        System.setProperty("HPSF.testdata.path",
                           "./src/testcases/org/apache/poi/hpsf/data");
        junit.textui.TestRunner.run(TestUnicode.class);
    
protected voidsetUp()

Read a the test file from the "data" directory.

exception
FileNotFoundException if the file to be read does not exist.
exception
IOException if any other I/O exception occurs

        final File dataDir =
            new File(System.getProperty("HPSF.testdata.path"));
        data = new File(dataDir, POI_FS);
    
public voidtestPropertySetMethods()

Tests the {@link PropertySet} methods. The test file has two property set: the first one is a {@link SummaryInformation}, the second one is a {@link DocumentSummaryInformation}.

exception
IOException if an I/O exception occurs
exception
HPSFException if an HPSF exception occurs

        POIFile poiFile = Util.readPOIFiles(data, POI_FILES)[0];
        byte[] b = poiFile.getBytes();
        PropertySet ps =
            PropertySetFactory.create(new ByteArrayInputStream(b));
        Assert.assertTrue(ps.isDocumentSummaryInformation());
        Assert.assertEquals(ps.getSectionCount(), 2);
        Section s = (Section) ps.getSections().get(1);
        Assert.assertEquals(s.getProperty(1),
                            new Integer(Constants.CP_UTF16));
        Assert.assertEquals(s.getProperty(2),
                            new Integer(-96070278));
        Assert.assertEquals(s.getProperty(3),
                            "MCon_Info zu Office bei Schreiner");
        Assert.assertEquals(s.getProperty(4),
                            "petrovitsch@schreiner-online.de");
        Assert.assertEquals(s.getProperty(5),
                            "Petrovitsch, Wilhelm");