forked from thombergs/docx-stamper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExpressionWithSurroundingSpacesTest.java
More file actions
54 lines (42 loc) · 2.48 KB
/
ExpressionWithSurroundingSpacesTest.java
File metadata and controls
54 lines (42 loc) · 2.48 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package org.wickedsource.docxstamper;
import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.docx4j.wml.P;
import org.junit.Assert;
import org.junit.Test;
import org.wickedsource.docxstamper.util.ParagraphWrapper;
import java.io.IOException;
import java.io.InputStream;
public class ExpressionWithSurroundingSpacesTest extends AbstractDocx4jTest {
@Test
public void test() throws Docx4JException, IOException {
Context context = new Context();
InputStream template = getClass().getResourceAsStream("ExpressionWithSurroundingSpacesTest.docx");
WordprocessingMLPackage document = stampAndLoad(template, context);
Assert.assertEquals("Before Expression After.", new ParagraphWrapper((P) document.getMainDocumentPart().getContent().get(2)).getText());
Assert.assertEquals("Before Expression After.", new ParagraphWrapper((P) document.getMainDocumentPart().getContent().get(3)).getText());
Assert.assertEquals("Before Expression After.", new ParagraphWrapper((P) document.getMainDocumentPart().getContent().get(4)).getText());
Assert.assertEquals("Before Expression After.", new ParagraphWrapper((P) document.getMainDocumentPart().getContent().get(5)).getText());
Assert.assertEquals("Before Expression After.", new ParagraphWrapper((P) document.getMainDocumentPart().getContent().get(6)).getText());
Assert.assertEquals("Before Expression After.", new ParagraphWrapper((P) document.getMainDocumentPart().getContent().get(7)).getText());
Assert.assertEquals("Before Expression After.", new ParagraphWrapper((P) document.getMainDocumentPart().getContent().get(8)).getText());
}
static class Context {
private String expressionWithLeadingAndTrailingSpace = " Expression ";
private String expressionWithLeadingSpace = " Expression";
private String expressionWithTrailingSpace = "Expression ";
private String expressionWithoutSpaces = "Expression";
public String getExpressionWithLeadingAndTrailingSpace() {
return expressionWithLeadingAndTrailingSpace;
}
public String getExpressionWithLeadingSpace() {
return expressionWithLeadingSpace;
}
public String getExpressionWithTrailingSpace() {
return expressionWithTrailingSpace;
}
public String getExpressionWithoutSpaces() {
return expressionWithoutSpaces;
}
}
}