Docx4j article (#2714)

* add docx4j dependencies

* Add image.jpg (docx4j)

* add Docx4j example

* Add docx4j test

* Remove unused import

* Fix typo (baeldung instead of baledung)
This commit is contained in:
nabyla
2017-10-08 11:47:15 +01:00
committed by Grzegorz Piwowarek
parent 9e273b1474
commit 26508f3104
4 changed files with 140 additions and 0 deletions
@@ -0,0 +1,24 @@
package com.baeldung.docx;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.Test;
public class Docx4jReadAndWriteTest {
String imagePath = "src/main/resources/image.jpg";
String outputPath = "helloWorld.docx";
@Test
public void givenWordPackage_whenTextExist_thenReturnTrue() {
Docx4jExample docx4j = new Docx4jExample();
try {
docx4j.createDocumentPackage(outputPath, imagePath);
assertTrue(docx4j.isTextExist("Hello World!"));
assertTrue(!docx4j.isTextExist("InexistantText"));
} catch (Exception e) {
fail();
}
}
}