1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.giraph.zk;
19
20 import org.apache.giraph.conf.GiraphConstants;
21 import org.apache.hadoop.conf.Configuration;
22 import org.junit.Test;
23
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertTrue;
26 import static org.junit.Assert.fail;
27
28 public class TestZooKeeperManager {
29 @Test
30 public void testGetBasePath() {
31 Configuration conf = new Configuration();
32
33
34 assertEquals("Default value for base path should be empty",
35 "", ZooKeeperManager.getBasePath(conf));
36
37 conf.set(GiraphConstants.BASE_ZNODE_KEY, "/howdy");
38 assertEquals("Base path should reflect value of " +
39 GiraphConstants.BASE_ZNODE_KEY,
40 "/howdy", ZooKeeperManager.getBasePath(conf));
41
42 conf.set(GiraphConstants.BASE_ZNODE_KEY, "no_slash");
43 try {
44 ZooKeeperManager.getBasePath(conf);
45 fail("Should not have allowed path without starting slash");
46 } catch (IllegalArgumentException iae) {
47 assertTrue(iae.getMessage().contains(GiraphConstants.BASE_ZNODE_KEY));
48 }
49 }
50 }