001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.client;
019
020import java.io.IOException;
021import org.apache.hadoop.hbase.HBaseClassTestRule;
022import org.apache.hadoop.hbase.ServerName;
023import org.apache.hadoop.hbase.security.UserProvider;
024import org.apache.hadoop.hbase.testclassification.ClientTests;
025import org.apache.hadoop.hbase.testclassification.SmallTests;
026import org.junit.After;
027import org.junit.Before;
028import org.junit.ClassRule;
029import org.junit.Test;
030import org.junit.experimental.categories.Category;
031
032import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
033
034@Category({ ClientTests.class, SmallTests.class })
035public class TestConnectionImplementationTracing extends TestTracingBase {
036
037  @ClassRule
038  public static final HBaseClassTestRule CLASS_RULE =
039    HBaseClassTestRule.forClass(TestConnectionImplementationTracing.class);
040
041  ConnectionImplementation conn;
042
043  @Override
044  @Before
045  public void setUp() throws Exception {
046    super.setUp();
047    conn = new ConnectionImplementation(conf, null, UserProvider.instantiate(conf).getCurrent());
048  }
049
050  @After
051  public void tearDown() throws IOException {
052    Closeables.close(conn, true);
053  }
054
055  @Test
056  public void testHbck() throws IOException {
057    conn.getHbck();
058    assertTrace(ConnectionImplementation.class.getSimpleName(), "getHbck", MASTER_HOST, null);
059  }
060
061  @Test
062  public void testHbckWithServerName() throws IOException {
063    ServerName otherHost = ServerName.valueOf("localhost2", 16010, System.currentTimeMillis());
064    conn.getHbck(otherHost);
065    assertTrace(ConnectionImplementation.class.getSimpleName(), "getHbck", otherHost, null);
066  }
067
068  @Test
069  public void testClose() throws IOException {
070    conn.close();
071    assertTrace(ConnectionImplementation.class.getSimpleName(), "close", null, null);
072  }
073
074}