@Override
    public void stop(CoprocessorEnvironment env) throws IOException {
      String fileName = null;

      if (env instanceof MasterCoprocessorEnvironment) {
        // if running on HMaster
        fileName = MASTER_FILE;
      } else if (env instanceof RegionServerCoprocessorEnvironment) {
        fileName = REGIONSERVER_FILE;
      } else if (env instanceof RegionCoprocessorEnvironment) {
        LOG.error("on RegionCoprocessorEnvironment!!");
      }

      Configuration conf = UTIL.getConfiguration();
      Path resultFile = new Path(UTIL.getDataTestDirOnTestFS(), fileName);
      FileSystem fs = FileSystem.get(conf);

      boolean result = fs.createNewFile(resultFile);
      LOG.info("create file " + resultFile + " return rc " + result);
    }
Tests for master and regionserver coprocessor stop method
hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorStop.java