public static void createLocalDoc(String myDoc) { createLocalDocument(myDoc, "Java2word_allInOne.doc"); }
@Test(expected = RuntimeException.class) public void readFileTestException() { String res = Utils.readFile(Utils.getAppRoot() + "/src/test/resources/not_a_file"); assertEquals(1, TestUtils.regexCount(res, "FileNotFoundException")); }
@Test public void sanityTestLocal() throws IOException{ ImageUtils imageUtils = new ImageUtils(); assertNotNull(imageUtils); BufferedImage bufferedImage = ImageIO.read(new File(Utils.getAppRoot() + "/src/test/resources/dtpick.gif")); String hexa = ImageUtils.getImageHexaBase64(bufferedImage, "gif"); assertEquals(1, TestUtils.regexCount(hexa, "R0lGODlhEAAQAPMAAKVNSkpNpUpNSqWmpdbT1v")); }
@Test public void testLocalImageFluent(){ Image img = Image.from_FULL_LOCAL_PATHL(Utils.getAppRoot() + "/src/test/resources/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(), "R0lGODlhEAAQAPMAAKVNSkpNpUpNS"));//just the beginning of... }
@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>")); }
@Test(expected = java.lang.RuntimeException.class) public void testInvalidImage(){ Image img = Image.from_FULL_LOCAL_PATHL(Utils.getAppRoot() + "/src/test/resources/whatever"); }
@Test public void testLocalImage(){ Image img = Image.from_FULL_LOCAL_PATHL(Utils.getAppRoot() + "/src/test/resources/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(), "R0lGODlhEAAQAPMAAKVNSkpNpUpNS"));//just the beginning of... }
@Test public void readFileTest() { String res = Utils.readFile(Utils.getAppRoot() + "/src/test/resources/resources.properties"); assertEquals(1, TestUtils.regexCount(res, "this is a regex test")); }
public static void createLocalDoc(String myDoc) { createLocalDocument(myDoc, "Java2word_allInOne.doc"); }
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>")); }
@Test public void sanityTest() throws IOException{ Image img = Image.from_FULL_LOCAL_PATHL(Utils.getAppRoot() + "/src/test/resources/dtpick.gif"); //Image img = new Image(Utils.getAppRoot() + "/src/test/resources/base2logo.png"); // Image("/Users/leonardo_correa/Desktop/icons_corrup/quote.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")); //for dtPicker.gif assertEquals(1, TestUtils.regexCount(img.getContent(), "R0lGODlhEAAQAPMAAKVNSkpNpUpNSqWmpdbT1v///////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAACH5BAEAAAYALAAAAAAQABAAQwRI0MhJqxmlkLwLyF8hYBpnluJArGzbjkEsB0NtD6PLAjyw\njqeOMANEDVGjm1IJm8WWONLxWDyGQjkdoecjVIOnrzEsKJvPaEEEADs=")); }
public static void createLocalDoc(String myDoc, String fileName) { if("".equals(fileName) || fileName == null) { fileName = "Java2word_allInOne.doc"; } createLocalDocument(myDoc, fileName); }
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>")); }
@Test public void testDefaultSize() throws IOException { Image img = Image.from_FULL_LOCAL_PATHL(Utils.getAppRoot() + "/src/test/resources/base2logo.png"); assertEquals(1, TestUtils.regexCount(img.getContent(), "style=\"width:116pt;height:104pt\"")); }
public static void createLocalDoc(String myDoc, String fileName) { if("".equals(fileName) || fileName == null) { fileName = "Java2word_allInOne.doc"; } createLocalDocument(myDoc, fileName); }
@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 testWidth() throws IOException { Image img = Image.from_FULL_LOCAL_PATHL(Utils.getAppRoot() + "/src/test/resources/base2logo.png"); img.setWidth("120"); assertEquals(0, TestUtils.regexCount(img.getContent(), "style=\"width:116pt;height:104pt\"")); assertEquals(1, TestUtils.regexCount(img.getContent(), "style=\"width:120pt;height:104pt\"")); }
@Test public void testHeight() throws IOException { Image img = Image.from_FULL_LOCAL_PATHL(Utils.getAppRoot() + "/src/test/resources/base2logo.png"); img.setHeight("110"); assertEquals(0, TestUtils.regexCount(img.getContent(), "style=\"width:116pt;height:104pt\"")); assertEquals(1, TestUtils.regexCount(img.getContent(), "style=\"width:116pt;height:110pt\"")); }
@Test public void testWidthAndHeight() throws IOException { Image img = Image.from_FULL_LOCAL_PATHL(Utils.getAppRoot() + "/src/test/resources/base2logo.png"); img.setWidth("121"); img.setHeight("111"); assertEquals(0, TestUtils.regexCount(img.getContent(), "style=\"width:116pt;height:104pt\"")); assertEquals(1, TestUtils.regexCount(img.getContent(), "style=\"width:121pt;height:111pt\"")); }