1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.regionserver;
19
20 import junit.framework.Assert;
21
22 import org.apache.hadoop.hbase.HBaseTestingUtility;
23 import org.apache.hadoop.hbase.master.HMaster;
24 import org.apache.hadoop.hbase.MediumTests;
25 import org.junit.AfterClass;
26 import org.junit.BeforeClass;
27 import org.junit.Test;
28 import org.junit.experimental.categories.Category;
29
30 @Category(MediumTests.class)
31 public class TestMXBean {
32
33 private static final HBaseTestingUtility TEST_UTIL =
34 new HBaseTestingUtility();
35
36 @BeforeClass
37 public static void setup() throws Exception {
38 TEST_UTIL.startMiniCluster(1, 1);
39 }
40
41 @AfterClass
42 public static void teardown() throws Exception {
43 TEST_UTIL.shutdownMiniCluster();
44 }
45
46 @Test
47 public void testInfo() {
48 HRegionServer rs = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0);
49 HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
50 MXBeanImpl info = MXBeanImpl.init(rs);
51
52 Assert.assertEquals(rs.getServerName().getServerName(),
53 info.getServerName());
54 Assert.assertEquals(rs.getCoprocessors().length,
55 info.getCoprocessors().length);
56 rs.getConfiguration().setInt("hbase.master.info.port",
57 master.getServerName().getPort());
58 Assert.assertEquals(rs.getZooKeeperWatcher().getQuorum(),
59 info.getZookeeperQuorum());
60 }
61 }