whitespace clean up before fix for BUG-60305
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1767021 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1c2f768b8c
commit
591785e2d2
@ -46,15 +46,21 @@ import org.junit.Test;
|
||||
* Tests that the extractor correctly gets the text out of our sample file
|
||||
*/
|
||||
public final class TestExtractor {
|
||||
/** Extractor primed on the 2 page basic test data */
|
||||
/**
|
||||
* 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";
|
||||
|
||||
/** Extractor primed on the 1 page but text-box'd test data */
|
||||
/**
|
||||
* Extractor primed on the 1 page but text-box'd test data
|
||||
*/
|
||||
private PowerPointExtractor ppe2;
|
||||
private static final String expectText2 = "Hello, World!!!\nI am just a poor boy\nThis is Times New Roman\nPlain Text \n";
|
||||
|
||||
/** Where our embeded files live */
|
||||
/**
|
||||
* Where our embeded files live
|
||||
*/
|
||||
private static POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
|
||||
|
||||
@Before
|
||||
@ -100,31 +106,32 @@ public final class TestExtractor {
|
||||
|
||||
@Test
|
||||
public void testReadBoth() {
|
||||
String[] slText = new String[] {
|
||||
String[] slText = new String[]{
|
||||
"This is a test title\nThis is a test subtitle\nThis is on page 1\n",
|
||||
"This is the title on page 2\nThis is page two\nIt has several blocks of text\nNone of them have formatting\n"
|
||||
};
|
||||
String[] ntText = new String[] {
|
||||
String[] ntText = new String[]{
|
||||
"These are the notes for page 1\n",
|
||||
"These are the notes on page two, again lacking formatting\n"
|
||||
};
|
||||
|
||||
ppe.setSlidesByDefault(true);
|
||||
ppe.setNotesByDefault(false);
|
||||
assertEquals(slText[0]+slText[1], ppe.getText());
|
||||
assertEquals(slText[0] + slText[1], ppe.getText());
|
||||
|
||||
ppe.setSlidesByDefault(false);
|
||||
ppe.setNotesByDefault(true);
|
||||
assertEquals(ntText[0]+ntText[1], ppe.getText());
|
||||
assertEquals(ntText[0] + ntText[1], ppe.getText());
|
||||
|
||||
ppe.setSlidesByDefault(true);
|
||||
ppe.setNotesByDefault(true);
|
||||
assertEquals(slText[0]+slText[1]+"\n"+ntText[0]+ntText[1], ppe.getText());
|
||||
assertEquals(slText[0] + slText[1] + "\n" + ntText[0] + ntText[1], ppe.getText());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that when presented with a PPT file missing the odd
|
||||
* core record, we can still get the rest of the text out
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
@ -146,13 +153,13 @@ public final class TestExtractor {
|
||||
}
|
||||
|
||||
private void ensureTwoStringsTheSame(String exp, String act) {
|
||||
assertEquals(exp.length(),act.length());
|
||||
assertEquals(exp.length(), act.length());
|
||||
char[] expC = exp.toCharArray();
|
||||
char[] actC = act.toCharArray();
|
||||
for(int i=0; i<expC.length; i++) {
|
||||
for (int i = 0; i < expC.length; i++) {
|
||||
assertEquals("Char " + i, expC[i], actC[i]);
|
||||
}
|
||||
assertEquals(exp,act);
|
||||
assertEquals(exp, act);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -200,7 +207,7 @@ public final class TestExtractor {
|
||||
List<OLEShape> shapes = ppe.getOLEShapes();
|
||||
assertEquals("Expected 6 ole shapes in " + path, 6, shapes.size());
|
||||
int num_ppt = 0, num_doc = 0, num_xls = 0;
|
||||
for(OLEShape ole : shapes) {
|
||||
for (OLEShape ole : shapes) {
|
||||
String name = ole.getInstanceName();
|
||||
InputStream data = ole.getObjectData().getData();
|
||||
if ("Worksheet".equals(name)) {
|
||||
@ -397,13 +404,13 @@ public final class TestExtractor {
|
||||
files[1] = npoifsFileSystem.getRoot();
|
||||
|
||||
// Open directly
|
||||
for(DirectoryNode dir : files) {
|
||||
for (DirectoryNode dir : files) {
|
||||
PowerPointExtractor extractor = new PowerPointExtractor(dir);
|
||||
assertEquals(expectText, extractor.getText());
|
||||
}
|
||||
|
||||
// Open via a HWPFDocument
|
||||
for(DirectoryNode dir : files) {
|
||||
for (DirectoryNode dir : files) {
|
||||
HSLFSlideShowImpl slideshow = new HSLFSlideShowImpl(dir);
|
||||
PowerPointExtractor extractor = new PowerPointExtractor(slideshow);
|
||||
assertEquals(expectText, extractor.getText());
|
||||
@ -413,7 +420,7 @@ public final class TestExtractor {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTable() throws Exception{
|
||||
public void testTable() throws Exception {
|
||||
// ppe = new PowerPointExtractor(slTests.openResourceAsStream("54111.ppt"));
|
||||
// String text = ppe.getText();
|
||||
// String target = "TH Cell 1\tTH Cell 2\tTH Cell 3\tTH Cell 4\n"+
|
||||
@ -428,7 +435,7 @@ public final class TestExtractor {
|
||||
ppe = new PowerPointExtractor(slTests.openResourceAsStream("54722.ppt"));
|
||||
String text = ppe.getText();
|
||||
|
||||
String target = "this\tText\tis\twithin\ta\n"+
|
||||
String target = "this\tText\tis\twithin\ta\n" +
|
||||
"table\t1\t2\t3\t4";
|
||||
assertTrue(text.contains(target));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user