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

View File

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

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
{