@Test
  public void testCreationClasspathCoprocessor() throws Exception {
    Configuration conf = UTIL.getConfiguration();
    // load coprocessor under test
    conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY,
      CoprocessorWhitelistMasterObserver.class.getName());
    conf.setStrings(CoprocessorWhitelistMasterObserver.CP_COPROCESSOR_WHITELIST_PATHS_KEY,
      new String[] {});
    // set retries low to raise exception quickly
    conf.setInt("hbase.client.retries.number", 5);
    UTIL.startMiniCluster();
    TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(TEST_TABLE)
      .setColumnFamily(ColumnFamilyDescriptorBuilder.of(TEST_FAMILY))
      .setCoprocessor(TestRegionObserver.class.getName()).build();
    Connection connection = ConnectionFactory.createConnection(conf);
    Admin admin = connection.getAdmin();
    LOG.info("Creating Table");
    admin.createTable(tableDescriptor);
    // ensure table was created and coprocessor is added to table
    LOG.info("Done Creating Table");
    Table t = connection.getTable(TEST_TABLE);
    assertEquals(1, t.getDescriptor().getCoprocessorDescriptors().size());
  }
Test a table creation including a coprocessor path which is on the classpath. Table will be
created with the coprocessor.
hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCoprocessorWhitelistMasterObserver.java