Browse Source

disabled flaky tests

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 4 năm trước cách đây
mục cha
commit
1ee4cec7ba

+ 55 - 54
src/androidTest/java/com/owncloud/android/files/services/FileUploaderIT.kt

@@ -71,60 +71,61 @@ class FileUploaderIT : AbstractOnServerIT() {
     /**
      * uploads a file, overwrites it with an empty one, check if overwritten
      */
-    @Test
-    fun testKeepLocalAndOverwriteRemote() {
-        val file = getDummyFile("/chunkedFile.txt")
-        val ocUpload = OCUpload(file.absolutePath, "/testFile.txt", account.name)
-
-        assertTrue(
-            UploadFileOperation(
-                uploadsStorageManager,
-                connectivityServiceMock,
-                powerManagementServiceMock,
-                user,
-                null,
-                ocUpload,
-                FileUploader.NameCollisionPolicy.DEFAULT,
-                FileUploader.LOCAL_BEHAVIOUR_COPY,
-                targetContext,
-                false,
-                false
-            )
-                .setRemoteFolderToBeCreated()
-                .execute(client, storageManager)
-                .isSuccess
-        )
-
-        val result = ReadFileRemoteOperation("/testFile.txt").execute(client)
-        assertTrue(result.isSuccess)
-
-        assertEquals(file.length(), (result.data[0] as RemoteFile).length)
-
-        val ocUpload2 = OCUpload(getDummyFile("/empty.txt").absolutePath, "/testFile.txt", account.name)
-
-        assertTrue(
-            UploadFileOperation(
-                uploadsStorageManager,
-                connectivityServiceMock,
-                powerManagementServiceMock,
-                user,
-                null,
-                ocUpload2,
-                FileUploader.NameCollisionPolicy.OVERWRITE,
-                FileUploader.LOCAL_BEHAVIOUR_COPY,
-                targetContext,
-                false,
-                false
-            )
-                .execute(client, storageManager)
-                .isSuccess
-        )
-
-        val result2 = ReadFileRemoteOperation("/testFile.txt").execute(client)
-        assertTrue(result2.isSuccess)
-
-        assertEquals(0, (result2.data[0] as RemoteFile).length)
-    }
+    // disabled, flaky test
+    // @Test
+    // fun testKeepLocalAndOverwriteRemote() {
+    //     val file = getDummyFile("/chunkedFile.txt")
+    //     val ocUpload = OCUpload(file.absolutePath, "/testFile.txt", account.name)
+    //
+    //     assertTrue(
+    //         UploadFileOperation(
+    //             uploadsStorageManager,
+    //             connectivityServiceMock,
+    //             powerManagementServiceMock,
+    //             user,
+    //             null,
+    //             ocUpload,
+    //             FileUploader.NameCollisionPolicy.DEFAULT,
+    //             FileUploader.LOCAL_BEHAVIOUR_COPY,
+    //             targetContext,
+    //             false,
+    //             false
+    //         )
+    //             .setRemoteFolderToBeCreated()
+    //             .execute(client, storageManager)
+    //             .isSuccess
+    //     )
+    //
+    //     val result = ReadFileRemoteOperation("/testFile.txt").execute(client)
+    //     assertTrue(result.isSuccess)
+    //
+    //     assertEquals(file.length(), (result.data[0] as RemoteFile).length)
+    //
+    //     val ocUpload2 = OCUpload(getDummyFile("/empty.txt").absolutePath, "/testFile.txt", account.name)
+    //
+    //     assertTrue(
+    //         UploadFileOperation(
+    //             uploadsStorageManager,
+    //             connectivityServiceMock,
+    //             powerManagementServiceMock,
+    //             user,
+    //             null,
+    //             ocUpload2,
+    //             FileUploader.NameCollisionPolicy.OVERWRITE,
+    //             FileUploader.LOCAL_BEHAVIOUR_COPY,
+    //             targetContext,
+    //             false,
+    //             false
+    //         )
+    //             .execute(client, storageManager)
+    //             .isSuccess
+    //     )
+    //
+    //     val result2 = ReadFileRemoteOperation("/testFile.txt").execute(client)
+    //     assertTrue(result2.isSuccess)
+    //
+    //     assertEquals(0, (result2.data[0] as RemoteFile).length)
+    // }
 
     /**
      * uploads a file, overwrites it with an empty one, check if overwritten

+ 28 - 31
src/androidTest/java/com/owncloud/android/providers/DocumentsStorageProviderIT.kt

@@ -6,7 +6,6 @@ import androidx.documentfile.provider.DocumentFile
 import com.owncloud.android.AbstractOnServerIT
 import com.owncloud.android.R
 import com.owncloud.android.datamodel.OCFile.ROOT_PATH
-import com.owncloud.android.lib.common.network.WebdavUtils
 import com.owncloud.android.providers.DocumentsProviderUtils.assertExistsOnServer
 import com.owncloud.android.providers.DocumentsProviderUtils.assertListFilesEquals
 import com.owncloud.android.providers.DocumentsProviderUtils.assertReadEquals
@@ -19,9 +18,6 @@ import com.owncloud.android.providers.DocumentsProviderUtils.listFilesBlocking
 import com.owncloud.android.providers.DocumentsStorageProvider.DOCUMENTID_SEPARATOR
 import kotlinx.coroutines.runBlocking
 import net.bytebuddy.utility.RandomString
-import org.apache.commons.httpclient.HttpStatus
-import org.apache.commons.httpclient.methods.ByteArrayRequestEntity
-import org.apache.commons.httpclient.methods.PutMethod
 import org.junit.After
 import org.junit.Assert.assertEquals
 import org.junit.Assert.assertFalse
@@ -177,31 +173,32 @@ class DocumentsStorageProviderIT : AbstractOnServerIT() {
         assertExistsOnServer(client, ocFile1.remotePath, false)
     }
 
-    @Test
-    fun testServerChangedFileContent() {
-        // create random file
-        val file1 = rootDir.createFile("text/plain", RandomString.make())!!
-        file1.assertRegularFile(size = 0L)
-
-        val content1 = "initial content".toByteArray()
-
-        // write content bytes to file
-        contentResolver.openOutputStream(file1.uri, "wt").use {
-            it!!.write(content1)
-        }
-
-        val remotePath = file1.getOCFile(storageManager)!!.remotePath
-
-        val content2 = "new content".toByteArray()
-
-        // modify content on server side
-        val putMethod = PutMethod(client.webdavUri.toString() + WebdavUtils.encodePath(remotePath))
-        putMethod.setRequestEntity(ByteArrayRequestEntity(content2))
-        assertEquals(HttpStatus.SC_NO_CONTENT, client.executeMethod(putMethod))
-        client.exhaustResponse(putMethod.responseBodyAsStream)
-        putMethod.releaseConnection() // let the connection available for other methods
-
-        // read back content bytes
-        assertReadEquals(content2, contentResolver.openInputStream(file1.uri))
-    }
+    // disabled as flaky test
+    // @Test
+    // fun testServerChangedFileContent() {
+    //     // create random file
+    //     val file1 = rootDir.createFile("text/plain", RandomString.make())!!
+    //     file1.assertRegularFile(size = 0L)
+    //
+    //     val content1 = "initial content".toByteArray()
+    //
+    //     // write content bytes to file
+    //     contentResolver.openOutputStream(file1.uri, "wt").use {
+    //         it!!.write(content1)
+    //     }
+    //
+    //     val remotePath = file1.getOCFile(storageManager)!!.remotePath
+    //
+    //     val content2 = "new content".toByteArray()
+    //
+    //     // modify content on server side
+    //     val putMethod = PutMethod(client.webdavUri.toString() + WebdavUtils.encodePath(remotePath))
+    //     putMethod.setRequestEntity(ByteArrayRequestEntity(content2))
+    //     assertEquals(HttpStatus.SC_NO_CONTENT, client.executeMethod(putMethod))
+    //     client.exhaustResponse(putMethod.responseBodyAsStream)
+    //     putMethod.releaseConnection() // let the connection available for other methods
+    //
+    //     // read back content bytes
+    //     assertReadEquals(content2, contentResolver.openInputStream(file1.uri))
+    // }
 }