package org.apache.poi.hwpf.extractor; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import junit.framework.TestCase; import org.apache.poi.POIDataSamples; import org.apache.poi.hwpf.HWPFDocument; public class TestSprms extends TestCase { /** * Test correct processing of "sprmPJc" by uncompressor */ public void testSprmPJc() throws IOException { InputStream resourceAsStream = POIDataSamples.getDocumentInstance() .openResourceAsStream("Bug49820.doc"); HWPFDocument hwpfDocument = new HWPFDocument(resourceAsStream); assertEquals(1, hwpfDocument.getStyleSheet().getParagraphStyle(8) .getJustification()); resourceAsStream.close(); } /** * Test correct processing of "sprmPJc" by compressor and uncompressor */ public void testSprmPJcResave() throws IOException { InputStream resourceAsStream = POIDataSamples.getDocumentInstance() .openResourceAsStream("Bug49820.doc"); HWPFDocument hwpfDocument = new HWPFDocument(resourceAsStream); resourceAsStream.close(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); hwpfDocument.write(baos); hwpfDocument = new HWPFDocument( new ByteArrayInputStream(baos.toByteArray())); assertEquals(1, hwpfDocument.getStyleSheet().getParagraphStyle(8) .getJustification()); } }