@Test
public void testKerbFileAccess() throws InterruptedException,
    LifecycleException, EventDeliveryException, IOException {

  LOG.debug("Starting testKerbFileAccess() ...");
  final String fileName = "FlumeData";
  final long rollCount = 5;
  final long batchSize = 2;
  String newPath = testPath + "/singleBucket";
  String kerbConfPrincipal = "user1/localhost@EXAMPLE.COM";
  String kerbKeytab = "/usr/lib/flume/nonexistkeytabfile";
  //turn security on
  Configuration conf = new Configuration();
  conf.set(CommonConfigurationKeys.HADOOP_SECURITY_AUTHENTICATION,
      "kerberos");
  UserGroupInformation.setConfiguration(conf);
  Context context = new Context();
  context.put("hdfs.path", newPath);
  context.put("hdfs.filePrefix", fileName);
  context.put("hdfs.rollCount", String.valueOf(rollCount));
  context.put("hdfs.batchSize", String.valueOf(batchSize));
  context.put("hdfs.kerberosPrincipal", kerbConfPrincipal);
  context.put("hdfs.kerberosKeytab", kerbKeytab);
  try {
    Configurables.configure(sink, context);
    Assert.fail("no exception thrown");
  } catch (IllegalArgumentException expected) {
    Assert.assertTrue(expected.getMessage().contains(
        "Keytab is not a readable file"));
  } finally {
    //turn security off
    conf.set(CommonConfigurationKeys.HADOOP_SECURITY_AUTHENTICATION,
        "simple");
    UserGroupInformation.setConfiguration(conf);
  }
}