@Test (timeout = 15000)
public void testReuseLocalizedAuxiliaryJar() throws Exception {

  File testJar = null;
  AuxServices aux = null;
  Configuration conf = new YarnConfiguration();
  FileSystem fs = FileSystem.get(conf);
  String root = "target/LocalDir";
  try {
    testJar = JarFinder.makeClassLoaderTestJar(this.getClass(), rootDir,
        "test-runjar.jar", 2048, ServiceB.class.getName(), LightService
        .class.getName());
    Context mockContext = mock(Context.class);
    LocalDirsHandlerService mockDirsHandler = mock(
        LocalDirsHandlerService.class);
    Path rootAuxServiceDirPath = new Path(root, "nmAuxService");
    when(mockDirsHandler.getLocalPathForWrite(anyString())).thenReturn(
        rootAuxServiceDirPath);
    when(mockContext.getLocalDirsHandler()).thenReturn(mockDirsHandler);
    aux = new AuxServices(MOCK_AUX_PATH_HANDLER, mockContext,
        MOCK_DEL_SERVICE);
    // First Time the jar gets localized
    Path path = aux.maybeDownloadJars("ServiceB", ServiceB.class.getName(),
        testJar.getAbsolutePath(), AuxServiceFile.TypeEnum.STATIC, conf);
    // Validate the path on reuse of localized jar
    path = aux.maybeDownloadJars("ServiceB", ServiceB.class.getName(),
        testJar.getAbsolutePath(), AuxServiceFile.TypeEnum.STATIC, conf);
    assertFalse("Failed to reuse the localized jar",
        path.toString().endsWith("/*"));
  } finally {
    if (testJar != null) {
      testJar.delete();
    }
    if (fs.exists(new Path(root))) {
      fs.delete(new Path(root), true);
    }
  }
}