From c8d61cbfe31d0d170cc00d447174bd886faa4ac7 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Wed, 1 Dec 2021 11:49:25 +0000 Subject: [PATCH] code formatting git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1895454 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/hwpf/usermodel/TestHWPFWrite.java | 16 ++++++++++ .../apache/poi/hpsf/basic/TestHPSFBugs.java | 30 ++++++++----------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java b/poi-scratchpad/src/test/java/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java index 36ad393a51..0f2039677a 100644 --- a/poi-scratchpad/src/test/java/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java +++ b/poi-scratchpad/src/test/java/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java @@ -139,4 +139,20 @@ public final class TestHWPFWrite extends HWPFTestCase { assertThrows(IllegalStateException.class, doc::write); } } + + @Test + void testBug65436() throws IOException { + UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream(); + try (HWPFDocument doc = HWPFTestDataSamples.openSampleFile("SampleDoc.doc")) { + doc + Range r = doc.getRange(); + assertEquals("I am a test document\r", r.getParagraph(0).text()); + doc.write(baos); + } + + try (HWPFDocument doc = new HWPFDocument(baos.toInputStream())) { + Range r = doc.getRange(); + assertEquals("I am a test document\r", r.getParagraph(0).text()); + } + } } diff --git a/poi/src/test/java/org/apache/poi/hpsf/basic/TestHPSFBugs.java b/poi/src/test/java/org/apache/poi/hpsf/basic/TestHPSFBugs.java index 001fc2b238..bd86d39cc2 100644 --- a/poi/src/test/java/org/apache/poi/hpsf/basic/TestHPSFBugs.java +++ b/poi/src/test/java/org/apache/poi/hpsf/basic/TestHPSFBugs.java @@ -17,26 +17,20 @@ package org.apache.poi.hpsf.basic; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; +import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream; +import org.apache.poi.POIDataSamples; +import org.apache.poi.POIDocument; +import org.apache.poi.hpsf.*; +import org.apache.poi.hssf.HSSFTestDataSamples; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.poifs.filesystem.POIFSFileSystem; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.io.InputStream; import java.util.Date; -import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream; -import org.apache.poi.POIDataSamples; -import org.apache.poi.POIDocument; -import org.apache.poi.hpsf.DocumentSummaryInformation; -import org.apache.poi.hpsf.HPSFPropertiesOnlyDocument; -import org.apache.poi.hpsf.NoPropertySetStreamException; -import org.apache.poi.hpsf.PropertySetFactory; -import org.apache.poi.hpsf.SummaryInformation; -import org.apache.poi.hssf.HSSFTestDataSamples; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.poifs.filesystem.POIFSFileSystem; -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; /** * Tests various bugs have been fixed @@ -112,12 +106,12 @@ final class TestHPSFBugs { @Test void test54233() throws IOException, NoPropertySetStreamException { try (InputStream is = _samples.openResourceAsStream("TestNon4ByteBoundary.doc"); - POIFSFileSystem fs = new POIFSFileSystem(is)) { + POIFSFileSystem fs = new POIFSFileSystem(is)) { SummaryInformation si = (SummaryInformation) - PropertySetFactory.create(fs.getRoot(), SummaryInformation.DEFAULT_STREAM_NAME); + PropertySetFactory.create(fs.getRoot(), SummaryInformation.DEFAULT_STREAM_NAME); DocumentSummaryInformation dsi = (DocumentSummaryInformation) - PropertySetFactory.create(fs.getRoot(), DocumentSummaryInformation.DEFAULT_STREAM_NAME); + PropertySetFactory.create(fs.getRoot(), DocumentSummaryInformation.DEFAULT_STREAM_NAME); // Test assertEquals("Microsoft Word 10.0", si.getApplicationName());