01: package CustomDNS.Tests;
02:
03: import java.sql.Connection;
04:
05: import CustomDNS.Tests.CustomDNSTestCase;
06: import CustomDNS.Configuration;
07:
08: public class TestConfiguration extends CustomDNSTestCase {
09:
10: Configuration myConfig;
11:
12: public TestConfiguration(String name) {
13: super (name);
14: }
15:
16: protected void setUp() throws Exception {
17: String[] args = { fullPath("espeak.prop"),
18: fullPath("customdns.prop") };
19: myConfig = Configuration.parseArguments("Test", args);
20: }
21:
22: public void testGetProperty() {
23: assertEquals(myConfig.getProperty("foo"), "bar");
24: assertEquals(myConfig.getProperty("foo.x.y"), "baz");
25: }
26:
27: public void testGetMissingProperty() {
28: assertEquals(myConfig.getProperty("missing"), null);
29: }
30:
31: public void testGetMissingPropertyDefault() {
32: assertEquals(myConfig.getProperty("missing", "default"),
33: "default");
34: }
35:
36: public void testConnectionFile() {
37: assertEquals(myConfig.getConnectionFile(),
38: fullPath("espeak.prop"));
39: }
40:
41: public void testDatabaseConnection() throws Exception {
42: Connection c = myConfig.connectToDatabase();
43: assert (c != null);
44: }
45: }
|