View Javadoc

1   /**
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  package org.apache.hbase.shaded;
20  
21  import static org.junit.Assert.assertEquals;
22  
23  import org.apache.hadoop.hbase.HBaseTestingUtility;
24  import org.apache.hadoop.hbase.TableName;
25  import org.apache.hadoop.hbase.client.Put;
26  import org.apache.hadoop.hbase.client.Table;
27  import org.apache.hadoop.hbase.testclassification.ClientTests;
28  import org.apache.hadoop.hbase.testclassification.MediumTests;
29  import org.apache.hadoop.hbase.util.Bytes;
30  import org.junit.AfterClass;
31  import org.junit.BeforeClass;
32  import org.junit.Test;
33  import org.junit.experimental.categories.Category;
34  
35  @Category({ ClientTests.class, MediumTests.class })
36  public class TestShadedHBaseTestingUtility {
37    private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
38  
39    @BeforeClass
40    public static void setUp() throws Exception {
41      TEST_UTIL.startMiniCluster(1, 2);
42    }
43  
44    @AfterClass
45    public static void tearDown() throws Exception {
46      TEST_UTIL.shutdownMiniCluster();
47    }
48  
49    @Test
50    public void testCreateTable() throws Exception {
51      TableName tableName = TableName.valueOf("test");
52  
53      Table table = TEST_UTIL.createTable(tableName, "cf");
54  
55      Put put1 = new Put(Bytes.toBytes("r1"));
56      put1.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("c"), Bytes.toBytes(1));
57      table.put(put1);
58  
59      Put put2 = new Put(Bytes.toBytes("r2"));
60      put2.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("c"), Bytes.toBytes(2));
61      table.put(put2);
62  
63      int rows = TEST_UTIL.countRows(tableName);
64      assertEquals(2, rows);
65    }
66  }