public static void createLocalDoc(String myDoc) { createLocalDocument(myDoc, "Java2word_allInOne.doc"); }
@Test public void testRegex(){ assertNotNull(new TestUtils()); assertEquals(1, TestUtils.regexCount("leonardo", "leo")); }
private void tableBasicCheckings(String content) { assertEquals(1, TestUtils.regexCount(content, "<w:tbl>")); assertEquals(1, TestUtils.regexCount(content, "</w:tbl>")); assertEquals(2, TestUtils.regexCount(content, "<*w:tblGrid>")); assertEquals(1, TestUtils.regexCount(content, "<w:tblPr>")); assertEquals(1, TestUtils.regexCount(content, "</w:tblPr>")); }
@Ignore @Test public void test93() { IDocument myDoc = new Document2004(); // String xmlTemplate = Utils.readFile("/home/leonardo/Desktop/paulo_93.doc"); //String xmlTemplate = Utils.readFile("/home/leonardo/Desktop/template_branco.xml"); String xmlTemplate = Utils.readFile("/home/leonardo/Desktop/template.doc"); TableV2 tbl = new TableV2(); tbl.addRow(TableRow.with("Simple String cell", "Another String simple cell")); xmlTemplate = replacePh(xmlTemplate, "<w:t><phTabela></w:t>", tbl.getContent()); System.out.println(xmlTemplate.trim()); //System.out.println(tbl.getContent()); //TestUtils.createLocalDoc(xmlTemplate.replace("</w:body>", tbl.getContent() + "</w:body>")); TestUtils.createLocalDoc(xmlTemplate.trim()); }
private void tableBasicCheckings(String content) { assertEquals(1, TestUtils.regexCount(content, "<w:tbl>")); assertEquals(1, TestUtils.regexCount(content, "</w:tbl>")); assertEquals(2, TestUtils.regexCount(content, "<*w:tblGrid>")); assertEquals(1, TestUtils.regexCount(content, "<w:tblPr>")); assertEquals(1, TestUtils.regexCount(content, "</w:tblPr>")); }
TestUtils.createLocalDoc(xmlTemplate);
private void verifyStyles(IElement e) { assertEquals(2, TestUtils.regexCount(e.getContent(), "<*w:rPr>")); assertEquals(1, TestUtils.regexCount(e.getContent(), "<w:jc w:val=\"center\" />")); //default is left assertEquals(1, TestUtils.regexCount(e.getContent(), "<w:b/>")); assertEquals(1, TestUtils.regexCount(e.getContent(), "<w:i/>")); }
public static void createLocalDoc(String myDoc) { createLocalDocument(myDoc, "Java2word_allInOne.doc"); }
TestUtils.createLocalDoc(myDoc.getContent());
private void doBasicChecking(IElement par, String value) { assertEquals(1, TestUtils.regexCount(par.getContent(), "<w:r>")); assertEquals(1, TestUtils.regexCount(par.getContent(), "<w:t>" + value + "</w:t>")); assertEquals(1, TestUtils.regexCount(par.getContent(), "</w:r>")); assertEquals(1, TestUtils.regexCount(par.getContent(), "<w:rPr>")); assertEquals(1, TestUtils.regexCount(par.getContent(), "</w:rPr>")); }
public static void createLocalDoc(String myDoc, String fileName) { if("".equals(fileName) || fileName == null) { fileName = "Java2word_allInOne.doc"; } createLocalDocument(myDoc, fileName); }
TestUtils.createLocalDoc(myDoc.getContent());
@Test(expected = IllegalArgumentException.class) public void testRegexNull02(){ assertEquals(0, TestUtils.regexCount(null, "xxx")); }
public static void createLocalDoc(String myDoc, String fileName) { if("".equals(fileName) || fileName == null) { fileName = "Java2word_allInOne.doc"; } createLocalDocument(myDoc, fileName); }
@Test(expected = IllegalArgumentException.class) public void testRegexNull03(){ assertEquals(0, TestUtils.regexCount(null, null)); }
@Test public void testRegexNotFound(){ assertEquals(0, TestUtils.regexCount("xxxxx xxxx", "leo")); }
@Test(expected = IllegalArgumentException.class) public void testRegexNull01(){ assertEquals(0, TestUtils.regexCount("xxxxxxxxx", null)); }
@Test public void testFromInputStream() throws FileNotFoundException{ InputStream is = new BufferedInputStream( new FileInputStream(Utils.getAppRoot() + "/src/test/resources/dtpick.gif")); Image img = Image.from_STREAM("leo.png", is); assertEquals(2, TestUtils.regexCount(img.getContent(), "<*w:pict>")); assertEquals(2, TestUtils.regexCount(img.getContent(), "<*v:shapetype")); assertEquals(2, TestUtils.regexCount(img.getContent(), "<*v:shape[ >]")); //white space or > assertEquals(2, TestUtils.regexCount(img.getContent(), "wordml")); assertEquals(1, TestUtils.regexCount(img.getContent(), "width:16pt;height:16pt")); assertEquals(1, TestUtils.regexCount(img.getContent(), "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAAD")); }
@Test public void testClasspathImage(){ Image img = Image.from_CLASSPATH("/dtpick.gif"); assertEquals(2, TestUtils.regexCount(img.getContent(), "<*w:pict>")); assertEquals(2, TestUtils.regexCount(img.getContent(), "<*v:shapetype")); assertEquals(2, TestUtils.regexCount(img.getContent(), "<*v:shape[ >]")); //white space or > assertEquals(2, TestUtils.regexCount(img.getContent(), "wordml")); assertEquals(1, TestUtils.regexCount(img.getContent(), "width:16pt;height:16pt")); assertEquals(1, TestUtils.regexCount(img.getContent(), "R0lGODlhEAAQAPMAAKVNSkpNpUpNS")); }
@Test public void sanityTest(){ assertEquals(1, TestUtils.regexCount(heading1.getTemplate(), "<w:p wsp:rsidR*")); assertEquals(1, TestUtils.regexCount(heading1.getTemplate(), "<w:t>[{]value[}]</w:t>")); //it has to have the pace holder assertEquals(1, TestUtils.regexCount(heading1.getTemplate(), "</w:p>")); assertEquals(1, TestUtils.regexCount(heading1.getTemplate(), "<w:pStyle w:val=\"Heading1\" />")); // it has to replace the Type of Heading }