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.hbase.shaded;
019
020import static org.junit.Assert.assertEquals;
021
022import org.apache.hadoop.hbase.HBaseClassTestRule;
023import org.apache.hadoop.hbase.HBaseTestingUtility;
024import org.apache.hadoop.hbase.TableName;
025import org.apache.hadoop.hbase.client.Put;
026import org.apache.hadoop.hbase.client.Table;
027import org.apache.hadoop.hbase.testclassification.ClientTests;
028import org.apache.hadoop.hbase.testclassification.MediumTests;
029import org.apache.hadoop.hbase.util.Bytes;
030import org.junit.AfterClass;
031import org.junit.BeforeClass;
032import org.junit.ClassRule;
033import org.junit.Test;
034import org.junit.experimental.categories.Category;
035
036@Category({ ClientTests.class, MediumTests.class })
037public class TestShadedHBaseTestingUtility {
038  private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
039
040  @ClassRule
041  public static final HBaseClassTestRule CLASS_RULE =
042    HBaseClassTestRule.forClass(TestShadedHBaseTestingUtility.class);
043
044  @BeforeClass
045  public static void setUp() throws Exception {
046    TEST_UTIL.startMiniCluster();
047  }
048
049  @AfterClass
050  public static void tearDown() throws Exception {
051    TEST_UTIL.shutdownMiniCluster();
052  }
053
054  @Test
055  public void testCreateTable() throws Exception {
056    TableName tableName = TableName.valueOf("test");
057
058    Table table = TEST_UTIL.createTable(tableName, "cf");
059
060    Put put1 = new Put(Bytes.toBytes("r1"));
061    put1.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("c"), Bytes.toBytes(1));
062    table.put(put1);
063
064    Put put2 = new Put(Bytes.toBytes("r2"));
065    put2.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("c"), Bytes.toBytes(2));
066    table.put(put2);
067
068    int rows = TEST_UTIL.countRows(tableName);
069    assertEquals(2, rows);
070  }
071}