From 2c96094f21fed90115b6cef0de35c473fa180cd9 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Thu, 30 Jul 2020 13:41:24 +0200 Subject: [PATCH] E2E test with random files that are big enought to use chunked uploads Signed-off-by: tobiasKaminsky --- .../com/nextcloud/client/EndToEndRandomIT.java | 16 +++++++++++----- .../java/com/owncloud/android/AbstractIT.java | 4 +++- .../com/owncloud/android/AbstractOnServerIT.java | 14 -------------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/androidTest/java/com/nextcloud/client/EndToEndRandomIT.java b/src/androidTest/java/com/nextcloud/client/EndToEndRandomIT.java index cf310acdda..f263b532c3 100644 --- a/src/androidTest/java/com/nextcloud/client/EndToEndRandomIT.java +++ b/src/androidTest/java/com/nextcloud/client/EndToEndRandomIT.java @@ -42,7 +42,6 @@ import com.owncloud.android.operations.GetCapabilitiesOperation; import com.owncloud.android.operations.RemoveFileOperation; import com.owncloud.android.utils.CsrHelper; import com.owncloud.android.utils.EncryptionUtils; -import com.owncloud.android.utils.FileStorageUtils; import net.bytebuddy.utility.RandomString; @@ -271,15 +270,22 @@ public class EndToEndRandomIT extends AbstractOnServerIT { private void uploadFile(int i) throws IOException { String fileName = RandomString.make(5) + ".txt"; - createFile(fileName, new Random().nextInt(50000)); - String path = currentFolder.getRemotePath() + fileName; + + File file; + if (new Random().nextBoolean()) { + file = createFile(fileName, new Random().nextInt(50000)); + } else { + file = createFile(fileName, 500000 + new Random().nextInt(50000)); + } + + String remotePath = currentFolder.getRemotePath() + fileName; Log_OC.d(this, "[" + i + "/" + actionCount + "] " + "Upload file to: " + currentFolder.getDecryptedRemotePath() + fileName); - OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + File.separator + fileName, - path, + OCUpload ocUpload = new OCUpload(file.getAbsolutePath(), + remotePath, account.name); uploadOCUpload(ocUpload); } diff --git a/src/androidTest/java/com/owncloud/android/AbstractIT.java b/src/androidTest/java/com/owncloud/android/AbstractIT.java index e6f94182f0..abf7a03a4d 100644 --- a/src/androidTest/java/com/owncloud/android/AbstractIT.java +++ b/src/androidTest/java/com/owncloud/android/AbstractIT.java @@ -185,7 +185,7 @@ public abstract class AbstractIT { return AccountManager.get(targetContext).getAccounts(); } - public static void createFile(String name, int iteration) throws IOException { + public static File createFile(String name, int iteration) throws IOException { File file = new File(FileStorageUtils.getSavePath(account.name) + File.separator + name); file.createNewFile(); @@ -196,6 +196,8 @@ public abstract class AbstractIT { } writer.flush(); writer.close(); + + return file; } protected File getFile(String filename) throws IOException { diff --git a/src/androidTest/java/com/owncloud/android/AbstractOnServerIT.java b/src/androidTest/java/com/owncloud/android/AbstractOnServerIT.java index 7ac6ddc3ae..42f74d361c 100644 --- a/src/androidTest/java/com/owncloud/android/AbstractOnServerIT.java +++ b/src/androidTest/java/com/owncloud/android/AbstractOnServerIT.java @@ -38,7 +38,6 @@ import org.junit.Assert; import org.junit.BeforeClass; import java.io.File; -import java.io.FileWriter; import java.io.IOException; import androidx.annotation.NonNull; @@ -148,19 +147,6 @@ public abstract class AbstractOnServerIT extends AbstractIT { createFile("chunkedFile.txt", 500000); } - public static void createFile(String name, int iteration) throws IOException { - File file = new File(FileStorageUtils.getSavePath(account.name) + File.separator + name); - file.createNewFile(); - - FileWriter writer = new FileWriter(file); - - for (int i = 0; i < iteration; i++) { - writer.write("123123123123123123123123123\n"); - } - writer.flush(); - writer.close(); - } - private static void waitForServer(OwnCloudClient client, Uri baseUrl) { GetMethod get = new GetMethod(baseUrl + "/status.php");