Ejemplo n.º 1
0
  /**
   * Tests that adding a directory of jars to the configuration works as expected. .jar files under
   * the added directory should be added to the configuration, and all other files should be
   * skipped.
   *
   * @throws IOException If there is a problem adding the jar directory to the configuration.
   */
  @Test
  public void testAddJarDirectory() throws IOException {
    DistCache.addJarDirToDistributedCache(testConf, testFolder.getRoot().getCanonicalPath());
    // Throw the added jar paths in a set to detect duplicates.
    String[] splitJarPaths = StringUtils.split(testConf.get("tmpjars"), ",");
    Set<String> addedJarPaths = new HashSet<String>();
    for (String path : splitJarPaths) {
      addedJarPaths.add(path);
    }
    assertEquals(
        "Incorrect number of jar paths added.", testFilePaths.length, addedJarPaths.size());

    // Ensure all expected paths were added.
    for (int i = 0; i < testFileQualifiedPaths.length; i++) {
      assertTrue(
          "Expected jar path missing from jar paths added to tmpjars: " + testFileQualifiedPaths[i],
          addedJarPaths.contains(testFileQualifiedPaths[i]));
    }
  }
Ejemplo n.º 2
0
 /**
  * Tests that adding a jar directory that is not a directory to the configuration throws an
  * exception.
  *
  * @throws IOException If the added jar directory is not a directory. This exception is expected.
  */
 @Test(expected = IOException.class)
 public void testAddJarDirectoryNotDirectory() throws IOException {
   DistCache.addJarDirToDistributedCache(testConf, testFilePaths[0]);
 }
Ejemplo n.º 3
0
 /**
  * Tests that adding a jar directory that does not exist to the configuration throws an exception.
  *
  * @throws IOException If the added jar directory does not exist. This exception is expected.
  */
 @Test(expected = IOException.class)
 public void testAddJarDirectoryThatDoesntExist() throws IOException {
   DistCache.addJarDirToDistributedCache(testConf, "/garbage/doesntexist");
 }