Use assertContains instead of assertTrue(text.contains) for better error messages on failure

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1792009 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2017-04-20 01:28:40 +00:00
parent fc23277dd4
commit 5189011805
12 changed files with 93 additions and 101 deletions

View File

@ -18,6 +18,7 @@ package org.apache.poi.xslf.extractor;
import static org.apache.poi.POITestCase.assertContains; import static org.apache.poi.POITestCase.assertContains;
import static org.apache.poi.POITestCase.assertNotContained; import static org.apache.poi.POITestCase.assertNotContained;
import static org.apache.poi.POITestCase.assertStartsWith;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
@ -64,7 +65,7 @@ public class TestXSLFPowerPointExtractor {
assertTrue(text.length() > 0); assertTrue(text.length() > 0);
// Check Basics // Check Basics
assertTrue(text.startsWith("Lorem ipsum dolor sit amet\n")); assertStartsWith(text, "Lorem ipsum dolor sit amet\n");
assertContains(text, "amet\n\n"); assertContains(text, "amet\n\n");
// Our placeholder master text // Our placeholder master text
@ -221,7 +222,7 @@ public class TestXSLFPowerPointExtractor {
assertTrue(text.length() > 0); assertTrue(text.length() > 0);
// Check comments are there // Check comments are there
assertTrue("Unable to find expected word in text\n" + text, text.contains("TEST")); assertContains(text, "TEST");
extractor.close(); extractor.close();
xml.close(); xml.close();
@ -246,31 +247,16 @@ public class TestXSLFPowerPointExtractor {
String text = extractor.getText(); String text = extractor.getText();
if (extension.equals("thmx")) { if (extension.equals("thmx")) {
// Theme file doesn't have any textual content // Theme file doesn't have any textual content
assertEquals(0, text.length()); assertEquals(filename, 0, text.length());
continue; continue;
} }
assertTrue(text.length() > 0); assertTrue(filename, text.length() > 0);
assertTrue( assertContains(filename, text, "Attachment Test");
"Text missing for " + filename + "\n" + text, assertContains(filename, text, "This is a test file data with the same content");
text.contains("Attachment Test") assertContains(filename, text, "content parsing");
); assertContains(filename, text, "Different words to test against");
assertTrue( assertContains(filename, text, "Mystery");
"Text missing for " + filename + "\n" + text,
text.contains("This is a test file data with the same content")
);
assertTrue(
"Text missing for " + filename + "\n" + text,
text.contains("content parsing")
);
assertTrue(
"Text missing for " + filename + "\n" + text,
text.contains("Different words to test against")
);
assertTrue(
"Text missing for " + filename + "\n" + text,
text.contains("Mystery")
);
extractor.close(); extractor.close();
xml.close(); xml.close();

View File

@ -18,6 +18,8 @@
package org.apache.poi.xssf.extractor; package org.apache.poi.xssf.extractor;
import static org.apache.poi.POITestCase.assertContains; import static org.apache.poi.POITestCase.assertContains;
import static org.apache.poi.POITestCase.assertStartsWith;
import static org.apache.poi.POITestCase.assertEndsWith;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
@ -49,8 +51,8 @@ public class TestXSSFBEventBasedExcelExtractor {
assertTrue(text.length() > 0); assertTrue(text.length() > 0);
// Check sheet names // Check sheet names
assertTrue(text.startsWith("Sheet1")); assertStartsWith(text, "Sheet1");
assertTrue(text.endsWith("Sheet3\n")); assertEndsWith(text, "Sheet3\n");
// Now without, will have text // Now without, will have text
extractor.setIncludeSheetNames(false); extractor.setIncludeSheetNames(false);

View File

@ -18,6 +18,8 @@
package org.apache.poi.xssf.extractor; package org.apache.poi.xssf.extractor;
import static org.apache.poi.POITestCase.assertContains; import static org.apache.poi.POITestCase.assertContains;
import static org.apache.poi.POITestCase.assertStartsWith;
import static org.apache.poi.POITestCase.assertEndsWith;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
@ -55,8 +57,8 @@ public class TestXSSFEventBasedExcelExtractor {
assertTrue(text.length() > 0); assertTrue(text.length() > 0);
// Check sheet names // Check sheet names
assertTrue(text.startsWith("Sheet1")); assertStartsWith(text, "Sheet1");
assertTrue(text.endsWith("Sheet3\n")); assertEndsWith(text, "Sheet3\n");
// Now without, will have text // Now without, will have text
extractor.setIncludeSheetNames(false); extractor.setIncludeSheetNames(false);
@ -116,10 +118,10 @@ public class TestXSSFEventBasedExcelExtractor {
assertTrue(text.length() > 0); assertTrue(text.length() > 0);
// Might not have all formatting it should do! // Might not have all formatting it should do!
assertTrue(text.startsWith( assertStartsWith(text,
"Avgtxfull\n" + "Avgtxfull\n" +
"(iii) AVERAGE TAX RATES ON ANNUAL" "(iii) AVERAGE TAX RATES ON ANNUAL"
)); );
extractor.close(); extractor.close();
} }
@ -166,7 +168,7 @@ public class TestXSSFEventBasedExcelExtractor {
new POITextExtractor[] { ooxmlExtractor, ole2Extractor }; new POITextExtractor[] { ooxmlExtractor, ole2Extractor };
for (POITextExtractor extractor : extractors) { for (POITextExtractor extractor : extractors) {
String text = extractor.getText().replaceAll("[\r\t]", ""); String text = extractor.getText().replaceAll("[\r\t]", "");
assertTrue(text.startsWith("First Sheet\nTest spreadsheet\n2nd row2nd row 2nd column\n")); assertStartsWith(text, "First Sheet\nTest spreadsheet\n2nd row2nd row 2nd column\n");
Pattern pattern = Pattern.compile(".*13(\\.0+)?\\s+Sheet3.*", Pattern.DOTALL); Pattern pattern = Pattern.compile(".*13(\\.0+)?\\s+Sheet3.*", Pattern.DOTALL);
Matcher m = pattern.matcher(text); Matcher m = pattern.matcher(text);
assertTrue(m.matches()); assertTrue(m.matches());

View File

@ -19,6 +19,8 @@
package org.apache.poi.xssf.streaming; package org.apache.poi.xssf.streaming;
import static org.apache.poi.POITestCase.assertStartsWith;
import static org.apache.poi.POITestCase.assertEndsWith;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
@ -245,8 +247,8 @@ public final class TestSXSSFWorkbook extends BaseTestXWorkbook {
SheetDataWriter wr = sh.getSheetDataWriter(); SheetDataWriter wr = sh.getSheetDataWriter();
assertTrue(wr.getClass() == SheetDataWriter.class); assertTrue(wr.getClass() == SheetDataWriter.class);
File tmp = wr.getTempFile(); File tmp = wr.getTempFile();
assertTrue(tmp.getName().startsWith("poi-sxssf-sheet")); assertStartsWith(tmp.getName(), "poi-sxssf-sheet");
assertTrue(tmp.getName().endsWith(".xml")); assertEndsWith(tmp.getName(), ".xml");
assertTrue(wb.dispose()); assertTrue(wb.dispose());
wb.close(); wb.close();
@ -256,8 +258,8 @@ public final class TestSXSSFWorkbook extends BaseTestXWorkbook {
wr = sh.getSheetDataWriter(); wr = sh.getSheetDataWriter();
assertTrue(wr.getClass() == GZIPSheetDataWriter.class); assertTrue(wr.getClass() == GZIPSheetDataWriter.class);
tmp = wr.getTempFile(); tmp = wr.getTempFile();
assertTrue(tmp.getName().startsWith("poi-sxssf-sheet-xml")); assertStartsWith(tmp.getName(), "poi-sxssf-sheet-xml");
assertTrue(tmp.getName().endsWith(".gz")); assertEndsWith(tmp.getName(), ".gz");
assertTrue(wb.dispose()); assertTrue(wb.dispose());
wb.close(); wb.close();

View File

@ -19,6 +19,7 @@ package org.apache.poi.xwpf.usermodel;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.apache.poi.POITestCase.assertContains;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -96,20 +97,20 @@ public final class TestXWPFSDT {
List<AbstractXWPFSDT> sdts = extractAllSDTs(doc); List<AbstractXWPFSDT> sdts = extractAllSDTs(doc);
String text = sdts.get(0).getContent().getText(); String text = sdts.get(0).getContent().getText();
assertEquals(2, sdts.size()); assertEquals(2, sdts.size());
assertTrue(text.indexOf("Test") > -1); assertContains(text, "Test");
text = sdts.get(1).getContent().getText(); text = sdts.get(1).getContent().getText();
assertTrue(text.indexOf("Test Subtitle") > -1); assertContains(text, "Test Subtitle");
assertTrue(text.indexOf("Test User") > -1); assertContains(text, "Test User");
assertTrue(text.indexOf("Test") < text.indexOf("Test Subtitle")); assertTrue(text.indexOf("Test") < text.indexOf("Test Subtitle"));
doc = XWPFTestDataSamples.openSampleDocument("Bug54771b.docx"); doc = XWPFTestDataSamples.openSampleDocument("Bug54771b.docx");
sdts = extractAllSDTs(doc); sdts = extractAllSDTs(doc);
assertEquals(3, sdts.size()); assertEquals(3, sdts.size());
assertTrue(sdts.get(0).getContent().getText().indexOf("Test") > -1); assertContains(sdts.get(0).getContent().getText(), "Test");
assertTrue(sdts.get(1).getContent().getText().indexOf("Test Subtitle") > -1); assertContains(sdts.get(1).getContent().getText(), "Test Subtitle");
assertTrue(sdts.get(2).getContent().getText().indexOf("Test User") > -1); assertContains(sdts.get(2).getContent().getText(), "Test User");
} }

View File

@ -17,9 +17,9 @@
package org.apache.poi.hpbf.extractor; package org.apache.poi.hpbf.extractor;
import static org.apache.poi.POITestCase.assertEndsWith;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -179,9 +179,9 @@ public final class TestPublisherTextExtractor {
ext.close(); ext.close();
sample.close(); sample.close();
assertTrue(text.endsWith("<http://poi.apache.org/>\n" assertEndsWith(text, "<http://poi.apache.org/>\n"
+ "<C:\\Documents and Settings\\Nick\\My Documents\\Booleans.xlsx>\n" + "<C:\\Documents and Settings\\Nick\\My Documents\\Booleans.xlsx>\n"
+ "<>\n" + "<mailto:dev@poi.apache.org?subject=HPBF>\n" + "<>\n" + "<mailto:dev@poi.apache.org?subject=HPBF>\n"
+ "<mailto:dev@poi.apache.org?subject=HPBF>\n")); + "<mailto:dev@poi.apache.org?subject=HPBF>\n");
} }
} }

View File

@ -17,6 +17,8 @@
package org.apache.poi.hpbf.model; package org.apache.poi.hpbf.model;
import static org.apache.poi.POITestCase.assertStartsWith;
import static org.apache.poi.POITestCase.assertEndsWith;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
@ -81,8 +83,8 @@ public final class TestQuillContents {
QCTextBit text = (QCTextBit)qc.getBits()[0]; QCTextBit text = (QCTextBit)qc.getBits()[0];
String t = text.getText(); String t = text.getText();
assertTrue(t.startsWith("This is some text on the first page")); assertStartsWith(t, "This is some text on the first page");
assertTrue(t.endsWith("Within doc to page 1\r")); assertEndsWith(t, "Within doc to page 1\r");
doc.close(); doc.close();
} }

View File

@ -432,7 +432,7 @@ public final class TestExtractor {
"Row 3, Cell 1\tRow 3, Cell 2\tRow 3, Cell 3\tRow 3, Cell 4\n"+ "Row 3, Cell 1\tRow 3, Cell 2\tRow 3, Cell 3\tRow 3, Cell 4\n"+
"Row 4, Cell 1\tRow 4, Cell 2\tRow 4, Cell 3\tRow 4, Cell 4\n"+ "Row 4, Cell 1\tRow 4, Cell 2\tRow 4, Cell 3\tRow 4, Cell 4\n"+
"Row 5, Cell 1\tRow 5, Cell 2\tRow 5, Cell 3\tRow 5, Cell 4\n"; "Row 5, Cell 1\tRow 5, Cell 2\tRow 5, Cell 3\tRow 5, Cell 4\n";
assertTrue(text1.contains(target1)); assertContains(text1, target1);
ppe1.close(); ppe1.close();
PowerPointExtractor ppe2 = openExtractor("54722.ppt"); PowerPointExtractor ppe2 = openExtractor("54722.ppt");
@ -440,7 +440,7 @@ public final class TestExtractor {
String target2 = "this\tText\tis\twithin\ta\n" + String target2 = "this\tText\tis\twithin\ta\n" +
"table\t1\t2\t3\t4"; "table\t1\t2\t3\t4";
assertTrue(text2.contains(target2)); assertContains(text2, target2);
ppe2.close(); ppe2.close();
} }

View File

@ -18,6 +18,7 @@
package org.apache.poi.hslf.usermodel; package org.apache.poi.hslf.usermodel;
import static org.apache.poi.POITestCase.assertContains; import static org.apache.poi.POITestCase.assertContains;
import static org.apache.poi.POITestCase.assertStartsWith;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
@ -162,8 +163,8 @@ public final class TestBugs {
assertNotNull(notes); assertNotNull(notes);
String text = HSLFTextParagraph.getRawText(notes.getTextParagraphs().get(0)); String text = HSLFTextParagraph.getRawText(notes.getTextParagraphs().get(0));
String startingPhrase = notesMap.get(slideNumber); String startingPhrase = notesMap.get(slideNumber);
assertTrue("Notes for slide " + slideNumber + " must start with " + assertStartsWith("Notes for slide " + slideNumber + " must start with starting phrase",
startingPhrase , text.startsWith(startingPhrase)); text, startingPhrase);
} }
} }
@ -306,15 +307,15 @@ public final class TestBugs {
List<List<HSLFTextParagraph>> paras = slide.get(0).getTextParagraphs(); List<List<HSLFTextParagraph>> paras = slide.get(0).getTextParagraphs();
assertEquals(4, paras.size()); assertEquals(4, paras.size());
Set<String> txt = new HashSet<String>(); Set<String> expected = new HashSet<String>();
txt.add("\u201CHAPPY BIRTHDAY SCOTT\u201D"); expected.add("\u201CHAPPY BIRTHDAY SCOTT\u201D");
txt.add("Have a HAPPY DAY"); expected.add("Have a HAPPY DAY");
txt.add("PS Nobody is allowed to hassle Scott TODAY\u2026"); expected.add("PS Nobody is allowed to hassle Scott TODAY\u2026");
txt.add("Drinks will be in the Boardroom at 5pm today to celebrate Scott\u2019s B\u2019Day\u2026 See you all there!"); expected.add("Drinks will be in the Boardroom at 5pm today to celebrate Scott\u2019s B\u2019Day\u2026 See you all there!");
for (List<HSLFTextParagraph> para : paras) { for (List<HSLFTextParagraph> para : paras) {
String text = HSLFTextParagraph.getRawText(para); String text = HSLFTextParagraph.getRawText(para);
assertTrue(text, txt.contains(text)); assertTrue(text, expected.contains(text));
} }
ppt.close(); ppt.close();

View File

@ -19,6 +19,7 @@ package org.apache.poi.hwmf;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.apache.poi.POITestCase.assertContains;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import java.awt.Dimension; import java.awt.Dimension;
@ -218,8 +219,8 @@ public class TestHwmfParsing {
} }
} }
String txt = sb.toString(); String txt = sb.toString();
assertTrue(txt.contains("\u041E\u0431\u0449\u043E")); assertContains(txt, "\u041E\u0431\u0449\u043E");
assertTrue(txt.contains("\u0411\u0430\u043B\u0430\u043D\u0441")); assertContains(txt, "\u0411\u0430\u043B\u0430\u043D\u0441");
} }
@Test @Test
@ -246,6 +247,6 @@ public class TestHwmfParsing {
} }
} }
String txt = sb.toString(); String txt = sb.toString();
assertTrue(txt.contains("\u822A\u7A7A\u60C5\u5831\u696D\u52D9\u3078\u306E\uFF27\uFF29\uFF33")); assertContains(txt, "\u822A\u7A7A\u60C5\u5831\u696D\u52D9\u3078\u306E\uFF27\uFF29\uFF33");
} }
} }

