1 2 17 18 19 package org.apache.poi.hpsf.basic; 20 21 import java.io.ByteArrayInputStream ; 22 import java.io.File ; 23 import java.io.FileNotFoundException ; 24 import java.io.IOException ; 25 26 import junit.framework.Assert; 27 import junit.framework.TestCase; 28 29 import org.apache.poi.hpsf.Constants; 30 import org.apache.poi.hpsf.HPSFException; 31 import org.apache.poi.hpsf.PropertySet; 32 import org.apache.poi.hpsf.PropertySetFactory; 33 import org.apache.poi.hpsf.Section; 34 35 36 37 45 public class TestUnicode extends TestCase 46 { 47 48 static final String POI_FS = "TestUnicode.xls"; 49 static final String [] POI_FILES = new String [] 50 { 51 "\005DocumentSummaryInformation", 52 }; 53 File data; 54 POIFile[] poiFiles; 55 56 57 58 63 public TestUnicode(final String name) 64 { 65 super(name); 66 } 67 68 69 70 76 protected void setUp() throws FileNotFoundException , IOException 77 { 78 final File dataDir = 79 new File (System.getProperty("HPSF.testdata.path")); 80 data = new File (dataDir, POI_FS); 81 } 82 83 84 85 93 public void testPropertySetMethods() throws IOException , HPSFException 94 { 95 POIFile poiFile = Util.readPOIFiles(data, POI_FILES)[0]; 96 byte[] b = poiFile.getBytes(); 97 PropertySet ps = 98 PropertySetFactory.create(new ByteArrayInputStream (b)); 99 Assert.assertTrue(ps.isDocumentSummaryInformation()); 100 Assert.assertEquals(ps.getSectionCount(), 2); 101 Section s = (Section) ps.getSections().get(1); 102 Assert.assertEquals(s.getProperty(1), 103 new Integer (Constants.CP_UTF16)); 104 Assert.assertEquals(s.getProperty(2), 105 new Long (4198897018L)); 106 Assert.assertEquals(s.getProperty(3), 107 "MCon_Info zu Office bei Schreiner"); 108 Assert.assertEquals(s.getProperty(4), 109 "petrovitsch@schreiner-online.de"); 110 Assert.assertEquals(s.getProperty(5), 111 "Petrovitsch, Wilhelm"); 112 } 113 114 115 116 121 public static void main(final String [] args) 122 { 123 System.setProperty("HPSF.testdata.path", 124 "./src/testcases/org/apache/poi/hpsf/data"); 125 junit.textui.TestRunner.run(TestUnicode.class); 126 } 127 128 } 129 | Popular Tags |