private RegionCoprocessorHost getRegionCoprocessorHost() {
    // Make up an HRegion instance. Use the hbase:meta first region as our RegionInfo. Use
    // hbase:meta table name for building the TableDescriptor our mock returns when asked schema
    // down inside RegionCoprocessorHost. Pass in mocked RegionServerServices too.
    RegionInfo ri = RegionInfoBuilder.FIRST_META_REGIONINFO;
    HRegion mockedHRegion = Mockito.mock(HRegion.class);
    Mockito.when(mockedHRegion.getRegionInfo()).thenReturn(ri);
    TableDescriptor td = TableDescriptorBuilder.newBuilder(ri.getTable()).build();
    Mockito.when(mockedHRegion.getTableDescriptor()).thenReturn(td);
    RegionServerServices mockedServices = Mockito.mock(RegionServerServices.class);
    Configuration conf = HBaseConfiguration.create();
    // Load our test coprocessor defined above.
    conf.set(REGION_COPROCESSOR_CONF_KEY, TestRegionObserver.class.getName());
    return new RegionCoprocessorHost(mockedHRegion, mockedServices, conf);
  }
Ensure we get expected exception when we try to return null from a preCompact call.
@throws IOException We expect it to throw {@link CoprocessorException}
hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverPreFlushAndPreCompact.java