Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ public void openFile() throws IOException {
// create file
String filePath = createFile("text");
String remotePath = "/text.md";
TestCase.assertTrue(new UploadFileRemoteOperation(filePath, remotePath, "text/markdown", "1464818400")
.execute(client).isSuccess());
TestCase.assertTrue(new UploadFileRemoteOperation(
filePath,
remotePath,
"text/markdown",
1464818400
).execute(client).isSuccess());

TestCase.assertTrue(new ReadFileRemoteOperation(remotePath).execute(client).isSuccess());

Expand All @@ -66,8 +70,12 @@ public void openFileWithSpecialChars() throws IOException {
// create file
String filePath = createFile("text");
String remotePath = "/äää.md";
TestCase.assertTrue(new UploadFileRemoteOperation(filePath, remotePath, "text/markdown", "1464818400")
.execute(client).isSuccess());
TestCase.assertTrue(new UploadFileRemoteOperation(
filePath,
remotePath,
"text/markdown",
1464818400
).execute(client).isSuccess());

TestCase.assertTrue(new ReadFileRemoteOperation(remotePath).execute(client).isSuccess());

Expand All @@ -85,8 +93,12 @@ public void openFileWithSpecialChars2() throws IOException {
// create file
String filePath = createFile("text");
String remotePath = "/あ.md";
TestCase.assertTrue(new UploadFileRemoteOperation(filePath, remotePath, "text/markdown", "1464818400")
.execute(client).isSuccess());
TestCase.assertTrue(new UploadFileRemoteOperation(
filePath,
remotePath,
"text/markdown",
1464818400
).execute(client).isSuccess());

TestCase.assertTrue(new ReadFileRemoteOperation(remotePath).execute(client).isSuccess());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class ToggleFileLockRemoteOperationIT : AbstractIT() {
val filePath: String = createFile("text")
val remotePath = "/text.md"
assertTrue(
UploadFileRemoteOperation(filePath, remotePath, "text/markdown", "1464818400")
@Suppress("Detekt.MagicNumber")
UploadFileRemoteOperation(filePath, remotePath, "text/markdown", 1464818400)
.execute(client).isSuccess
)
val initialFile =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ public void reuseExistingFile() throws IOException {

assertTrue(new CreateFolderRemoteOperation(folder, true).execute(client).isSuccess());

RemoteOperationResult uploadResult = new UploadFileRemoteOperation(txtFile.getAbsolutePath(),
RemoteOperationResult uploadResult = new UploadFileRemoteOperation(
txtFile.getAbsolutePath(),
filePath,
"txt/plain",
String.valueOf(System.currentTimeMillis() / MILLI_TO_SECOND))
.execute(client);
System.currentTimeMillis() / MILLI_TO_SECOND
).execute(client);

assertTrue("Error uploading file " + filePath + ": " + uploadResult, uploadResult.isSuccess());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public abstract class AbstractIT {
public RetryTestRule retryTestRule = new RetryTestRule();

private static final int BUFFER_SIZE = 1024;
public static final String RANDOM_MTIME = "1464818400";
public static final long RANDOM_MTIME = 1464818400L;
public static final int MILLI_TO_SECOND = 1000;

public static OwnCloudClient client;
Expand Down
25 changes: 15 additions & 10 deletions library/src/androidTest/java/com/owncloud/android/CopyFileIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
*/
package com.owncloud.android;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

import android.util.Log;

import com.owncloud.android.lib.common.operations.RemoteOperationResult;
Expand All @@ -42,10 +46,6 @@

import java.io.File;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

/**
* Class to test CopyRemoteFileOperation
*/
Expand Down Expand Up @@ -188,7 +188,12 @@ public void createFixtures() throws Exception {
File txtFile = getFile(ASSETS__TEXT_FILE_NAME);

for (String filePath : FILES_IN_FIXTURE) {
result = new UploadFileRemoteOperation(txtFile.getAbsolutePath(), filePath, "txt/plain", String.valueOf(System.currentTimeMillis() / 1000)).execute(client);
result = new UploadFileRemoteOperation(
txtFile.getAbsolutePath(),
filePath,
"txt/plain",
System.currentTimeMillis() / 1000
).execute(client);

assertTrue("Error uploading file " + filePath + ": " + result, result.isSuccess());
}
Expand Down Expand Up @@ -243,13 +248,13 @@ public void testCopyRemoteFileOperation() {

// copy & rename folder, different location
copyOperation = new CopyFileRemoteOperation(SRC_PATH_TO_FULL_FOLDER_2, TARGET_PATH_TO_FULL_FOLDER_2_RENAMED,
false);
false);
result = copyOperation.execute(client);
assertTrue("copy & rename folder, different location", result.isSuccess());

// copy & rename folder, same location (rename folder)
copyOperation = new CopyFileRemoteOperation(SRC_PATH_TO_FULL_FOLDER_3, SRC_PATH_TO_FULL_FOLDER_3_RENAMED,
false);
false);
result = copyOperation.execute(client);
assertTrue("copy & rename folder, same location (rename folder)", result.isSuccess());

Expand All @@ -260,7 +265,7 @@ public void testCopyRemoteFileOperation() {

// copy overwriting
copyOperation = new CopyFileRemoteOperation(SRC_PATH_TO_FULL_FOLDER_4,
TARGET_PATH_TO_ALREADY_EXISTENT_EMPTY_FOLDER_4, true);
TARGET_PATH_TO_ALREADY_EXISTENT_EMPTY_FOLDER_4, true);
result = copyOperation.execute(client);
assertTrue("copy overwriting", result.isSuccess());

Expand All @@ -269,13 +274,13 @@ public void testCopyRemoteFileOperation() {

// file to copy does not exist
copyOperation = new CopyFileRemoteOperation(SRC_PATH_TO_NON_EXISTENT_FILE, TARGET_PATH_TO_NON_EXISTENT_FILE,
false);
false);
result = copyOperation.execute(client);
assertSame("file to copy does not exist", result.getCode(), ResultCode.FILE_NOT_FOUND);

// folder to copy into does no exist
copyOperation = new CopyFileRemoteOperation(SRC_PATH_TO_FILE_5, TARGET_PATH_TO_FILE_5_INTO_NON_EXISTENT_FOLDER,
false);
false);
result = copyOperation.execute(client);
assertEquals("folder to copy into does no exist", result.getHttpCode(), HttpStatus.SC_CONFLICT);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ public void setUp() throws Exception {
assertTrue("Error creating folder" + mFullPath2Folder + ": " + result, result.isSuccess());

File textFile = getFile(ASSETS__TEXT_FILE_NAME);
result = new UploadFileRemoteOperation(textFile.getAbsolutePath(), mFullPath2File, "txt/plain",
String.valueOf(System.currentTimeMillis() / MILLI_TO_SECOND)).execute(client);
result = new UploadFileRemoteOperation(
textFile.getAbsolutePath(),
mFullPath2File, "txt/plain",
System.currentTimeMillis() / MILLI_TO_SECOND
).execute(client);

assertTrue("Error uploading file " + textFile.getAbsolutePath() + ": " + result, result.isSuccess());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,34 +57,36 @@ public void setUp() throws Exception {
mFullPath2NonExistentFile = NON_EXISTENT_FILE;

File textFile = getFile(ASSETS__TEXT_FILE_NAME);
RemoteOperationResult result = new UploadFileRemoteOperation(textFile.getAbsolutePath(),
mFullPath2FileToShare,
"txt/plain",
String.valueOf(System.currentTimeMillis() / MILLI_TO_SECOND))
.execute(client);
RemoteOperationResult result = new UploadFileRemoteOperation(
textFile.getAbsolutePath(),
mFullPath2FileToShare,
"txt/plain",
System.currentTimeMillis() / MILLI_TO_SECOND
).execute(client);

assertTrue("Error uploading file " + textFile + ": " + result, result.isSuccess());
}

@Test
public void testCreatePublicShareSuccessful() {
RemoteOperationResult result = new CreateShareRemoteOperation(mFullPath2FileToShare,
ShareType.PUBLIC_LINK,
"",
false,
"",
1).execute(client);
RemoteOperationResult result = new CreateShareRemoteOperation(
mFullPath2FileToShare,
ShareType.PUBLIC_LINK,
"",
false,
"",
1).execute(client);
assertTrue(result.isSuccess());
}

@Test
public void testCreatePublicShareFailure() {
RemoteOperationResult result = new CreateShareRemoteOperation(mFullPath2NonExistentFile,
ShareType.PUBLIC_LINK,
"",
false,
"",
1).execute(client);
ShareType.PUBLIC_LINK,
"",
false,
"",
1).execute(client);

assertFalse(result.isSuccess());
assertEquals(ResultCode.FILE_NOT_FOUND, result.getCode());
Expand All @@ -96,11 +98,11 @@ public void testCreatePublicShareFailure() {
@Test
public void testCreatePrivateShareWithUserSuccessful() {
RemoteOperationResult result = new CreateShareRemoteOperation(mFullPath2FileToShare,
ShareType.USER,
"admin",
false,
"",
31).execute(client);
ShareType.USER,
"admin",
false,
"",
31).execute(client);
assertTrue(result.isSuccess());
}

Expand All @@ -110,11 +112,11 @@ public void testCreatePrivateShareWithUserSuccessful() {
@Test
public void testCreatePrivateShareWithUserNotExists() {
RemoteOperationResult result = new CreateShareRemoteOperation(mFullPath2FileToShare,
ShareType.USER,
"no_exist",
false,
"",
31).execute(client);
ShareType.USER,
"no_exist",
false,
"",
31).execute(client);
assertFalse(result.isSuccess());

// TODO 404 is File not found, but actually it is "user not found"
Expand All @@ -127,11 +129,11 @@ public void testCreatePrivateShareWithUserNotExists() {
@Test
public void testCreatePrivateShareWithFileNotExists() {
RemoteOperationResult result = new CreateShareRemoteOperation(mFullPath2NonExistentFile,
ShareType.USER,
"admin",
false,
"",
31).execute(client);
ShareType.USER,
"admin",
false,
"",
31).execute(client);
assertFalse(result.isSuccess());
assertEquals(ResultCode.FILE_NOT_FOUND, result.getCode());
}
Expand All @@ -142,11 +144,11 @@ public void testCreatePrivateShareWithFileNotExists() {
@Test
public void testCreatePrivateShareWithGroupSuccessful() {
RemoteOperationResult result = new CreateShareRemoteOperation(mFullPath2FileToShare,
ShareType.GROUP,
"admin",
false,
"",
1).execute(client);
ShareType.GROUP,
"admin",
false,
"",
1).execute(client);
assertTrue(result.isSuccess());
}

Expand All @@ -156,11 +158,11 @@ public void testCreatePrivateShareWithGroupSuccessful() {
@Test
public void testCreatePrivateShareWithNonExistingGroupSharee() {
RemoteOperationResult result = new CreateShareRemoteOperation(mFullPath2FileToShare,
ShareType.GROUP,
"no_exist",
false,
"",
31).execute(client);
ShareType.GROUP,
"no_exist",
false,
"",
31).execute(client);
assertFalse(result.isSuccess());

// TODO 404 is File not found, but actually it is "user not found"
Expand All @@ -173,11 +175,11 @@ public void testCreatePrivateShareWithNonExistingGroupSharee() {
@Test
public void testCreatePrivateShareWithNonExistingFile() {
RemoteOperationResult result = new CreateShareRemoteOperation(mFullPath2NonExistentFile,
ShareType.GROUP,
"admin",
false,
"",
31).execute(client);
ShareType.GROUP,
"admin",
false,
"",
31).execute(client);
assertFalse(result.isSuccess());
assertEquals(ResultCode.FILE_NOT_FOUND, result.getCode());
}
Expand All @@ -202,15 +204,15 @@ public void testCreatePrivateShareWithNonExistingFile() {
@Test
public void testCreateFederatedShareWithNonExistingSharee() {
RemoteOperationResult result = new CreateShareRemoteOperation(mFullPath2FileToShare,
ShareType.FEDERATED,
"no_exist@" + serverUri2,
false,
"",
31).execute(client);
ShareType.FEDERATED,
"no_exist@" + serverUri2,
false,
"",
31).execute(client);

assertFalse("sharee doesn't exist in an existing remote server", result.isSuccess());
assertEquals("sharee doesn't exist in an existing remote server, forbidden",
RemoteOperationResult.ResultCode.SHARE_FORBIDDEN, result.getCode());
RemoteOperationResult.ResultCode.SHARE_FORBIDDEN, result.getCode());
}

/**
Expand All @@ -219,11 +221,11 @@ public void testCreateFederatedShareWithNonExistingSharee() {
@Test
public void testCreateFederatedShareWithNonExistingRemoteServer() {
RemoteOperationResult result = new CreateShareRemoteOperation(mFullPath2FileToShare,
ShareType.FEDERATED,
"no_exist",
false,
"",
31).execute(client);
ShareType.FEDERATED,
"no_exist",
false,
"",
31).execute(client);
assertFalse(result.isSuccess());
// TODO expected:<SHARE_WRONG_PARAMETER> but was:<SHARE_FORBIDDEN>
assertEquals("remote server doesn't exist", ResultCode.SHARE_FORBIDDEN, result.getCode());
Expand All @@ -235,11 +237,11 @@ public void testCreateFederatedShareWithNonExistingRemoteServer() {
@Test
public void testCreateFederatedShareWithNonExistingFile() {
RemoteOperationResult result = new CreateShareRemoteOperation(mFullPath2NonExistentFile,
ShareType.FEDERATED,
"admin@" + serverUri2,
false,
"",
31).execute(client);
ShareType.FEDERATED,
"admin@" + serverUri2,
false,
"",
31).execute(client);

assertFalse("file doesn't exist", result.isSuccess());
assertEquals("file doesn't exist", ResultCode.FILE_NOT_FOUND, result.getCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ public class RemoveShareIT extends AbstractIT {
@Test
public void testRemoveShare() throws IOException {
File textFile = getFile(ASSETS__TEXT_FILE_NAME);
assertTrue(new UploadFileRemoteOperation(textFile.getAbsolutePath(),
assertTrue(new UploadFileRemoteOperation(
textFile.getAbsolutePath(),
FILE_TO_UNSHARE,
"txt/plain",
String.valueOf(System.currentTimeMillis() / MILLI_TO_SECOND))
.execute(client).isSuccess());
System.currentTimeMillis() / MILLI_TO_SECOND
).execute(client).isSuccess());

RemoteOperationResult<List<OCShare>> result = new CreateShareRemoteOperation(FILE_TO_UNSHARE,
ShareType.PUBLIC_LINK,
Expand Down
Loading