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:
committed by
Grzegorz Piwowarek
parent
9e273b1474
commit
26508f3104
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user