Merged WEBAPP-API (5.2.1) to 5.2.N (5.2.1)

134653 cpopa: APPSREPO-105 : Add an API to download multiple file/folders as a zip
      - Fixed a test which failed due to an incorrect wait time.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@134673 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Constantin Popa
2017-01-20 12:57:06 +00:00
parent 671b712a47
commit 79a98c1cfe

View File

@@ -75,6 +75,10 @@ import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestDownloads extends AbstractBaseApiTest
{
private static final int STATUS_CHECK_SLEEP_TIME = 5;
private static final int NUMBER_OF_TIMES_TO_CHECK_STATUS = 400;
public static final String NODES_SECONDARY_CHILDREN = "nodes/%s/secondary-children";
public static final String API_DOWNLOADS = "downloads";
@@ -370,14 +374,14 @@ public class TestDownloads extends AbstractBaseApiTest
private void assertDoneDownload(Download download, int expectedFilesAdded, int expectedTotal) throws Exception, InterruptedException
{
for(int i = 0; i<=40; i++){
if (i == 40)
for(int i = 0; i<=NUMBER_OF_TIMES_TO_CHECK_STATUS; i++){
if (i == NUMBER_OF_TIMES_TO_CHECK_STATUS)
{
fail("Download should be DONE by now.");
}
Download downloadStatus = getDownload(download.getDownloadId());
if (!downloadStatus.getStatus().equals(DownloadStatus.Status.DONE)){
Thread.sleep(50);
Thread.sleep(STATUS_CHECK_SLEEP_TIME);
}else{
assertTrue("The number of bytes added in the archive does not match the total", downloadStatus.getDone() == downloadStatus.getTotal());
assertEquals("The number of files added in the archive should be " + expectedFilesAdded, expectedFilesAdded, downloadStatus.getFilesAdded());
@@ -391,14 +395,14 @@ public class TestDownloads extends AbstractBaseApiTest
protected void assertCancelledDownload(Download download, int expectedTotalFiles, int expectedTotal) throws PublicApiException, Exception, InterruptedException
{
cancel(download.getDownloadId());
for(int i = 0; i<=40; i++){
if (i == 40)
for(int i = 0; i<=NUMBER_OF_TIMES_TO_CHECK_STATUS; i++){
if (i == NUMBER_OF_TIMES_TO_CHECK_STATUS)
{
fail("Download should be CANCELLED by now.");
}
Download downloadStatus = getDownload(download.getDownloadId());
if (!downloadStatus.getStatus().equals(DownloadStatus.Status.CANCELLED)){
Thread.sleep(50);
Thread.sleep(STATUS_CHECK_SLEEP_TIME);
}else{
assertTrue("The total bytes added to the archive by now should be greater than 0", downloadStatus.getDone() > 0 && downloadStatus.getDone() <= downloadStatus.getTotal());
assertTrue("The download is in progress, there should still be files to be added.", downloadStatus.getFilesAdded() < downloadStatus.getTotalFiles());
@@ -411,14 +415,14 @@ public class TestDownloads extends AbstractBaseApiTest
private void assertInProgressDownload(Download download, int expectedTotalFiles, int expectedTotal) throws Exception, InterruptedException
{
for(int i = 0; i<=40; i++){
if (i == 40)
for(int i = 0; i<=NUMBER_OF_TIMES_TO_CHECK_STATUS; i++){
if (i == NUMBER_OF_TIMES_TO_CHECK_STATUS)
{
fail("Download creation is taking too long.Download status should be at least IN_PROGRESS by now.");
}
Download downloadStatus = getDownload(download.getDownloadId());
if (!downloadStatus.getStatus().equals(DownloadStatus.Status.IN_PROGRESS)){
Thread.sleep(50);
Thread.sleep(STATUS_CHECK_SLEEP_TIME);
}else{
//'done' can be equal to the 'total' even though the status is IN_PROGRESS. See ZipDownloadExporter line 239
assertTrue("The total bytes added to the archive by now should be greater than 0", downloadStatus.getDone() > 0 && downloadStatus.getDone() <= downloadStatus.getTotal());