Skip to content

Commit

Permalink
Merge pull request #781 from nextcloud/backport/780/stable-2.8
Browse files Browse the repository at this point in the history
[stable-2.8] Enhance tests for master server
  • Loading branch information
AlvaroBrey authored Dec 10, 2021
2 parents c7c1ae1 + ff6ab37 commit 7ad15f8
Show file tree
Hide file tree
Showing 27 changed files with 115 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@

package com.nextcloud.android.lib.resources.directediting;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import com.owncloud.android.AbstractIT;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;

import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class DirectEditingCreateFileRemoteOperationTest extends AbstractIT {
public class DirectEditingCreateFileRemoteOperationIT extends AbstractIT {
@Test
public void createEmptyFile() {
RemoteOperationResult<String> result = new DirectEditingCreateFileRemoteOperation("/test.md",
"text",
"textdocument")
"text",
"textdocument")
.execute(client);
assertTrue(result.isSuccess());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@

package com.nextcloud.android.lib.resources.directediting;

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

import com.owncloud.android.AbstractIT;
import com.owncloud.android.lib.common.TemplateList;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;

import org.junit.Test;

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

public class DirectEditingObtainListOfTemplatesRemoteOperationTest extends AbstractIT {
public class DirectEditingObtainListOfTemplatesRemoteOperationIT extends AbstractIT {

@Test
public void testGetAll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@

package com.nextcloud.android.lib.resources.directediting;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import com.owncloud.android.AbstractIT;
import com.owncloud.android.lib.common.Creator;
import com.owncloud.android.lib.common.DirectEditing;
Expand All @@ -31,12 +36,7 @@

import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class DirectEditingObtainRemoteOperationTest extends AbstractIT {
public class DirectEditingObtainRemoteOperationIT extends AbstractIT {

@Test
public void testGetAll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

package com.nextcloud.android.lib.resources.directediting;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import com.owncloud.android.AbstractIT;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation;
Expand All @@ -38,17 +41,14 @@

import java.io.IOException;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class DirectEditingOpenFileRemoteOperationTest extends AbstractIT {
public class DirectEditingOpenFileRemoteOperationIT extends AbstractIT {
@Test
public void openFile() throws IOException {
// create file
String filePath = createFile("text");
String remotePath = "/text.md";
TestCase.assertTrue(new UploadFileRemoteOperation(filePath, remotePath, "text/markdown", "123")
.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,7 +66,7 @@ public void openFileWithSpecialChars() throws IOException {
// create file
String filePath = createFile("text");
String remotePath = "/äää.md";
TestCase.assertTrue(new UploadFileRemoteOperation(filePath, remotePath, "text/markdown", "123")
TestCase.assertTrue(new UploadFileRemoteOperation(filePath, remotePath, "text/markdown", "1464818400")
.execute(client).isSuccess());

TestCase.assertTrue(new ReadFileRemoteOperation(remotePath).execute(client).isSuccess());
Expand All @@ -85,7 +85,7 @@ public void openFileWithSpecialChars2() throws IOException {
// create file
String filePath = createFile("text");
String remotePath = "/あ.md";
TestCase.assertTrue(new UploadFileRemoteOperation(filePath, remotePath, "text/markdown", "123")
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 @@ -32,7 +32,7 @@ import org.junit.Assert.assertTrue
import org.junit.Assume.assumeTrue
import org.junit.Test

class SearchProvidersRemoteOperationTest : AbstractIT() {
class SearchProvidersRemoteOperationIT : AbstractIT() {
@Test
fun getSearchProviders() {
// only on NC20+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@

package com.nextcloud.android.lib.resources.users;

import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertNotEquals;

import android.text.TextUtils;

import com.owncloud.android.AbstractIT;
Expand All @@ -37,11 +41,7 @@

import org.junit.Test;

import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertNotEquals;

public class GenerateAppPasswordRemoteOperationTest extends AbstractIT {
public class GenerateAppPasswordRemoteOperationIT extends AbstractIT {

@Test
public void generateAppPassword() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

package com.nextcloud.android.lib.richWorkspace;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import android.webkit.URLUtil;

import com.owncloud.android.AbstractIT;
Expand All @@ -33,10 +36,7 @@
import java.io.File;
import java.io.IOException;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class RichWorkspaceDirectEditingRemoteOperationTest extends AbstractIT {
public class RichWorkspaceDirectEditingRemoteOperationIT extends AbstractIT {

@Test
public void getEditLinkForRoot() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test

class GetUserInfoRemoteOperationTest : AbstractIT() {
class GetUserInfoRemoteOperationIT : AbstractIT() {
@Test
fun testGetUserNoQuota() {
nextcloudClient.credentials = Credentials.basic("user1", "user1")
Expand Down
7 changes: 4 additions & 3 deletions src/androidTest/java/com/owncloud/android/AbstractIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
*/
package com.owncloud.android;

import static junit.framework.TestCase.assertTrue;

import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
Expand Down Expand Up @@ -66,17 +68,16 @@

import okhttp3.Credentials;

import static junit.framework.TestCase.assertTrue;

/**
* Common base for all integration tests
*/

public abstract class AbstractIT {
@Rule
public RetryTestRule retryTestRule = new RetryTestRule();

private static final int BUFFER_SIZE = 1024;
public static final String RANDOM_MTIME = "1464818400";

public static OwnCloudClient client;
protected static NextcloudClient nextcloudClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
*/
package com.owncloud.android;

import static org.junit.Assert.assertTrue;

import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation;
import com.owncloud.android.lib.resources.files.RemoveFileRemoteOperation;
Expand All @@ -37,13 +39,11 @@

import java.io.File;

import static org.junit.Assert.assertTrue;

/**
* Class to test Delete a File Operation
*/

public class DeleteFileTest extends AbstractIT {
public class DeleteFileIT extends AbstractIT {
/* Folder data to delete. */
private static final String FOLDER_PATH = "/folderToDelete";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
*/
package com.owncloud.android.lib.common.operations;

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

import com.owncloud.android.AbstractIT;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.resources.files.UploadFileRemoteOperation;
Expand All @@ -37,14 +41,10 @@

import java.io.File;

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

/**
* Test create share
*/
public class CreateShareTest extends AbstractIT {
public class CreateShareIT extends AbstractIT {
private static final String NON_EXISTENT_FILE = "/nonExistentFile.txt";
private static final String serverUri2 = "server2";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
*/
package com.owncloud.android.lib.common.operations;

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

import com.owncloud.android.AbstractIT;
import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation;
import com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation;
Expand All @@ -37,25 +40,22 @@

import java.util.List;

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

/**
* Class to test Get Shares Operation
*
* @author masensio
*/

public class GetSharesTest extends AbstractIT {
@Test
public class GetSharesIT extends AbstractIT {
@Test
public void testGetShares() {
assertTrue(new CreateFolderRemoteOperation("/1/", true).execute(client).isSuccess());
assertTrue(new CreateShareRemoteOperation("/1/",
ShareType.PUBLIC_LINK,
"",
false,
"",
1).execute(client).isSuccess());
ShareType.PUBLIC_LINK,
"",
false,
"",
1).execute(client).isSuccess());

assertTrue(new CreateFolderRemoteOperation("/2/", true).execute(client).isSuccess());
assertTrue(new CreateShareRemoteOperation("/2/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@
*/
package com.owncloud.android.lib.common.operations;

import static org.junit.Assert.assertTrue;

import com.owncloud.android.AbstractIT;
import com.owncloud.android.lib.common.Quota;
import com.owncloud.android.lib.common.UserInfo;
import com.owncloud.android.lib.resources.users.GetUserInfoRemoteOperation;

import org.junit.Test;

import static org.junit.Assert.assertTrue;


/**
* Class to test Get User Quota
*
* @author Bartosz Przybylski
*/
public class GetUserQuotaTest extends AbstractIT {
public class GetUserQuotaIT extends AbstractIT {

@Test
public void testGetUserQuota() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
*/
package com.owncloud.android.lib.common.operations;

import static org.junit.Assert.assertTrue;

import com.owncloud.android.AbstractIT;
import com.owncloud.android.lib.resources.files.UploadFileRemoteOperation;
import com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation;
Expand All @@ -39,9 +41,7 @@
import java.io.IOException;
import java.util.List;

import static org.junit.Assert.assertTrue;

public class RemoveShareTest extends AbstractIT {
public class RemoveShareIT extends AbstractIT {
private static final String FILE_TO_UNSHARE = "/fileToUnshare.txt";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CommentFileRemoteOperationIT : AbstractIT() {
val filePath: String = createFile("commentFile")
val remotePath = "/commentFile.txt"
assertTrue(
UploadFileRemoteOperation(filePath, remotePath, "image/jpg", "123")
UploadFileRemoteOperation(filePath, remotePath, "image/jpg", RANDOM_MTIME)
.execute(client).isSuccess
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@

package com.owncloud.android.lib.resources.e2ee;

import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertNotNull;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assume.assumeTrue;

import android.text.TextUtils;

import com.owncloud.android.AbstractIT;
Expand All @@ -37,13 +43,7 @@

import org.junit.Test;

import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertNotNull;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assume.assumeTrue;

public class UpdateMetadataRemoteOperationTest extends AbstractIT {
public class UpdateMetadataRemoteOperationIT extends AbstractIT {
@Test
public void uploadAndModify() {
// tests only for NC19+
Expand Down
Loading

0 comments on commit 7ad15f8

Please sign in to comment.