@Test
  public void testPreWALAppendNotCalledOnMetaEdit() throws Exception {
    final TableName tableName =
      TableName.valueOf(TEST_TABLE.getNameAsString() + "." + name.getMethodName());
    TableDescriptorBuilder tdBuilder = TableDescriptorBuilder.newBuilder(tableName);
    ColumnFamilyDescriptorBuilder cfBuilder = ColumnFamilyDescriptorBuilder.newBuilder(FAMILY);
    tdBuilder.setColumnFamily(cfBuilder.build());
    tdBuilder.setCoprocessor(SimpleRegionObserver.class.getName());
    TableDescriptor td = tdBuilder.build();
    Table table = util.createTable(td, new byte[][] { A, B, C });

    PreWALAppendWALActionsListener listener = new PreWALAppendWALActionsListener();
    List<HRegion> regions = util.getHBaseCluster().getRegions(tableName);
    // should be only one region
    HRegion region = regions.get(0);

    region.getWAL().registerWALActionsListener(listener);
    // flushing should write to the WAL
    region.flush(true);
    // so should compaction
    region.compact(false);
    // and so should closing the region
    region.close();

    // but we still shouldn't have triggered preWALAppend because no user data was written
    String[] methods = new String[] { "getCtPreWALAppend" };
    Object[] expectedResult = new Integer[] { 0 };
    verifyMethodResult(SimpleRegionObserver.class, methods, tableName, expectedResult);
  }
Tests overriding compaction handling via coprocessor hooks
hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverInterface.java