001/**
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements.  See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership.  The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License.  You may obtain a copy of the License at
010 *
011 *     http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 */
019package org.apache.hbase.shaded;
020
021import static org.junit.Assert.assertEquals;
022
023import org.apache.hadoop.hbase.HBaseClassTestRule;
024import org.apache.hadoop.hbase.HBaseTestingUtility;
025import org.apache.hadoop.hbase.TableName;
026import org.apache.hadoop.hbase.client.Put;
027import org.apache.hadoop.hbase.client.Table;
028import org.apache.hadoop.hbase.testclassification.ClientTests;
029import org.apache.hadoop.hbase.testclassification.MediumTests;
030import org.apache.hadoop.hbase.util.Bytes;
031import org.junit.AfterClass;
032import org.junit.BeforeClass;
033import org.junit.ClassRule;
034import org.junit.Test;
035import org.junit.experimental.categories.Category;
036
037@Category({ ClientTests.class, MediumTests.class })
038public class TestShadedHBaseTestingUtility {
039  private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
040
041  @ClassRule
042  public static final HBaseClassTestRule CLASS_RULE =
043      HBaseClassTestRule.forClass(TestShadedHBaseTestingUtility.class);
044
045  @BeforeClass
046  public static void setUp() throws Exception {
047    TEST_UTIL.startMiniCluster();
048  }
049
050  @AfterClass
051  public static void tearDown() throws Exception {
052    TEST_UTIL.shutdownMiniCluster();
053  }
054
055  @Test
056  public void testCreateTable() throws Exception {
057    TableName tableName = TableName.valueOf("test");
058
059    Table table = TEST_UTIL.createTable(tableName, "cf");
060
061    Put put1 = new Put(Bytes.toBytes("r1"));
062    put1.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("c"), Bytes.toBytes(1));
063    table.put(put1);
064
065    Put put2 = new Put(Bytes.toBytes("r2"));
066    put2.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("c"), Bytes.toBytes(2));
067    table.put(put2);
068
069    int rows = TEST_UTIL.countRows(tableName);
070    assertEquals(2, rows);
071  }
072}