bbeaudreault commented on code in PR #4542:
URL: https://github.com/apache/hbase/pull/4542#discussion_r904369878


##########
src/main/asciidoc/_chapters/unit_testing.adoc:
##########
@@ -321,11 +324,68 @@ public class MyHBaseIntegrationTest {
 }
 ----
 
+Starting from HBase 2.5.0, it is recommended to use TestingHBaseCluster 
instead.
+
+[source,java]
+----
+public class MyHBaseIntegrationTest {
+
+  private TestingHBaseCluster cluster;
+
+  private Connection conn;
+
+  private Admin admin;
+
+  private TableName tableName = TableName.valueOf("MyTest");
+
+  byte[] CF = "CF".getBytes();
+  byte[] CQ1 = "CQ-1".getBytes();
+  byte[] CQ2 = "CQ-2".getBytes();
+
+  @Before
+  public void setUp() throws Exception {
+    cluster = 
TestingHBaseCluster.create(TestingHBaseClusterOption.builder().build());
+    cluster.start();
+    conn = ConnectionFactory.createConnection(cluster.getConf());
+    admin = conn.getAdmin();
+    admin.createTable(TableDescriptorBuilder.newBuilder(tableName)
+      .setColumnFamily(ColumnFamilyDescriptorBuilder.of(CF)).build());
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    admin.close();
+    conn.close();
+    cluster.stop();
+  }
+
+  @Test
+  public void testInsert() throws Exception {
+    try (Table table = conn.getTable(tableName)) {
+      HBaseTestObj obj = new HBaseTestObj();
+      obj.setRowKey("ROWKEY-1");
+      obj.setData1("DATA-1");
+      obj.setData2("DATA-2");
+      MyHBaseDAO.insertRecord(table, obj);
+      Get get1 = new Get(Bytes.toBytes(obj.getRowKey()));
+      get1.addColumn(CF, CQ1);
+      Result result1 = table.get(get1);
+      assertEquals(Bytes.toString(result1.getRow()), obj.getRowKey());
+      assertEquals(Bytes.toString(result1.value()), obj.getData1());
+      Get get2 = new Get(Bytes.toBytes(obj.getRowKey()));
+      get2.addColumn(CF, CQ2);
+      Result result2 = table.get(get2);
+      assertEquals(Bytes.toString(result2.getRow()), obj.getRowKey());
+      assertEquals(Bytes.toString(result2.value()), obj.getData2());
+    }
+  }
+}
+----
+
 This code creates an HBase mini-cluster and starts it.
 Next, it creates a table called `MyTest` with one column family, `CF`.
 A record is inserted, a Get is performed from the same table, and the 
insertion is verified.
 
 NOTE: Starting the mini-cluster takes about 20-30 seconds, but that should be 
appropriate for integration testing.
 
-See the paper at 
link:http://blog.sematext.com/2010/08/30/hbase-case-study-using-hbasetestingutility-for-local-testing-development/[HBase
 Case-Study: Using HBaseTestingUtility for Local Testing and

Review Comment:
   Should we just remove this now?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to