1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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 }