diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java b/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java index b2f408299..12c37bc6b 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java @@ -16,17 +16,6 @@ ==================================================================== */ package org.apache.poi.hwpf.converter; -import static org.apache.poi.POITestCase.assertContains; -import static org.junit.Assert.assertFalse; - -import java.io.StringWriter; - -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - import org.apache.poi.POIDataSamples; import org.apache.poi.hwpf.HWPFDocument; import org.apache.poi.hwpf.usermodel.PictureType; @@ -34,53 +23,59 @@ import org.apache.poi.util.XMLHelper; import org.junit.Test; import org.w3c.dom.Document; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import java.io.StringWriter; + +import static org.apache.poi.POITestCase.assertContains; +import static org.junit.Assert.assertFalse; + /** * Test cases for {@link WordToHtmlConverter} */ -public class TestWordToHtmlConverter -{ - private static String getHtmlText( final String sampleFileName ) - throws Exception - { - return getHtmlText( sampleFileName, false); +public class TestWordToHtmlConverter { + private static String getHtmlText(final String sampleFileName) throws Exception { + return getHtmlText(sampleFileName, false); } - private static String getHtmlText( final String sampleFileName, - boolean emulatePictureStorage ) throws Exception - { - HWPFDocument hwpfDocument = new HWPFDocument( POIDataSamples - .getDocumentInstance().openResourceAsStream( sampleFileName )); + private static String getHtmlText(final String sampleFileName, + boolean emulatePictureStorage) throws Exception { + HWPFDocument hwpfDocument = new HWPFDocument(POIDataSamples + .getDocumentInstance().openResourceAsStream(sampleFileName)); Document newDocument = XMLHelper.getDocumentBuilderFactory().newDocumentBuilder().newDocument(); WordToHtmlConverter wordToHtmlConverter = new WordToHtmlConverter( newDocument); - if ( emulatePictureStorage ) + if (emulatePictureStorage) { - wordToHtmlConverter.setPicturesManager( new PicturesManager() + wordToHtmlConverter.setPicturesManager(new PicturesManager() { @Override - public String savePicture( byte[] content, + public String savePicture(byte[] content, PictureType pictureType, String suggestedName, - float widthInches, float heightInches ) + float widthInches, float heightInches) { return suggestedName; } }); } - wordToHtmlConverter.processDocument( hwpfDocument); + wordToHtmlConverter.processDocument(hwpfDocument); StringWriter stringWriter = new StringWriter(); Transformer transformer = TransformerFactory.newInstance() .newTransformer(); - transformer.setOutputProperty( OutputKeys.INDENT, "yes"); - transformer.setOutputProperty( OutputKeys.ENCODING, "utf-8"); - transformer.setOutputProperty( OutputKeys.METHOD, "html"); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty(OutputKeys.ENCODING, "utf-8"); + transformer.setOutputProperty(OutputKeys.METHOD, "html"); transformer.transform( - new DOMSource( wordToHtmlConverter.getDocument() ), - new StreamResult( stringWriter )); + new DOMSource(wordToHtmlConverter.getDocument()), + new StreamResult(stringWriter)); return stringWriter.toString(); } @@ -88,14 +83,14 @@ public class TestWordToHtmlConverter @Test public void testAIOOBTap() throws Exception { - String result = getHtmlText( "AIOOB-Tap.doc"); - assertContains(result.substring( 0, 6000 ), "
"); assertContains(result, " | "); @@ -278,9 +274,9 @@ public class TestWordToHtmlConverter @Test public void testBug52420() throws Exception { - String result = getHtmlText( "52420.doc"); + String result = getHtmlText("52420.doc"); - assertFalse(result.contains( "FORMTEXT" )); + assertFalse(result.contains("FORMTEXT")); assertContains(result, "\u0417\u0410\u0414\u0410\u041d\u0418\u0415"); assertContains(result, "\u041f\u0440\u0435\u043f\u043e\u0434\u0430\u0432\u0430\u0442\u0435\u043b\u044c"); |