1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.zookeeper;
20
21 import static org.junit.Assert.assertEquals;
22 import static org.junit.Assert.assertTrue;
23
24 import org.apache.hadoop.conf.Configuration;
25 import org.apache.hadoop.hbase.*;
26 import org.junit.Test;
27 import org.junit.experimental.categories.Category;
28
29 @Category(SmallTests.class)
30 public class TestZooKeeperMainServer {
31 private final ZooKeeperMainServer parser = new ZooKeeperMainServer();
32
33 @Test public void test() {
34 Configuration c = HBaseConfiguration.create();
35 assertEquals("localhost:" + c.get(HConstants.ZOOKEEPER_CLIENT_PORT), parser.parse(c));
36 final String port = "1234";
37 c.set(HConstants.ZOOKEEPER_CLIENT_PORT, port);
38 c.set("hbase.zookeeper.quorum", "example.com");
39 assertEquals("example.com:" + port, parser.parse(c));
40 c.set("hbase.zookeeper.quorum", "example1.com,example2.com,example3.com");
41 String ensemble = parser.parse(c);
42 assertTrue(port, ensemble.matches("(example[1-3]\\.com:1234,){2}example[1-3]\\.com:" + port));
43 }
44 }