forked from leonardoanalista/java2word
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtils_Test.java
More file actions
83 lines (65 loc) · 2.46 KB
/
Copy pathUtils_Test.java
File metadata and controls
83 lines (65 loc) · 2.46 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package word;
import junit.framework.Assert;
import org.junit.Test;
import word.utils.TestUtils;
import word.utils.Utils;
public class Utils_Test extends Assert {
@Test
public void sanityTest() {
/*
File dir1 = new File(".");
File dir2 = new File("..");
try {
System.out.println("Current dir : " + dir1.getCanonicalPath());
System.out.println("Parent dir : " + dir2.getCanonicalPath());
} catch (Exception e) {
e.printStackTrace();
}
*/
}
@Test
public void getAppRootTest() {
Utils utils = new Utils();
assertNotNull(utils);
assertTrue(Utils.getAppRoot().contains("/java2word"));
}
@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"));
}
@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 testReplaceSpecialCharactersMultiples(){
String original = "íxxxíxxx";
//assertEquals("U+00ED;xxxU+00ED;xxx", Utils.replaceSpecialCharacters(original));
}
@Test
public void testReplaceSpecialCharactersAll(){
String original = "Índio, ";
assertEquals("Índio, ", Utils.replaceSpecialCharacters(original));
original = "Á, É, Í, Ó, Ú";
assertEquals("Á, É, Í, Ó, Ú", Utils.replaceSpecialCharacters(original));
original = "á, é, í, ó, ú";
assertEquals("á, é, í, ó, ú", Utils.replaceSpecialCharacters(original));
}
// @Test
// public void prettyTest01() {
// String str = Utils.pretty("<leo><nada></nada></leo>");
// assertTrue(str.contains("<leo>\n <nada/>"));
// assertEquals(2, TestUtils.regexCount(str, "<*leo>"));
// assertEquals(1, TestUtils.regexCount(str, "<nada/>"));
// }
// @Test(expected = RuntimeException.class)
// public void prettyTestException() {
// String crap = "<leo><nada></leo>";
//
// @SuppressWarnings("unused")
// String str = Utils.pretty(crap);
// assertEquals(crap, crap); // the same crap...
// }
}