-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathJUnit3Demo.java
More file actions
59 lines (47 loc) · 1.66 KB
/
JUnit3Demo.java
File metadata and controls
59 lines (47 loc) · 1.66 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
import junit.framework.TestCase;
import java.util.HashMap;
import java.util.Map;
///
/// Тесты на JUnit3
///
/// Тестовый класс должен быть наследником TestCase (junit.framework.TestCase)
//-->
public class JUnit3Demo extends TestCase {
private final Map<String, byte[]> toHexStringData = new HashMap<String, byte[]>();
protected static void setUpClass() {
System.out.println("JUnit3Demo.setUpClass");
}
protected static void tearDownClass() {
System.out.println("JUnit3Demo.tearDownClass");
}
public void testIsEmpty() {
boolean actual = StringUtils.isEmpty(null);
assertTrue(actual);
actual = StringUtils.isEmpty("");
assertTrue(actual);
actual = StringUtils.isEmpty(" ");
assertFalse(actual);
actual = StringUtils.isEmpty("some string");
assertFalse(actual);
}
// Аналог @Before из JUnit4
protected void setUp() throws Exception {
toHexStringData.put("", new byte[0]);
toHexStringData.put("01020d112d7f", new byte[]{1, 2, 13, 17, 45, 127});
toHexStringData.put("00fff21180", new byte[]{0, -1, -14, 17, -128});
//...
}
// Аналог @After из JUnit4
protected void tearDown() throws Exception {
toHexStringData.clear();
}
public void testToHexString() {
for (Object o : toHexStringData.keySet()) {
final String expected = (String) o;
final byte[] testData = toHexStringData.get(expected);
final String actual = StringUtils.toHexString(testData);
assertEquals(expected, actual);
}
}
}
//<--