View File

@ -17,6 +17,7 @@
package org.apache.poi.hwpf.model; package org.apache.poi.hwpf.model;
import static org.apache.poi.POITestCase.assertStartsWith;
import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
@ -100,8 +101,7 @@ public final class TestTextPieceTable {
assertEquals(339, tp.getEnd()); assertEquals(339, tp.getEnd());
assertEquals(339, tp.characterLength()); assertEquals(339, tp.characterLength());
assertEquals(339, tp.bytesLength()); assertEquals(339, tp.bytesLength());
assertTrue(tp.getStringBuilder().toString() assertStartsWith(tp.getStringBuilder().toString(), "This is a sample word document");
.startsWith("This is a sample word document"));
// Save and re-load // Save and re-load
HWPFDocument docB = saveAndReload(doc); HWPFDocument docB = saveAndReload(doc);
@ -114,8 +114,7 @@ public final class TestTextPieceTable {
assertEquals(339, tp.getEnd()); assertEquals(339, tp.getEnd());
assertEquals(339, tp.characterLength()); assertEquals(339, tp.characterLength());
assertEquals(339, tp.bytesLength()); assertEquals(339, tp.bytesLength());
assertTrue(tp.getStringBuilder().toString() assertStartsWith(tp.getStringBuilder().toString(), "This is a sample word document");
.startsWith("This is a sample word document"));
} }
/** /**

View File

@ -17,6 +17,8 @@
package org.apache.poi.hpsf.extractor; package org.apache.poi.hpsf.extractor;
import static org.apache.poi.POITestCase.assertContains;
import java.io.IOException; import java.io.IOException;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -35,23 +37,21 @@ public final class TestHPSFPropertiesExtractor extends TestCase {
POIFSFileSystem fs = new POIFSFileSystem(_samples.openResourceAsStream("TestMickey.doc")); POIFSFileSystem fs = new POIFSFileSystem(_samples.openResourceAsStream("TestMickey.doc"));
HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs); HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs);
try { try {
ext.getText();
// Check each bit in turn // Check each bit in turn
String sinfText = ext.getSummaryInformationText(); String summary = ext.getSummaryInformationText();
String dinfText = ext.getDocumentSummaryInformationText(); String docsummary = ext.getDocumentSummaryInformationText();
assertTrue(sinfText.indexOf("TEMPLATE = Normal") > -1); assertContains(summary, "TEMPLATE = Normal");
assertTrue(sinfText.indexOf("SUBJECT = sample subject") > -1); assertContains(summary, "SUBJECT = sample subject");
assertTrue(dinfText.indexOf("MANAGER = sample manager") > -1); assertContains(docsummary, "MANAGER = sample manager");
assertTrue(dinfText.indexOf("COMPANY = sample company") > -1); assertContains(docsummary, "COMPANY = sample company");
// Now overall // Now overall
String text = ext.getText(); String text = ext.getText();
assertTrue(text.indexOf("TEMPLATE = Normal") > -1); assertContains(text, "TEMPLATE = Normal");
assertTrue(text.indexOf("SUBJECT = sample subject") > -1); assertContains(text, "SUBJECT = sample subject");
assertTrue(text.indexOf("MANAGER = sample manager") > -1); assertContains(text, "MANAGER = sample manager");
assertTrue(text.indexOf("COMPANY = sample company") > -1); assertContains(text, "COMPANY = sample company");
} finally { } finally {
ext.close(); ext.close();
} }
@ -61,23 +61,21 @@ public final class TestHPSFPropertiesExtractor extends TestCase {
POIFSFileSystem fs = new POIFSFileSystem(_samples.openResourceAsStream("TestUnicode.xls")); POIFSFileSystem fs = new POIFSFileSystem(_samples.openResourceAsStream("TestUnicode.xls"));
HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs); HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs);
try { try {
ext.getText();
// Check each bit in turn // Check each bit in turn
String sinfText = ext.getSummaryInformationText(); String summary = ext.getSummaryInformationText();
String dinfText = ext.getDocumentSummaryInformationText(); String docsummary = ext.getDocumentSummaryInformationText();
assertTrue(sinfText.indexOf("AUTHOR = marshall") > -1); assertContains(summary, "AUTHOR = marshall");
assertTrue(sinfText.indexOf("TITLE = Titel: \u00c4h") > -1); assertContains(summary, "TITLE = Titel: \u00c4h");
assertTrue(dinfText.indexOf("COMPANY = Schreiner") > -1); assertContains(docsummary, "COMPANY = Schreiner");
assertTrue(dinfText.indexOf("SCALE = false") > -1); assertContains(docsummary, "SCALE = false");
// Now overall // Now overall
String text = ext.getText(); String text = ext.getText();
assertTrue(text.indexOf("AUTHOR = marshall") > -1); assertContains(text, "AUTHOR = marshall");
assertTrue(text.indexOf("TITLE = Titel: \u00c4h") > -1); assertContains(text, "TITLE = Titel: \u00c4h");
assertTrue(text.indexOf("COMPANY = Schreiner") > -1); assertContains(text, "COMPANY = Schreiner");
assertTrue(text.indexOf("SCALE = false") > -1); assertContains(text, "SCALE = false");
} finally { } finally {
ext.close(); ext.close();
} }
@ -91,12 +89,12 @@ public final class TestHPSFPropertiesExtractor extends TestCase {
try { try {
// Custom properties are part of the document info stream // Custom properties are part of the document info stream
String dinfText = ext.getDocumentSummaryInformationText(); String dinfText = ext.getDocumentSummaryInformationText();
assertTrue(dinfText.indexOf("Client = sample client") > -1); assertContains(dinfText, "Client = sample client");
assertTrue(dinfText.indexOf("Division = sample division") > -1); assertContains(dinfText, "Division = sample division");
String text = ext.getText(); String text = ext.getText();
assertTrue(text.indexOf("Client = sample client") > -1); assertContains(text, "Client = sample client");
assertTrue(text.indexOf("Division = sample division") > -1); assertContains(text, "Division = sample division");
} finally { } finally {
ext.close(); ext.close();
} }
@ -138,26 +136,24 @@ public final class TestHPSFPropertiesExtractor extends TestCase {
eeText = eeExt.getText(); eeText = eeExt.getText();
} finally { } finally {
eeExt.close(); eeExt.close();
wb.close();
} }
assertEquals(fsText, hwText); assertEquals(fsText, hwText);
assertEquals(fsText, eeText); assertEquals(fsText, eeText);
assertTrue(fsText.indexOf("AUTHOR = marshall") > -1); assertContains(fsText, "AUTHOR = marshall");
assertTrue(fsText.indexOf("TITLE = Titel: \u00c4h") > -1); assertContains(fsText, "TITLE = Titel: \u00c4h");
// Finally tidy
wb.close();
} }
public void test42726() throws IOException { public void test42726() throws IOException {
HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(HSSFTestDataSamples.openSampleWorkbook("42726.xls")); HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(HSSFTestDataSamples.openSampleWorkbook("42726.xls"));
try { try {
String txt = ext.getText(); String txt = ext.getText();
assertTrue(txt.indexOf("PID_AUTHOR") != -1); assertContains(txt, "PID_AUTHOR");
assertTrue(txt.indexOf("PID_EDITTIME") != -1); assertContains(txt, "PID_EDITTIME");
assertTrue(txt.indexOf("PID_REVNUMBER") != -1); assertContains(txt, "PID_REVNUMBER");
assertTrue(txt.indexOf("PID_THUMBNAIL") != -1); assertContains(txt, "PID_THUMBNAIL");
} finally { } finally {
ext.close(); ext.close();
} }