Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Add too-large upload file test
Browse files Browse the repository at this point in the history
Test for files that are too large to upload.
  • Loading branch information
djansen-redhat committed Sep 6, 2013
1 parent 38681a4 commit 2b85d60
Showing 1 changed file with 39 additions and 2 deletions.
Expand Up @@ -32,6 +32,7 @@

import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;

import static org.hamcrest.MatcherAssert.assertThat;

Expand Down Expand Up @@ -63,6 +64,7 @@ public void uploadedDocumentIsInFilesystem()
.pressUploadFileButton()
.enterFilePath(filePath)
.submitUpload();

assertThat("Document uploaded notification shows",
projectSourceDocumentsPage.getNotificationMessage(), Matchers.equalTo(successfullyUploaded));
assertThat("Document shows in table", projectSourceDocumentsPage.sourceDocumentsContains(testFileName));
Expand All @@ -77,6 +79,7 @@ public void cancelFileUpload()
.concat(testFileName);

assertThat("Data file "+testFileName+" exists", new File(filePath).exists());

ProjectSourceDocumentsPage projectSourceDocumentsPage = new LoginWorkFlow().signIn("admin", "admin")
.goToProjects()
.goToProject("about fedora")
Expand All @@ -85,10 +88,12 @@ public void cancelFileUpload()
.pressUploadFileButton()
.enterFilePath(filePath)
.cancelUpload();

assertThat("Document does not show in table",
!projectSourceDocumentsPage.sourceDocumentsContains(testFileName));
}

// RHBZ-990373
@Test(expected = RuntimeException.class)
public void emptyFilenameUpload()
{
Expand All @@ -100,11 +105,44 @@ public void emptyFilenameUpload()
.pressUploadFileButton()
.submitUpload();

// RHBZ-990373
projectSourceDocumentsPage.assertNoCriticalErrors();
// TODO: Verify graceful handling of scenario
}

// RHBZ990836
@Test(expected = RuntimeException.class)
public void handleReallyBigFile()
{
File bigFile;
int mbyte = 1024 * 1024;
int fileSize = 500;

try {
bigFile = File.createTempFile("bigFile", "txt");
RandomAccessFile randomAccessFile = new RandomAccessFile(bigFile, "rw");
randomAccessFile.setLength(mbyte*fileSize);
} catch (IOException e)
{
throw new RuntimeException("Unable to generate the test file");
}
assertThat("Data file "+bigFile+" exists", bigFile.exists());
assertThat("Data file "+bigFile+" is big", (int)bigFile.length() / mbyte,
Matchers.equalTo(fileSize));

ProjectSourceDocumentsPage projectSourceDocumentsPage = new LoginWorkFlow().signIn("admin", "admin")
.goToProjects()
.goToProject("about fedora")
.goToVersion("master")
.goToSourceDocuments()
.pressUploadFileButton()
.enterFilePath(bigFile.getAbsolutePath())
.submitUpload();

projectSourceDocumentsPage.assertNoCriticalErrors();
// TODO: Verify graceful handling of scenario
}

// RHBZ-990373
@Test(expected = RuntimeException.class)
public void failOnInvalidFileUpload()
{
Expand All @@ -129,7 +167,6 @@ public void failOnInvalidFileUpload()
assertThat("Data file " + noFile.getName() + " does not exists", !noFile.exists());
projectSourceDocumentsPage = projectSourceDocumentsPage.submitUpload();

// RHBZ-990373
projectSourceDocumentsPage.assertNoCriticalErrors();
// TODO: Verify graceful handling of scenario
}
Expand Down

0 comments on commit 2b85d60

Please sign in to comment.