@Test
public void testKeySuccessfulKeyLifecycle() throws Exception {

  outContent.reset();
  String[] args1 = {"create", "key1", "--provider", 
      "jceks://file" + tmpDir + "/keystore.jceks"};
  int rc = 0;
  KeyShell ks = new KeyShell();
  ks.setConf(new Configuration());
  rc = ks.run(args1);
  assertEquals(0, rc);
  assertTrue(outContent.toString().contains("key1 has been successfully " +
  		"created."));
  outContent.reset();
  String[] args2 = {"list", "--provider",
      "jceks://file" + tmpDir + "/keystore.jceks"};
  rc = ks.run(args2);
  assertEquals(0, rc);
  assertTrue(outContent.toString().contains("key1"));
  outContent.reset();
  String[] args2a = {"list", "--metadata", "--provider",
                    "jceks://file" + tmpDir + "/keystore.jceks"};
  rc = ks.run(args2a);
  assertEquals(0, rc);
  assertTrue(outContent.toString().contains("key1"));
  assertTrue(outContent.toString().contains("description"));
  assertTrue(outContent.toString().contains("created"));
  outContent.reset();
  String[] args3 = {"roll", "key1", "--provider", 
      "jceks://file" + tmpDir + "/keystore.jceks"};
  rc = ks.run(args3);
  assertEquals(0, rc);
  assertTrue(outContent.toString().contains("key1 has been successfully " +
  		"rolled."));
  outContent.reset();
  String[] args4 = {"delete", "key1", "--provider", 
      "jceks://file" + tmpDir + "/keystore.jceks"};
  rc = ks.run(args4);
  assertEquals(0, rc);
  assertTrue(outContent.toString().contains("key1 has been successfully " +
  		"deleted."));
  outContent.reset();
  String[] args5 = {"list", "--provider", 
      "jceks://file" + tmpDir + "/keystore.jceks"};
  rc = ks.run(args5);
  assertEquals(0, rc);
  assertFalse(outContent.toString(), outContent.toString().contains("key1"));
}