Exemplo n.º 1
0
  protected ProgressAnswer replayMockForPut(String resourceName, String content, Wagon wagon) {
    Resource resource = new Resource(resourceName);
    mockTransferListener.transferInitiated(
        createTransferEvent(
            wagon,
            resource,
            TransferEvent.TRANSFER_INITIATED,
            TransferEvent.REQUEST_PUT,
            sourceFile));
    resource = new Resource(resourceName);
    resource.setContentLength(content.length());
    resource.setLastModified(sourceFile.lastModified());
    mockTransferListener.transferStarted(
        createTransferEvent(
            wagon,
            resource,
            TransferEvent.TRANSFER_STARTED,
            TransferEvent.REQUEST_PUT,
            sourceFile));
    mockTransferListener.transferProgress(
        eq(
            createTransferEvent(
                wagon,
                resource,
                TransferEvent.TRANSFER_PROGRESS,
                TransferEvent.REQUEST_PUT,
                sourceFile)),
        anyObject(byte[].class),
        anyInt());
    ProgressAnswer progressAnswer = new ProgressAnswer();
    expectLastCall().andStubAnswer(progressAnswer);

    mockTransferListener.debug(anyString());
    expectLastCall().anyTimes();

    mockTransferListener.transferCompleted(
        createTransferEvent(
            wagon,
            resource,
            TransferEvent.TRANSFER_COMPLETED,
            TransferEvent.REQUEST_PUT,
            sourceFile));

    replay(mockTransferListener);
    return progressAnswer;
  }
Exemplo n.º 2
0
  protected ProgressAnswer replaceMockForGet(Wagon wagon, int expectedSize) {
    Resource resource = new Resource(this.resource);
    mockTransferListener.transferInitiated(
        createTransferEvent(
            wagon,
            resource,
            TransferEvent.TRANSFER_INITIATED,
            TransferEvent.REQUEST_GET,
            destFile));
    resource = new Resource(this.resource);
    resource.setContentLength(getExpectedContentLengthOnGet(expectedSize));
    resource.setLastModified(getExpectedLastModifiedOnGet(testRepository, resource));
    TransferEvent te =
        createTransferEvent(
            wagon, resource, TransferEvent.TRANSFER_STARTED, TransferEvent.REQUEST_GET, null);
    mockTransferListener.transferStarted(te);
    mockTransferListener.transferProgress(
        eq(
            new TransferEvent(
                wagon, resource, TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_GET)),
        anyObject(byte[].class),
        anyInt());

    ProgressAnswer progressAnswer = new ProgressAnswer();

    if (assertOnTransferProgress()) {
      expectLastCall().andAnswer(progressAnswer);
    } else {
      expectLastCall().andAnswer(progressAnswer);
      expectLastCall().anyTimes();
    }
    mockTransferListener.debug(anyString());
    expectLastCall().anyTimes();

    mockTransferListener.transferCompleted(
        createTransferEvent(
            wagon,
            resource,
            TransferEvent.TRANSFER_COMPLETED,
            TransferEvent.REQUEST_GET,
            destFile));

    replay(mockTransferListener);
    return progressAnswer;
  }
Exemplo n.º 3
0
  private void replaceMockForSkippedGetIfNewer(Wagon wagon, int expectedSize) {
    Resource resource = new Resource(this.resource);
    mockTransferListener.transferInitiated(
        createTransferEvent(
            wagon,
            resource,
            TransferEvent.TRANSFER_INITIATED,
            TransferEvent.REQUEST_GET,
            destFile));
    resource = new Resource(this.resource);
    resource.setContentLength(getExpectedContentLengthOnGet(expectedSize));
    resource.setLastModified(getExpectedLastModifiedOnGet(testRepository, resource));
    // TODO: transfer skipped event?
    // mockTransferListener.transferSkipped( createTransferEvent( wagon, resource,
    // TransferEvent.TRANSFER_STARTED,
    // TransferEvent.REQUEST_GET, destFile ) );

    mockTransferListener.debug(anyString());
    expectLastCall().anyTimes();

    replay(mockTransferListener);
  }