forked from thombergs/docx-stamper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFailOnUnresolvedExpressionTest.java
More file actions
35 lines (29 loc) · 1.33 KB
/
FailOnUnresolvedExpressionTest.java
File metadata and controls
35 lines (29 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package org.wickedsource.docxstamper;
import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.junit.Test;
import org.wickedsource.docxstamper.api.UnresolvedExpressionException;
import org.wickedsource.docxstamper.context.NameContext;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
public class FailOnUnresolvedExpressionTest extends AbstractDocx4jTest {
@Test(expected = UnresolvedExpressionException.class)
public void fails() throws Docx4JException, IOException {
NameContext context = new NameContext();
context.setName("Homer");
InputStream template = getClass().getResourceAsStream("FailOnUnresolvedExpressionTest.docx");
DocxStamper stamper = new DocxStamper();
stamper.stamp(template, context, new ByteArrayOutputStream());
}
@Test
public void doesNotFail() throws Docx4JException, IOException {
NameContext context = new NameContext();
context.setName("Homer");
InputStream template = getClass().getResourceAsStream("FailOnUnresolvedExpressionTest.docx");
DocxStamper stamper = new DocxStamperConfiguration()
.setFailOnUnresolvedExpression(false)
.build();
stamper.stamp(template, context, new ByteArrayOutputStream());
// no exception
}
}