-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathAppTest.java
More file actions
61 lines (53 loc) · 1.48 KB
/
AppTest.java
File metadata and controls
61 lines (53 loc) · 1.48 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
package test;
import junit.framework.*;
import main.App;
public class AppTest extends TestCase {
protected void setUp() {
// put common setup code in here
try {
App app = new App();
app.insertData("Seattle", "WA");
} catch (Exception e) {
System.out.println("Error setting up database for test");
}
}
protected void tearDown() {
// put common cleanup code in here
}
public void testGetDataFromBoth() {
String[] result = {""};
try {
App app = new App();
result = app.getData("Seattle", "WA");
System.out.println("testGetDataFromBoth: " + result[0]);
} catch (Exception e) {
System.out.println("Error testing database");
} finally {
assertEquals("Seattle, WA", result[0]);
}
}
public void testGetDataFromCity() {
String[] result = {""};
try {
App app = new App();
result = app.getData("Seattle", null);
System.out.println("testGetDataFromCity: " + result[0]);
} catch (Exception e) {
System.out.println("Error testing database");
} finally {
assertEquals("Seattle, WA", result[0]);
}
}
public void testGetDataFromState() {
String[] result = {""};
try {
App app = new App();
result = app.getData(null, "WA");
System.out.println("testGetDataFromState: " + result[0]);
} catch (Exception e) {
System.out.println("Error testing database");
} finally {
assertEquals("Seattle, WA", result[0]);
}
}
}