Example #1
0
  /**
   * Test {@link Wagon#getFileList(String)}.
   *
   * @throws Exception
   * @since 1.0-beta-2
   */
  public void testWagonGetFileList() throws Exception {
    setupRepositories();

    setupWagonTestingFixtures();

    String dirName = "file-list";

    String filenames[] =
        new String[] {
          "test-resource.txt",
          "test-resource.pom",
          "test-resource b.txt",
          "more-resources.dat",
          ".index.txt"
        };

    for (String filename : filenames) {
      putFile(dirName + "/" + filename, dirName + "/" + filename, filename + "\n");
    }

    Wagon wagon = getWagon();

    wagon.connect(testRepository, getAuthInfo());

    List<String> list = wagon.getFileList(dirName);
    assertNotNull("file list should not be null.", list);
    assertTrue(
        "file list should contain more items (actually contains '" + list + "').",
        list.size() >= filenames.length);

    for (String filename : filenames) {
      assertTrue("Filename '" + filename + "' should be in list.", list.contains(filename));
    }

    // WAGON-250
    list = wagon.getFileList("");
    assertNotNull("file list should not be null.", list);
    assertTrue(
        "file list should contain items (actually contains '" + list + "').", !list.isEmpty());
    assertTrue(list.contains("file-list/"));
    assertFalse(list.contains("file-list"));
    assertFalse(list.contains("."));
    assertFalse(list.contains(".."));
    assertFalse(list.contains("./"));
    assertFalse(list.contains("../"));

    wagon.disconnect();

    tearDownWagonTestingFixtures();
  }
Example #2
0
  /**
   * Test {@link Wagon#getFileList(String)} when the directory does not exist.
   *
   * @throws Exception
   * @since 1.0-beta-2
   */
  public void testWagonGetFileListWhenDirectoryDoesNotExist() throws Exception {
    setupRepositories();

    setupWagonTestingFixtures();

    String dirName = "file-list-unexisting";

    Wagon wagon = getWagon();

    wagon.connect(testRepository, getAuthInfo());

    try {
      wagon.getFileList(dirName);
      fail("getFileList on unexisting directory must throw ResourceDoesNotExistException");
    } catch (ResourceDoesNotExistException e) {
      // expected
    } finally {
      wagon.disconnect();

      tearDownWagonTestingFixtures();
    }
  }