public static CopyFilter getCopyFilter(Configuration conf) {
    String filtersClassName = conf
            .get(DistCpConstants.CONF_LABEL_FILTERS_CLASS);
    if (filtersClassName != null) {
      try {
        Class<? extends CopyFilter> filtersClass = conf
                .getClassByName(filtersClassName)
                .asSubclass(CopyFilter.class);
        filtersClassName = filtersClass.getName();
        Constructor<? extends CopyFilter> constructor = filtersClass
                .getDeclaredConstructor(Configuration.class);
        return constructor.newInstance(conf);
      } catch (Exception e) {
        LOG.error(DistCpConstants.CLASS_INSTANTIATION_ERROR_MSG +
                filtersClassName, e);
        throw new RuntimeException(
                DistCpConstants.CLASS_INSTANTIATION_ERROR_MSG +
                        filtersClassName, e);
      }
    } else {
      return getDefaultCopyFilter(conf);
    }
  }
@Test
  public void testGetCopyFilterRegexCopyFilter() {
    Configuration configuration = new Configuration(false);
    configuration.set(DistCpConstants.CONF_LABEL_FILTERS_FILE, "random");
    CopyFilter copyFilter = CopyFilter.getCopyFilter(configuration);
    assertTrue("copyFilter should be instance of RegexCopyFilter",
            copyFilter instanceof RegexCopyFilter);
  }