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
This commit is contained in:
Nick Burch 2013-06-26 00:49:41 +00:00
parent 3783080709
commit b3e4741320
6 changed files with 21 additions and 72 deletions

View File

@ -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));
}

View File

@ -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

View File

@ -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;
@ -111,11 +110,4 @@ public final class TestFixedSizedProperties extends TestCase {
Calendar clientSubmitTime = mapiMessageSucceeds.getMessageDate();
assertEquals("Fri, 22 Jun 2012 18:32:54", f.format(clientSubmitTime.getTime()));
}
private static void assertContains(String haystack, String needle) {
if (haystack.indexOf(needle) > -1) {
return;
}
fail("'" + needle + "' wasn't found in '" + haystack + "'");
}
}

View File

@ -24,29 +24,21 @@ 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 void testQuick() throws Exception {
POIFSFileSystem simple = new POIFSFileSystem(
new FileInputStream(samples.getFile("quick.msg"))

View File

@ -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
{

View File

@ -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
{