@Override public Document2004 encoding(Encoding encoding) { this.encoding = encoding.getValue(); return this; }
@Override public String toString() { return this.getContent(); }
/** * This is an alias to 'getBody().addEle' */ @Override public void addEle(String str) { this.getBody().addEle(str); }
@Test public void testFooterWithNoPageNumber(){ Footer2004 ft = new Footer2004(); ft.showPageNumber(false); ft.addEle(Paragraph.with("p1")); assertEquals(2, TestUtils.regexCount(ft.getContent(), "<*w:ftr")); assertEquals(1, TestUtils.regexCount(ft.getContent(), "<w:t>p1</w:t>")); assertEquals(0, TestUtils.regexCount(ft.getContent(), "<w:rStyle w:val=\"PageNumber\"/>")); }
@Test public void testAaddEleString(){ Body2004 bd = new Body2004(); bd.addEle("<w:p wsp:rsidR=\"008979E8\" wsp:rsidRDefault=\"008979E8\"/>"); //this is a breakline assertEquals(2, TestUtils.regexCount(bd.getContent(), "<*w:body>")); assertEquals(1, TestUtils.regexCount(bd.getContent(), "<w:p wsp:rsidR=\"008979E8\" wsp:rsidRDefault=\"008979E8\"/>")); }
@Test public void testHideHeaderandFooter(){ //this has to be tested in the body... Header2004 hd = new Header2004(); hd.setHideHeaderAndFooterFirstPage(true); assertTrue(hd.getHideHeaderAndFooterFirstPage()); }
@Test public void testAddEleString(){ Header2004 hd = new Header2004(); hd.addEle("<w:t>p1</w:t>"); assertEquals(2, TestUtils.regexCount(hd.getContent(), "<*w:hdr")); assertEquals(1, TestUtils.regexCount(hd.getContent(), "<w:t>p1</w:t>")); }
@Test public void testAddEleString(){ Footer2004 ft = new Footer2004(); ft.addEle("<w:t>p1</w:t>"); assertEquals(2, TestUtils.regexCount(ft.getContent(), "<*w:ftr")); assertEquals(1, TestUtils.regexCount(ft.getContent(), "<w:t>p1</w:t>")); }
@Test public void sanityTest(){ Footer2004 ft = new Footer2004(); assertEquals("", ft.getContent()); }
@Test public void sanityTest(){ Header2004 hd = new Header2004(); assertEquals("", hd.getContent()); }
@Test public void sanityTest(){ Body2004 bd = new Body2004(); assertEquals(2, TestUtils.regexCount(bd.getContent(), "<*w:body>")); }
@Test public void testDefaultEncodingUTF() { IDocument myDoc = new Document2004(); assertEquals(1, TestUtils.regexCount(myDoc.getContent(), "encoding=\"UTF-8\"")); IDocument myDoc02 = new Document2004(); myDoc02.encoding(Encoding.UTF_8); assertEquals(1, TestUtils.regexCount(myDoc02.getContent(), "encoding=\"UTF-8\"")); }
@Test public void testAddEle(){ Body2004 bd = new Body2004(); bd.addEle(new IElement() { @Override public String getContent() { return "I am an element"; } }); assertEquals(2, TestUtils.regexCount(bd.getContent(), "<*w:body>")); assertEquals(1, TestUtils.regexCount(bd.getContent(), "I am an element")); }
/** * This is an alias to 'getBody().addEle' */ @Override public void addEle(IElement e) { this.getBody().addEle(e); }
@Test public void sanityTest() { IDocument myDoc = new Document2004(); assertEquals(myDoc.getContent(), myDoc.getContent()); assertEquals(myDoc.getContent(), myDoc.getContent()); }
@Override public Document2004 encoding(Encoding encoding) { this.encoding = encoding.getValue(); return this; }
@Override public String toString() { return this.getContent(); }
/** * This is an alias to 'getBody().addEle' */ @Override public void addEle(String str) { this.getBody().addEle(str); }
@Test public void testPageOrientationLandscape() { IDocument doc = new Document2004(); doc.setPageOrientationLandscape(); assertEquals(1, TestUtils.regexCount(doc.getContent(), "landscape")); }
/** * This is an alias to 'getBody().addEle' */ @Override public void addEle(IElement e) { this.getBody().addEle(e); }