blob: 2862a1ae548e1bb44b41a50335985933578965ff (
plain)
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
84
85
86
|
/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
package repmgrtests;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNull;
import com.sleepycat.db.Environment;
import com.sleepycat.db.EnvironmentConfig;
import com.sleepycat.db.ReplicationManagerSite;
import com.sleepycat.db.ReplicationManagerSiteConfig;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
public class TestConfig {
private EnvironmentConfig ec;
private File dir;
@Before public void setUp() throws Exception {
ec = new EnvironmentConfig();
ec.setAllowCreate(true);
ec.setInitializeCache(true);
ec.setInitializeLocking(true);
ec.setInitializeLogging(true);
ec.setInitializeReplication(true);
ec.setTransactional(true);
ec.setThreaded(true);
dir = Util.mkdir("site1");
}
@Test(expected=IllegalArgumentException.class)
public void nullHost() throws Exception
{
ReplicationManagerSiteConfig conf =
new ReplicationManagerSiteConfig(null, 6000);
conf.setLocalSite(true);
ec.addReplicationManagerSite(conf);
Environment env = new Environment(dir, ec);
env.close();
}
@Test public void host() throws Exception
{
ReplicationManagerSiteConfig conf =
new ReplicationManagerSiteConfig("localhost", 6000);
conf.setLocalSite(true);
ec.addReplicationManagerSite(conf);
Environment env = new Environment(dir, ec);
env.close();
}
@Test public void getLocalSite() throws Exception
{
String host = "localhost";
long port = 6000;
ReplicationManagerSiteConfig conf =
new ReplicationManagerSiteConfig(host, port);
conf.setLocalSite(true);
ec.addReplicationManagerSite(conf);
Environment env = new Environment(dir, ec);
ReplicationManagerSite dbsite = env.getReplicationManagerLocalSite();
assertTrue(host.equals(dbsite.getAddress().host));
assertEquals(port, dbsite.getAddress().port);
env.close();
}
@Test public void noLocalSite() throws Exception {
Environment env = new Environment(dir, ec);
assertNull(env.getReplicationManagerLocalSite());
env.close();
}
}
|