コード例 #1
0
ファイル: WagonTestCase.java プロジェクト: apache/maven-wagon
  /**
   * Test that when putting a directory that already exists new files get also copied
   *
   * @throws Exception
   * @since 1.0-beta-1
   */
  public void testWagonPutDirectoryWhenDirectoryAlreadyExists() throws Exception {

    final String dirName = "directory-copy-existing";

    final String resourceToCreate = "test-resource-1.txt";

    final String[] resources = {
      "a/test-resource-2.txt", "a/b/test-resource-3.txt", "c/test-resource-4.txt"
    };

    setupRepositories();

    setupWagonTestingFixtures();

    Wagon wagon = getWagon();

    if (wagon.supportsDirectoryCopy()) {
      sourceFile = new File(FileTestUtils.getTestOutputDir(), dirName);

      FileUtils.deleteDirectory(sourceFile);

      createDirectory(wagon, resourceToCreate, dirName);

      for (String resource : resources) {
        writeTestFile(resource);
      }

      wagon.connect(testRepository, getAuthInfo());

      wagon.putDirectory(sourceFile, dirName);

      List<String> resourceNames = new ArrayList<String>(resources.length + 1);

      resourceNames.add(dirName + "/" + resourceToCreate);
      for (String resource : resources) {
        resourceNames.add(dirName + "/" + resource);
      }

      assertResourcesAreInRemoteSide(wagon, resourceNames);

      wagon.disconnect();
    }

    tearDownWagonTestingFixtures();
  }
コード例 #2
0
ファイル: WagonTestCase.java プロジェクト: apache/maven-wagon
  protected void putFile(String resourceName, String testFileName, String content)
      throws Exception {
    sourceFile = new File(FileTestUtils.getTestOutputDir(), testFileName);
    sourceFile.getParentFile().mkdirs();
    FileUtils.fileWrite(sourceFile.getAbsolutePath(), content);

    Wagon wagon = getWagon();

    ProgressAnswer progressAnswer = replayMockForPut(resourceName, content, wagon);

    message("Putting test artifact: " + resourceName + " into test repository " + testRepository);

    connectWagon(wagon);

    wagon.put(sourceFile, resourceName);

    disconnectWagon(wagon);

    verifyMock(progressAnswer, content.length());
  }
コード例 #3
0
ファイル: WagonTestCase.java プロジェクト: apache/maven-wagon
  /**
   * Test for putting a directory with a destination that multiple directories deep, all of which
   * haven't been created.
   *
   * @throws Exception
   * @since 1.0-beta-2
   */
  public void testWagonPutDirectoryDeepDestination() throws Exception {
    setupRepositories();

    setupWagonTestingFixtures();

    Wagon wagon = getWagon();

    if (wagon.supportsDirectoryCopy()) {
      sourceFile = new File(FileTestUtils.getTestOutputDir(), "deep0/deep1/deep2");

      FileUtils.deleteDirectory(sourceFile);

      writeTestFile("test-resource-1.txt");
      writeTestFile("a/test-resource-2.txt");
      writeTestFile("a/b/test-resource-3.txt");
      writeTestFile("c/test-resource-4.txt");
      writeTestFile("d/e/f/test-resource-5.txt");

      wagon.connect(testRepository, getAuthInfo());

      wagon.putDirectory(sourceFile, "deep0/deep1/deep2");

      destFile = FileTestUtils.createUniqueFile(getName(), getName());

      destFile.deleteOnExit();

      wagon.get("deep0/deep1/deep2/test-resource-1.txt", destFile);
      wagon.get("deep0/deep1/deep2/a/test-resource-2.txt", destFile);
      wagon.get("deep0/deep1/deep2/a/b/test-resource-3.txt", destFile);
      wagon.get("deep0/deep1/deep2/c/test-resource-4.txt", destFile);
      wagon.get("deep0/deep1/deep2/d/e/f/test-resource-5.txt", destFile);

      wagon.disconnect();
    }

    tearDownWagonTestingFixtures();
  }