use of org.apache.poi.hwpf.HWPFDocument in project poi by apache.
the class TestRevisionMarkAuthorTable method testEmptyDocument.
/**
* Tests that an empty file doesn't have one
*/
public void testEmptyDocument() {
HWPFDocument doc = HWPFTestDataSamples.openSampleFile("empty.doc");
RevisionMarkAuthorTable rmt = doc.getRevisionMarkAuthorTable();
assertNull(rmt);
}
use of org.apache.poi.hwpf.HWPFDocument in project poi by apache.
the class TestRevisionMarkAuthorTable method testSimpleDocument.
/**
* Tests that we can load a document with
* only simple entries in the table
*/
public void testSimpleDocument() {
HWPFDocument doc = HWPFTestDataSamples.openSampleFile("two_images.doc");
RevisionMarkAuthorTable rmt = doc.getRevisionMarkAuthorTable();
assertNotNull(rmt);
assertEquals(1, rmt.getSize());
assertEquals("Unknown", rmt.getAuthor(0));
assertEquals(null, rmt.getAuthor(1));
assertEquals(null, rmt.getAuthor(2));
assertEquals(null, rmt.getAuthor(3));
}
use of org.apache.poi.hwpf.HWPFDocument in project poi by apache.
the class TestRevisionMarkAuthorTable method testMultipleAuthors.
/**
* Several authors, one of whom has no name
*/
public void testMultipleAuthors() {
HWPFDocument doc = HWPFTestDataSamples.openSampleFile("MarkAuthorsTable.doc");
RevisionMarkAuthorTable rmt = doc.getRevisionMarkAuthorTable();
assertNotNull(rmt);
assertEquals(4, rmt.getSize());
assertEquals("Unknown", rmt.getAuthor(0));
assertEquals("BSanders", rmt.getAuthor(1));
assertEquals(" ", rmt.getAuthor(2));
assertEquals("Ryan Lauck", rmt.getAuthor(3));
assertEquals(null, rmt.getAuthor(4));
assertEquals(null, rmt.getAuthor(5));
assertEquals(null, rmt.getAuthor(6));
}
use of org.apache.poi.hwpf.HWPFDocument in project poi by apache.
the class AbstractWordUtilsTest method testBuildTableCellEdgesArray.
/**
* Test case for {@link AbstractWordUtils#buildTableCellEdgesArray(Table)}
*/
public void testBuildTableCellEdgesArray() {
HWPFDocument document = HWPFTestDataSamples.openSampleFile("table-merges.doc");
final Range range = document.getRange();
Table table = range.getTable(range.getParagraph(0));
int[] result = AbstractWordUtils.buildTableCellEdgesArray(table);
assertEquals(6, result.length);
assertEquals(0000, result[0]);
assertEquals(1062, result[1]);
assertEquals(5738, result[2]);
assertEquals(6872, result[3]);
assertEquals(8148, result[4]);
assertEquals(9302, result[5]);
}
use of org.apache.poi.hwpf.HWPFDocument in project poi by apache.
the class TestHWPFWrite method testWriteNewFile.
/**
* Write to a new file
*/
@Test
public void testWriteNewFile() throws IOException {
HWPFDocument doc = HWPFTestDataSamples.openSampleFile("SampleDoc.doc");
Range r = doc.getRange();
assertEquals("I am a test document\r", r.getParagraph(0).text());
File file = TempFile.createTempFile("TestDocument", ".doc");
doc.write(file);
doc.close();
// Check reading from File and Stream
doc = new HWPFDocument(new FileInputStream(file));
r = doc.getRange();
assertEquals("I am a test document\r", r.getParagraph(0).text());
doc.close();
doc = new HWPFDocument(new POIFSFileSystem(file));
r = doc.getRange();
assertEquals("I am a test document\r", r.getParagraph(0).text());
doc.close();
}
Aggregations