From: Nick Burch Date: Wed, 26 Jun 2013 00:49:41 +0000 (+0000) Subject: Convert classes with a assertContains method to using the new POITestCase common... X-Git-Tag: REL_3_10_BETA2~66 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6d63c0d32ee0ef79391528eb2e7d16b1e658cedc;p=poi.git Convert classes with a assertContains method to using the new POITestCase common parent class, which has it there git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1496697 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java b/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java index 104637c27b..b0cf1c3bd0 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java @@ -24,6 +24,7 @@ import java.util.List; import junit.framework.TestCase; import org.apache.poi.POIDataSamples; +import org.apache.poi.POITestCase; import org.apache.poi.hslf.HSLFSlideShow; import org.apache.poi.hslf.model.OLEShape; import org.apache.poi.hslf.usermodel.SlideShow; @@ -36,10 +37,8 @@ import org.apache.poi.util.IOUtils; /** * Tests that the extractor correctly gets the text out of our sample file - * - * @author Nick Burch (nick at torchbox dot com) */ -public final class TestExtractor extends TestCase { +public final class TestExtractor extends POITestCase { /** Extractor primed on the 2 page basic test data */ private PowerPointExtractor ppe; private static final String expectText = "This is a test title\nThis is a test subtitle\nThis is on page 1\nThis is the title on page 2\nThis is page two\nIt has several blocks of text\nNone of them have formatting\n"; @@ -58,12 +57,6 @@ public final class TestExtractor extends TestCase { ppe2 = new PowerPointExtractor(slTests.openResourceAsStream("with_textbox.ppt")); } - private static void assertContains(String haystack, String needle) { - assertContains( - "Unable to find expected text '" + needle + "' in text:\n" + haystack, - haystack, needle - ); - } private static void assertContains(String reason, String haystack, String needle) { assertTrue(reason, haystack.contains(needle)); } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java index 63acbaceb5..fe013f491a 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java @@ -21,23 +21,21 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.FileInputStream; -import junit.framework.TestCase; - +import org.apache.poi.POIDataSamples; +import org.apache.poi.POITestCase; import org.apache.poi.hslf.HSLFSlideShow; import org.apache.poi.hslf.model.Slide; import org.apache.poi.hslf.model.TextBox; import org.apache.poi.hslf.model.TextRun; import org.apache.poi.hslf.record.Record; import org.apache.poi.hslf.record.SlideListWithText; -import org.apache.poi.POIDataSamples; /** * Test that the friendly getters and setters on RichTextRun * behave as expected. * (model.TestTextRun tests the other functionality) - * @author Nick Burch (nick at torchbox dot com) */ -public final class TestRichTextRun extends TestCase { +public final class TestRichTextRun extends POITestCase { private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance(); // SlideShow primed on the test data @@ -77,12 +75,6 @@ public final class TestRichTextRun extends TestCase { ssChinese = new SlideShow(hssChinese); } - private static void assertContains(String haystack, String needle) { - assertTrue( - "Unable to find expected text '" + needle + "' in text:\n" + haystack, - haystack.contains(needle) - ); - } /** * Test the stuff about getting/setting bold * on a non rich text run diff --git a/src/scratchpad/testcases/org/apache/poi/hsmf/TestFixedSizedProperties.java b/src/scratchpad/testcases/org/apache/poi/hsmf/TestFixedSizedProperties.java index e528b625f6..49a04793cf 100644 --- a/src/scratchpad/testcases/org/apache/poi/hsmf/TestFixedSizedProperties.java +++ b/src/scratchpad/testcases/org/apache/poi/hsmf/TestFixedSizedProperties.java @@ -25,9 +25,8 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.TimeZone; -import junit.framework.TestCase; - import org.apache.poi.POIDataSamples; +import org.apache.poi.POITestCase; import org.apache.poi.hsmf.dev.HSMFDump; import org.apache.poi.hsmf.extractor.OutlookTextExtactor; import org.apache.poi.poifs.filesystem.POIFSFileSystem; @@ -36,7 +35,7 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem; * Tests that we can read fixed sized properties, as well as variable * ones, for example Submission Dates */ -public final class TestFixedSizedProperties extends TestCase { +public final class TestFixedSizedProperties extends POITestCase { protected static final String messageSucceeds = "53784_succeeds.msg"; protected static final String messageFails = "53784_fails.msg"; private MAPIMessage mapiMessageSucceeds; @@ -104,18 +103,11 @@ public final class TestFixedSizedProperties extends TestCase { /** * TODO Work out why the Fri 22nd vs Monday 25th problem is occurring and fix */ - public void DISABLEDtestClientSubmitTime() throws Exception { - SimpleDateFormat f = new SimpleDateFormat("E, d MMM yyyy HH:mm:ss"); - f.setTimeZone(TimeZone.getTimeZone("GMT")); - - Calendar clientSubmitTime = mapiMessageSucceeds.getMessageDate(); - assertEquals("Fri, 22 Jun 2012 18:32:54", f.format(clientSubmitTime.getTime())); - } + public void DISABLEDtestClientSubmitTime() throws Exception { + SimpleDateFormat f = new SimpleDateFormat("E, d MMM yyyy HH:mm:ss"); + f.setTimeZone(TimeZone.getTimeZone("GMT")); - private static void assertContains(String haystack, String needle) { - if (haystack.indexOf(needle) > -1) { - return; - } - fail("'" + needle + "' wasn't found in '" + haystack + "'"); + Calendar clientSubmitTime = mapiMessageSucceeds.getMessageDate(); + assertEquals("Fri, 22 Jun 2012 18:32:54", f.format(clientSubmitTime.getTime())); } } diff --git a/src/scratchpad/testcases/org/apache/poi/hsmf/extractor/TestOutlookTextExtractor.java b/src/scratchpad/testcases/org/apache/poi/hsmf/extractor/TestOutlookTextExtractor.java index 1cf9902ded..3d276ce64a 100644 --- a/src/scratchpad/testcases/org/apache/poi/hsmf/extractor/TestOutlookTextExtractor.java +++ b/src/scratchpad/testcases/org/apache/poi/hsmf/extractor/TestOutlookTextExtractor.java @@ -24,28 +24,20 @@ import java.util.Calendar; import java.util.GregorianCalendar; import java.util.TimeZone; -import junit.framework.TestCase; - import org.apache.poi.POIDataSamples; +import org.apache.poi.POITestCase; import org.apache.poi.hsmf.MAPIMessage; import org.apache.poi.poifs.filesystem.POIFSFileSystem; /** * Tests to verify that the text extractor works */ -public final class TestOutlookTextExtractor extends TestCase { +public final class TestOutlookTextExtractor extends POITestCase { private POIDataSamples samples; - public TestOutlookTextExtractor() throws IOException { - samples = POIDataSamples.getHSMFInstance(); - } - - private void assertContains(String haystack, String needle) { - if(haystack.indexOf(needle) > -1) { - return; - } - fail("'" + needle + "' wasn't found in '" + haystack + "'"); - } + public TestOutlookTextExtractor() throws IOException { + samples = POIDataSamples.getHSMFInstance(); + } public void testQuick() throws Exception { POIFSFileSystem simple = new POIFSFileSystem( diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToFoConverter.java b/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToFoConverter.java index d6dd00d846..4bfff59815 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToFoConverter.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToFoConverter.java @@ -27,26 +27,15 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; -import junit.framework.TestCase; - import org.apache.poi.POIDataSamples; +import org.apache.poi.POITestCase; import org.apache.poi.hwpf.HWPFDocument; /** * Test cases for {@link WordToFoConverter} - * - * @author Sergey Vladimirov (vlsergey {at} gmail {dot} com) */ -public class TestWordToFoConverter extends TestCase +public class TestWordToFoConverter extends POITestCase { - private static void assertContains( String result, final String substring ) - { - if ( !result.contains( substring ) ) - fail( "Substring \"" + substring - + "\" not found in the following string: \"" + result - + "\"" ); - } - private static String getFoText( final String sampleFileName ) throws Exception { 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 6d748cd3cd..845c7e9c97 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java @@ -28,25 +28,16 @@ import javax.xml.transform.stream.StreamResult; import junit.framework.TestCase; import org.apache.poi.POIDataSamples; +import org.apache.poi.POITestCase; import org.apache.poi.hwpf.HWPFDocument; import org.apache.poi.hwpf.usermodel.PictureType; import org.w3c.dom.Document; /** * Test cases for {@link WordToHtmlConverter} - * - * @author Sergey Vladimirov (vlsergey {at} gmail {dot} com) */ -public class TestWordToHtmlConverter extends TestCase +public class TestWordToHtmlConverter extends POITestCase { - private static void assertContains( String result, final String substring ) - { - if ( !result.contains( substring ) ) - fail( "Substring \"" + substring - + "\" not found in the following string: \"" + result - + "\"" ); - } - private static String getHtmlText( final String sampleFileName ) throws Exception {