1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
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  }