Ejemplo n.º 1
0
  public void testFailedGetIfNewer() throws Exception {
    if (supportsGetIfNewer()) {
      setupRepositories();
      setupWagonTestingFixtures();
      message("Getting test artifact from test repository " + testRepository);
      Wagon wagon = getWagon();
      wagon.addTransferListener(checksumObserver);
      wagon.connect(testRepository, getAuthInfo());
      destFile = FileTestUtils.createUniqueFile(getName(), getName());
      destFile.deleteOnExit();
      try {
        wagon.getIfNewer("fubar.txt", destFile, 0);
        fail("File was found when it shouldn't have been");
      } catch (ResourceDoesNotExistException e) {
        // expected
        assertTrue(true);
      } finally {
        wagon.removeTransferListener(checksumObserver);

        wagon.disconnect();

        tearDownWagonTestingFixtures();
      }
    }
  }
Ejemplo n.º 2
0
  protected void assertResourcesAreInRemoteSide(Wagon wagon, List<String> resourceNames)
      throws IOException, TransferFailedException, ResourceDoesNotExistException,
          AuthorizationException {
    for (String resourceName : resourceNames) {
      File destFile = FileTestUtils.createUniqueFile(getName(), resourceName);

      destFile.deleteOnExit();

      wagon.get(resourceName, destFile);
    }
  }
Ejemplo n.º 3
0
  protected void getFile(int expectedSize) throws Exception {
    destFile = FileTestUtils.createUniqueFile(getName(), getName());
    destFile.deleteOnExit();

    Wagon wagon = getWagon();

    ProgressAnswer progressAnswer = replaceMockForGet(wagon, expectedSize);

    message("Getting test artifact from test repository " + testRepository);

    connectWagon(wagon);

    wagon.get(this.resource, destFile);

    disconnectWagon(wagon);

    verifyMock(progressAnswer, expectedSize);
  }
Ejemplo n.º 4
0
  protected ProgressAnswer setupGetIfNewerTest(
      Wagon wagon, boolean expectedResult, int expectedSize)
      throws NoSuchAlgorithmException, IOException {
    checksumObserver = new ChecksumObserver();

    destFile = FileTestUtils.createUniqueFile(getName(), getName());
    destFile.delete();
    assertFalse(destFile.exists());
    destFile.deleteOnExit();

    ProgressAnswer progressAnswer = null;
    if (expectedResult) {
      progressAnswer = replaceMockForGet(wagon, expectedSize);
    } else {
      replaceMockForSkippedGetIfNewer(wagon, expectedSize);
    }
    return progressAnswer;
  }
Ejemplo n.º 5
0
  /**
   * 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();
  }