|
9 | 9 | import java.util.Locale; |
10 | 10 |
|
11 | 11 | import com.dropbox.core.util.IOUtil.ProgressListener; |
| 12 | + |
| 13 | +import org.junit.After; |
12 | 14 | import org.testng.annotations.Test; |
13 | 15 |
|
14 | 16 | import com.dropbox.core.BadRequestException; |
@@ -101,25 +103,28 @@ private void testUploadAndDownload(DbxClientV2 client, boolean trackProgress) th |
101 | 103 | Metadata actual = client.files().getMetadata(path); |
102 | 104 | assertWithMessage(actual.getClass().getCanonicalName()).that(actual instanceof FileMetadata).isTrue(); |
103 | 105 |
|
104 | | - // Ignore parentSharedFolderId field; CDM users will fail that check due to nature of CDM member folder. |
105 | | - assertThat(actual.getName()).isEqualTo(metadata.getName()); |
106 | | - assertThat(actual.getPathLower()).isEqualTo(metadata.getPathLower()); |
107 | | - assertThat(actual.getPathDisplay()).isEqualTo(metadata.getPathDisplay()); |
| 106 | + try { |
| 107 | + assertThat(actual).isEqualTo(metadata); |
108 | 108 |
|
109 | | - if (trackProgress) { |
110 | | - progressListener = createTestListener(contents.length); |
111 | | - } |
| 109 | + if (trackProgress) { |
| 110 | + progressListener = createTestListener(contents.length); |
| 111 | + } |
112 | 112 |
|
113 | | - DbxDownloader<FileMetadata> downloader = client.files().download(path); |
114 | | - ByteArrayOutputStream out = new ByteArrayOutputStream(); |
115 | | - downloader.download(out, progressListener); |
| 113 | + DbxDownloader<FileMetadata> downloader = client.files().download(path); |
| 114 | + ByteArrayOutputStream out = new ByteArrayOutputStream(); |
| 115 | + downloader.download(out, progressListener); |
116 | 116 |
|
117 | | - byte [] actualContents = out.toByteArray(); |
118 | | - FileMetadata actualResult = downloader.getResult(); |
| 117 | + byte[] actualContents = out.toByteArray(); |
| 118 | + FileMetadata actualResult = downloader.getResult(); |
119 | 119 |
|
120 | | - assertThat(actualResult).isEqualTo(metadata); |
121 | | - assertThat(actualContents).isEqualTo(contents); |
122 | | - assertThat(downloader.getContentType()).isEqualTo("application/octet-stream"); |
| 120 | + assertThat(actualResult).isEqualTo(metadata); |
| 121 | + assertThat(actualContents).isEqualTo(contents); |
| 122 | + assertThat(downloader.getContentType()).isEqualTo("application/octet-stream"); |
| 123 | + } catch (AssertionError e) { |
| 124 | + // so subsequent tests don't fail due to file not being cleaned up |
| 125 | + client.files().deleteV2(path).getMetadata(); |
| 126 | + throw e; |
| 127 | + } |
123 | 128 |
|
124 | 129 | Metadata deleted = client.files().deleteV2(path).getMetadata(); |
125 | 130 | assertThat(deleted).isEqualTo(metadata); |
|
0 commit comments