Skip to content

Commit 383b867

Browse files
- deleted recently_added_search: we cannot filter by creation-date as we only have modification date
- delete shared_search: will be replaced by a decent endpoint - extract SearchMethod - wrote test for all remaining search types Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
1 parent 9eee920 commit 383b867

File tree

6 files changed

+684
-251
lines changed

6 files changed

+684
-251
lines changed

src/androidTest/java/com/owncloud/android/AbstractIT.java

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,67 @@
77
import com.owncloud.android.lib.common.OwnCloudBasicCredentials;
88
import com.owncloud.android.lib.common.OwnCloudClient;
99
import com.owncloud.android.lib.common.OwnCloudClientFactory;
10+
import com.owncloud.android.lib.resources.files.ReadFolderRemoteOperation;
11+
import com.owncloud.android.lib.resources.files.RemoveFileRemoteOperation;
12+
import com.owncloud.android.lib.resources.files.model.RemoteFile;
1013

14+
import org.junit.After;
1115
import org.junit.BeforeClass;
1216
import org.junit.runner.RunWith;
1317

18+
import java.io.File;
19+
import java.io.IOException;
20+
import java.util.ArrayList;
21+
1422
import androidx.test.ext.junit.runners.AndroidJUnit4;
1523
import androidx.test.platform.app.InstrumentationRegistry;
1624

25+
import static junit.framework.TestCase.assertTrue;
26+
1727
/**
1828
* Common base for all integration tests
1929
*/
2030

2131
@RunWith(AndroidJUnit4.class)
2232
public abstract class AbstractIT {
23-
static OwnCloudClient client;
33+
protected static OwnCloudClient client;
34+
protected static String userId;
35+
protected static Context context;
2436

2537
@BeforeClass
2638
public static void beforeAll() {
2739
Bundle arguments = InstrumentationRegistry.getArguments();
28-
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
40+
context = InstrumentationRegistry.getInstrumentation().getTargetContext();
2941

3042
Uri url = Uri.parse(arguments.getString("TEST_SERVER_URL"));
31-
String username = arguments.getString("TEST_SERVER_USERNAME");
43+
userId = arguments.getString("TEST_SERVER_USERNAME");
3244
String password = arguments.getString("TEST_SERVER_PASSWORD");
3345

3446
client = OwnCloudClientFactory.createOwnCloudClient(url, context, true);
35-
client.setCredentials(new OwnCloudBasicCredentials(username, password));
47+
client.setCredentials(new OwnCloudBasicCredentials(userId, password));
48+
}
49+
50+
public String createFile(String name) throws IOException {
51+
File tempDir = context.getFilesDir();
52+
53+
File file = new File(tempDir + File.separator + name);
54+
file.createNewFile();
55+
56+
assertTrue(file.exists());
57+
58+
return file.getAbsolutePath();
59+
}
60+
61+
@After
62+
public void after() {
63+
ArrayList list = new ReadFolderRemoteOperation("/").execute(client).getData();
64+
65+
for (Object object : list) {
66+
RemoteFile remoteFile = (RemoteFile) object;
67+
68+
if (!remoteFile.getRemotePath().equals("/")) {
69+
new RemoveFileRemoteOperation(remoteFile.getRemotePath()).execute(client);
70+
}
71+
}
3672
}
3773
}

src/androidTest/java/com/owncloud/android/ExceptionParserIT.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,16 @@
44

55
import org.junit.Assert;
66
import org.junit.Test;
7-
import org.junit.runner.RunWith;
87

98
import java.io.ByteArrayInputStream;
109
import java.io.IOException;
1110
import java.io.InputStream;
1211

13-
import androidx.test.ext.junit.runners.AndroidJUnit4;
14-
1512

1613
/**
1714
* Created by tobi on 3/21/18.
1815
*/
1916

20-
@RunWith(AndroidJUnit4.class)
2117
public class ExceptionParserIT {
2218

2319
@Test

src/androidTest/java/com/owncloud/android/FileIT.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,13 @@
77
import com.owncloud.android.lib.resources.files.RemoveFileRemoteOperation;
88

99
import org.junit.Test;
10-
import org.junit.runner.RunWith;
11-
12-
import androidx.test.ext.junit.runners.AndroidJUnit4;
1310

1411
import static org.junit.Assert.assertFalse;
1512
import static org.junit.Assert.assertTrue;
1613

1714
/**
1815
* Tests related to file operations
1916
*/
20-
@RunWith(AndroidJUnit4.class)
2117
public class FileIT extends AbstractIT {
2218
@Test
2319
public void testCreateFolderSuccess() {

0 commit comments

Comments
 (0)