1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.documentsui.archives; 18 19 import static com.google.common.truth.Truth.assertThat; 20 import static org.junit.Assert.fail; 21 import static org.mockito.Mockito.mock; 22 import static org.mockito.Mockito.when; 23 24 import android.os.ParcelFileDescriptor; 25 26 import androidx.annotation.NonNull; 27 import androidx.annotation.Nullable; 28 import androidx.test.runner.AndroidJUnit4; 29 30 import java.io.FileInputStream; 31 import java.io.IOException; 32 import java.io.InputStream; 33 import java.util.ArrayList; 34 import java.util.Date; 35 import java.util.Enumeration; 36 import java.util.List; 37 import java.util.Locale; 38 39 import org.apache.commons.compress.archivers.ArchiveEntry; 40 import org.apache.commons.compress.archivers.ArchiveException; 41 import org.apache.commons.compress.compressors.CompressorException; 42 import org.junit.Rule; 43 import org.junit.Test; 44 import org.junit.runner.RunWith; 45 46 @RunWith(AndroidJUnit4.class) 47 public class ArchiveHandleTest { 48 @Rule 49 public ArchiveFileTestRule mArchiveFileTestRule = new ArchiveFileTestRule(); 50 51 prepareArchiveHandle(String archivePath, String suffix, String mimeType)52 private ArchiveHandle prepareArchiveHandle(String archivePath, String suffix, 53 String mimeType) throws IOException, CompressorException, ArchiveException { 54 ParcelFileDescriptor parcelFileDescriptor = mArchiveFileTestRule 55 .openAssetFile(archivePath, suffix); 56 57 return ArchiveHandle.create(parcelFileDescriptor, mimeType); 58 } 59 getFileInArchive(Enumeration<ArchiveEntry> enumeration, String pathInArchive)60 private static ArchiveEntry getFileInArchive(Enumeration<ArchiveEntry> enumeration, 61 String pathInArchive) { 62 while (enumeration.hasMoreElements()) { 63 ArchiveEntry entry = enumeration.nextElement(); 64 if (entry.getName().equals(pathInArchive)) { 65 return entry; 66 } 67 } 68 return null; 69 } 70 71 72 private static class ArchiveEntryRecord implements ArchiveEntry { 73 private final String mName; 74 private final long mSize; 75 private final boolean mIsDirectory; 76 ArchiveEntryRecord(ArchiveEntry archiveEntry)77 private ArchiveEntryRecord(ArchiveEntry archiveEntry) { 78 this(archiveEntry.getName(), archiveEntry.getSize(), archiveEntry.isDirectory()); 79 } 80 ArchiveEntryRecord(String name, long size, boolean isDirectory)81 private ArchiveEntryRecord(String name, long size, boolean isDirectory) { 82 mName = name; 83 mSize = size; 84 mIsDirectory = isDirectory; 85 } 86 87 @Override equals(@ullable Object obj)88 public boolean equals(@Nullable Object obj) { 89 if (obj == null) { 90 return false; 91 } 92 93 if (obj instanceof ArchiveEntryRecord) { 94 ArchiveEntryRecord recordB = (ArchiveEntryRecord) obj; 95 return mName.equals(recordB.mName) 96 && mSize == recordB.mSize 97 && mIsDirectory == recordB.mIsDirectory; 98 } 99 100 return false; 101 } 102 103 @Override getName()104 public String getName() { 105 return mName; 106 } 107 108 @Override getSize()109 public long getSize() { 110 return mSize; 111 } 112 113 @Override isDirectory()114 public boolean isDirectory() { 115 return mIsDirectory; 116 } 117 118 @Override getLastModifiedDate()119 public Date getLastModifiedDate() { 120 return null; 121 } 122 123 @NonNull 124 @Override toString()125 public String toString() { 126 return String.format(Locale.ENGLISH, "name: %s, size: %d, isDirectory: %b", 127 mName, mSize, mIsDirectory); 128 } 129 } 130 transformToIterable(Enumeration<ArchiveEntry> enumeration)131 private static List<ArchiveEntry> transformToIterable(Enumeration<ArchiveEntry> enumeration) { 132 List list = new ArrayList<ArchiveEntry>(); 133 while (enumeration.hasMoreElements()) { 134 list.add(new ArchiveEntryRecord(enumeration.nextElement())); 135 } 136 return list; 137 } 138 139 private static final List<ArchiveEntryRecord> sExpectEntries = 140 new ArrayList<ArchiveEntryRecord>() { 141 { 142 add(new ArchiveEntryRecord("hello/hello.txt", 48, false)); 143 add(new ArchiveEntryRecord("hello/inside_folder/hello_insside.txt", 144 14, false)); 145 add(new ArchiveEntryRecord("hello/hello2.txt", 48, false)); 146 } 147 }; 148 149 150 @Test buildArchiveHandle_withoutFileDescriptor_shouldBeIllegal()151 public void buildArchiveHandle_withoutFileDescriptor_shouldBeIllegal() throws Exception { 152 try { 153 ArchiveHandle.create(null, 154 "application/x-7z-compressed"); 155 fail("It should not be here!"); 156 } catch (NullPointerException e) { 157 /* do nothing */ 158 } 159 } 160 161 @Test buildArchiveHandle_withWrongMimeType_shouldBeIllegal()162 public void buildArchiveHandle_withWrongMimeType_shouldBeIllegal() throws Exception { 163 ParcelFileDescriptor parcelFileDescriptor = mArchiveFileTestRule 164 .openAssetFile("archives/7z/hello.7z", ".7z"); 165 166 try { 167 ArchiveHandle.create(parcelFileDescriptor, null); 168 fail("It should not be here!"); 169 } catch (IllegalArgumentException e) { 170 /* do nothing */ 171 } 172 } 173 174 @Test buildArchiveHandle_sevenZFile_shouldNotNull()175 public void buildArchiveHandle_sevenZFile_shouldNotNull() throws Exception { 176 ArchiveHandle archiveHandle = prepareArchiveHandle("archives/7z/hello.7z", 177 ".7z", "application/x-7z-compressed"); 178 179 assertThat(archiveHandle).isNotNull(); 180 } 181 182 @Test buildArchiveHandle_zipFile_shouldNotNull()183 public void buildArchiveHandle_zipFile_shouldNotNull() throws Exception { 184 ArchiveHandle archiveHandle = prepareArchiveHandle("archives/zip/hello.zip", 185 ".zip", "application/zip"); 186 187 assertThat(archiveHandle).isNotNull(); 188 } 189 190 @Test buildArchiveHandle_zipWithWrongMimeType_shouldBeNull()191 public void buildArchiveHandle_zipWithWrongMimeType_shouldBeNull() throws Exception { 192 try { 193 prepareArchiveHandle("archives/zip/hello.zip", 194 ".zip", "application/xxxzip"); 195 fail("It should not be here!"); 196 } catch (UnsupportedOperationException e) { 197 /* do nothing */ 198 } 199 } 200 201 @Test buildArchiveHandle_tarFile_shouldNotNull()202 public void buildArchiveHandle_tarFile_shouldNotNull() throws Exception { 203 ArchiveHandle archiveHandle = prepareArchiveHandle("archives/tar/hello.tar", 204 ".tar","application/x-gtar"); 205 206 assertThat(archiveHandle).isNotNull(); 207 } 208 209 @Test buildArchiveHandle_tgzFile_shouldNotNull()210 public void buildArchiveHandle_tgzFile_shouldNotNull() throws Exception { 211 ArchiveHandle archiveHandle = prepareArchiveHandle("archives/tar_gz/hello.tgz", 212 ".tgz", "application/x-compressed-tar"); 213 214 assertThat(archiveHandle).isNotNull(); 215 } 216 217 @Test buildArchiveHandle_tarGzFile_shouldNotNull()218 public void buildArchiveHandle_tarGzFile_shouldNotNull() throws Exception { 219 ArchiveHandle archiveHandle = 220 prepareArchiveHandle("archives/tar_gz/hello_tar_gz", ".tar.gz", 221 "application/x-compressed-tar"); 222 223 assertThat(archiveHandle).isNotNull(); 224 } 225 226 @Test buildArchiveHandle_tarBzipFile_shouldNotNull()227 public void buildArchiveHandle_tarBzipFile_shouldNotNull() throws Exception { 228 ArchiveHandle archiveHandle = 229 prepareArchiveHandle("archives/tar_bz2/hello.tar.bz2", 230 ".tar.bz2", "application/x-bzip-compressed-tar"); 231 232 assertThat(archiveHandle).isNotNull(); 233 } 234 235 @Test buildArchiveHandle_tarXzFile_shouldNotNull()236 public void buildArchiveHandle_tarXzFile_shouldNotNull() throws Exception { 237 ArchiveHandle archiveHandle = 238 prepareArchiveHandle("archives/xz/hello.tar.xz", ".tar.xz", 239 "application/x-xz-compressed-tar"); 240 241 assertThat(archiveHandle).isNotNull(); 242 } 243 244 @Test buildArchiveHandle_tarBrFile_shouldNotNull()245 public void buildArchiveHandle_tarBrFile_shouldNotNull() throws Exception { 246 ArchiveHandle archiveHandle = 247 prepareArchiveHandle("archives/brotli/hello.tar.br", ".tar.br", 248 "application/x-brotli-compressed-tar"); 249 250 assertThat(archiveHandle).isNotNull(); 251 } 252 253 @Test getMimeType_sevenZFile_shouldBeSevenZ()254 public void getMimeType_sevenZFile_shouldBeSevenZ() 255 throws CompressorException, ArchiveException, IOException { 256 ArchiveHandle archiveHandle = prepareArchiveHandle("archives/7z/hello.7z", 257 ".7z", "application/x-7z-compressed"); 258 259 assertThat(archiveHandle.getMimeType()).isEqualTo("application/x-7z-compressed"); 260 } 261 262 @Test getMimeType_tarBrotli_shouldBeBrotliCompressedTar()263 public void getMimeType_tarBrotli_shouldBeBrotliCompressedTar() 264 throws CompressorException, ArchiveException, IOException { 265 ArchiveHandle archiveHandle = 266 prepareArchiveHandle("archives/brotli/hello.tar.br", ".tar.br", 267 "application/x-brotli-compressed-tar"); 268 269 assertThat(archiveHandle.getMimeType()) 270 .isEqualTo("application/x-brotli-compressed-tar"); 271 } 272 273 @Test getMimeType_tarXz_shouldBeXzCompressedTar()274 public void getMimeType_tarXz_shouldBeXzCompressedTar() 275 throws CompressorException, ArchiveException, IOException { 276 ArchiveHandle archiveHandle = 277 prepareArchiveHandle("archives/xz/hello.tar.xz", ".tar.xz", 278 "application/x-xz-compressed-tar"); 279 280 assertThat(archiveHandle.getMimeType()) 281 .isEqualTo("application/x-xz-compressed-tar"); 282 } 283 284 @Test getMimeType_tarGz_shouldBeCompressedTar()285 public void getMimeType_tarGz_shouldBeCompressedTar() 286 throws CompressorException, ArchiveException, IOException { 287 ArchiveHandle archiveHandle = 288 prepareArchiveHandle("archives/tar_gz/hello_tar_gz", ".tar.gz", 289 "application/x-compressed-tar"); 290 291 assertThat(archiveHandle.getMimeType()) 292 .isEqualTo("application/x-compressed-tar"); 293 } 294 295 @Test getCommonArchive_tarBrFile_shouldBeCommonArchiveInputHandle()296 public void getCommonArchive_tarBrFile_shouldBeCommonArchiveInputHandle() throws Exception { 297 ArchiveHandle archiveHandle = 298 prepareArchiveHandle("archives/brotli/hello.tar.br", ".tar.br", 299 "application/x-brotli-compressed-tar"); 300 301 assertThat(archiveHandle.toString()).contains("CommonArchiveInputHandle"); 302 } 303 304 @Test getCommonArchive_sevenZFile_shouldBeSevenZFileHandle()305 public void getCommonArchive_sevenZFile_shouldBeSevenZFileHandle() throws Exception { 306 ArchiveHandle archiveHandle = prepareArchiveHandle("archives/7z/hello.7z", 307 ".7z", "application/x-7z-compressed"); 308 309 assertThat(archiveHandle.toString()).contains("SevenZFileHandle"); 310 } 311 312 313 @Test getCommonArchive_zipFile_shouldBeZipFileHandle()314 public void getCommonArchive_zipFile_shouldBeZipFileHandle() throws Exception { 315 ArchiveHandle archiveHandle = prepareArchiveHandle("archives/zip/hello.zip", 316 ".zip", "application/zip"); 317 318 assertThat(archiveHandle.toString()).contains("ZipFileHandle"); 319 } 320 321 @Test close_zipFile_shouldBeSuccess()322 public void close_zipFile_shouldBeSuccess() throws Exception { 323 ArchiveHandle archiveHandle = prepareArchiveHandle("archives/zip/hello.zip", 324 ".zip", "application/zip"); 325 326 archiveHandle.close(); 327 } 328 329 @Test close_sevenZFile_shouldBeSuccess()330 public void close_sevenZFile_shouldBeSuccess() throws Exception { 331 ArchiveHandle archiveHandle = prepareArchiveHandle("archives/7z/hello.7z", 332 ".7z", "application/x-7z-compressed"); 333 334 archiveHandle.close(); 335 } 336 337 @Test closeInputStream_zipFile_shouldBeSuccess()338 public void closeInputStream_zipFile_shouldBeSuccess() throws Exception { 339 ArchiveHandle archiveHandle = prepareArchiveHandle("archives/zip/hello.zip", 340 ".zip", "application/zip"); 341 342 InputStream inputStream = archiveHandle.getInputStream( 343 getFileInArchive(archiveHandle.getEntries(), 344 "hello/inside_folder/hello_insside.txt")); 345 346 assertThat(inputStream).isNotNull(); 347 348 inputStream.close(); 349 } 350 351 @Test close_zipFile_shouldNotOpen()352 public void close_zipFile_shouldNotOpen() throws Exception { 353 ParcelFileDescriptor parcelFileDescriptor = mArchiveFileTestRule 354 .openAssetFile("archives/zip/hello.zip", ".zip"); 355 356 ArchiveHandle archiveHandle = ArchiveHandle.create(parcelFileDescriptor, 357 "application/zip"); 358 359 archiveHandle.close(); 360 361 FileInputStream fileInputStream = 362 new FileInputStream(parcelFileDescriptor.getFileDescriptor()); 363 assertThat(fileInputStream).isNotNull(); 364 } 365 366 @Test getInputStream_zipFile_shouldHaveTheSameContent()367 public void getInputStream_zipFile_shouldHaveTheSameContent() throws Exception { 368 ParcelFileDescriptor parcelFileDescriptor = mArchiveFileTestRule 369 .openAssetFile("archives/zip/hello.zip", ".zip"); 370 371 String expectedContent = mArchiveFileTestRule.getAssetText( 372 "archives/original/hello/inside_folder/hello_insside.txt"); 373 374 ArchiveHandle archiveHandle = ArchiveHandle.create(parcelFileDescriptor, 375 "application/zip"); 376 377 InputStream inputStream = archiveHandle.getInputStream( 378 getFileInArchive(archiveHandle.getEntries(), 379 "hello/inside_folder/hello_insside.txt")); 380 381 assertThat(ArchiveFileTestRule.getStringFromInputStream(inputStream)) 382 .isEqualTo(expectedContent); 383 } 384 385 @Test getInputStream_zipFileNotExistEntry_shouldFail()386 public void getInputStream_zipFileNotExistEntry_shouldFail() throws Exception { 387 ArchiveHandle archiveHandle = prepareArchiveHandle("archives/zip/hello.zip", 388 ".zip", "application/zip"); 389 390 ArchiveEntry archiveEntry = mock(ArchiveEntry.class); 391 when(archiveEntry.getName()).thenReturn("/not_exist_entry"); 392 393 try { 394 archiveHandle.getInputStream(archiveEntry); 395 fail("It should not be here."); 396 } catch (IllegalArgumentException | ArchiveException | CompressorException e) { 397 /* do nothing */ 398 } 399 } 400 401 @Test getInputStream_directoryEntry_shouldFail()402 public void getInputStream_directoryEntry_shouldFail() throws Exception { 403 ArchiveHandle archiveHandle = prepareArchiveHandle("archives/zip/hello.zip", 404 ".zip", "application/zip"); 405 406 ArchiveEntry archiveEntry = mock(ArchiveEntry.class); 407 when(archiveEntry.isDirectory()).thenReturn(true); 408 409 try { 410 archiveHandle.getInputStream(archiveEntry); 411 fail("It should not be here."); 412 } catch (IllegalArgumentException e) { 413 /* expected, do nothing */ 414 } 415 } 416 417 @Test getInputStream_zeroSizeEntry_shouldFail()418 public void getInputStream_zeroSizeEntry_shouldFail() throws Exception { 419 ArchiveHandle archiveHandle = prepareArchiveHandle("archives/zip/hello.zip", 420 ".zip", "application/zip"); 421 422 ArchiveEntry archiveEntry = mock(ArchiveEntry.class); 423 when(archiveEntry.isDirectory()).thenReturn(false); 424 when(archiveEntry.getSize()).thenReturn(0L); 425 426 try { 427 archiveHandle.getInputStream(archiveEntry); 428 fail("It should not be here."); 429 } catch (IllegalArgumentException e) { 430 /* expected, do nothing */ 431 } 432 } 433 434 @Test getInputStream_emptyStringEntry_shouldFail()435 public void getInputStream_emptyStringEntry_shouldFail() throws Exception { 436 ArchiveHandle archiveHandle = prepareArchiveHandle("archives/zip/hello.zip", 437 ".zip", "application/zip"); 438 439 ArchiveEntry archiveEntry = mock(ArchiveEntry.class); 440 when(archiveEntry.isDirectory()).thenReturn(false); 441 when(archiveEntry.getSize()).thenReturn(14L); 442 when(archiveEntry.getName()).thenReturn(""); 443 444 try { 445 archiveHandle.getInputStream(archiveEntry); 446 fail("It should not be here."); 447 } catch (IllegalArgumentException e) { 448 /* expected, do nothing */ 449 } 450 } 451 452 @Test getInputStream_sevenZFile_shouldHaveTheSameContent()453 public void getInputStream_sevenZFile_shouldHaveTheSameContent() throws Exception { 454 ParcelFileDescriptor parcelFileDescriptor = mArchiveFileTestRule 455 .openAssetFile("archives/7z/hello.7z", ".7z"); 456 457 String expectedContent = mArchiveFileTestRule.getAssetText( 458 "archives/original/hello/inside_folder/hello_insside.txt"); 459 460 ArchiveHandle archiveHandle = ArchiveHandle.create(parcelFileDescriptor, 461 "application/x-7z-compressed"); 462 463 InputStream inputStream = archiveHandle.getInputStream( 464 getFileInArchive(archiveHandle.getEntries(), 465 "hello/inside_folder/hello_insside.txt")); 466 467 assertThat(ArchiveFileTestRule.getStringFromInputStream(inputStream)) 468 .isEqualTo(expectedContent); 469 } 470 471 @Test getInputStream_tarGzFile_shouldHaveTheSameContent()472 public void getInputStream_tarGzFile_shouldHaveTheSameContent() throws Exception { 473 ParcelFileDescriptor parcelFileDescriptor = mArchiveFileTestRule 474 .openAssetFile("archives/tar_gz/hello.tgz", ".tar.gz"); 475 476 String expectedContent = mArchiveFileTestRule.getAssetText( 477 "archives/original/hello/inside_folder/hello_insside.txt"); 478 479 ArchiveHandle archiveHandle = ArchiveHandle.create(parcelFileDescriptor, 480 "application/x-compressed-tar"); 481 482 InputStream inputStream = archiveHandle.getInputStream( 483 getFileInArchive(archiveHandle.getEntries(), 484 "hello/inside_folder/hello_insside.txt")); 485 486 assertThat(ArchiveFileTestRule.getStringFromInputStream(inputStream)) 487 .isEqualTo(expectedContent); 488 } 489 490 @Test getInputStream_tarGzFileNullEntry_getNullInputStream()491 public void getInputStream_tarGzFileNullEntry_getNullInputStream() throws Exception { 492 ParcelFileDescriptor parcelFileDescriptor = mArchiveFileTestRule 493 .openAssetFile("archives/tar_gz/hello.tgz", ".tar.gz"); 494 495 String expectedContent = mArchiveFileTestRule.getAssetText( 496 "archives/original/hello/inside_folder/hello_insside.txt"); 497 498 ArchiveHandle archiveHandle = ArchiveHandle.create(parcelFileDescriptor, 499 "application/x-compressed-tar"); 500 501 try { 502 archiveHandle.getInputStream(null); 503 fail("It should not here"); 504 } catch (IllegalArgumentException | ArchiveException | CompressorException e) { 505 /* expected, do nothing */ 506 } 507 } 508 509 510 @Test getInputStream_tarGzFileInvalidEntry_getNullInputStream()511 public void getInputStream_tarGzFileInvalidEntry_getNullInputStream() throws Exception { 512 ParcelFileDescriptor parcelFileDescriptor = mArchiveFileTestRule 513 .openAssetFile("archives/tar_gz/hello.tgz", ".tar.gz"); 514 515 String expectedContent = mArchiveFileTestRule.getAssetText( 516 "archives/original/hello/inside_folder/hello_insside.txt"); 517 518 ArchiveHandle archiveHandle = ArchiveHandle.create(parcelFileDescriptor, 519 "application/x-compressed-tar"); 520 521 ArchiveEntry archiveEntry = mock(ArchiveEntry.class); 522 when(archiveEntry.getName()).thenReturn(""); 523 try { 524 archiveHandle.getInputStream(archiveEntry); 525 fail("It should not here"); 526 } catch (IllegalArgumentException | ArchiveException | CompressorException e) { 527 /* expected, do nothing */ 528 } 529 } 530 531 @Test getInputStream_tarBrotliFile_shouldHaveTheSameContent()532 public void getInputStream_tarBrotliFile_shouldHaveTheSameContent() throws Exception { 533 ParcelFileDescriptor parcelFileDescriptor = mArchiveFileTestRule 534 .openAssetFile("archives/brotli/hello.tar.br", ".tar.br"); 535 536 String expectedContent = mArchiveFileTestRule.getAssetText( 537 "archives/original/hello/inside_folder/hello_insside.txt"); 538 539 ArchiveHandle archiveHandle = ArchiveHandle.create(parcelFileDescriptor, 540 "application/x-brotli-compressed-tar"); 541 542 InputStream inputStream = archiveHandle.getInputStream( 543 getFileInArchive(archiveHandle.getEntries(), 544 "hello/inside_folder/hello_insside.txt")); 545 546 assertThat(ArchiveFileTestRule.getStringFromInputStream(inputStream)) 547 .isEqualTo(expectedContent); 548 } 549 550 @Test getEntries_zipFile_shouldTheSameWithList()551 public void getEntries_zipFile_shouldTheSameWithList() throws Exception { 552 ArchiveHandle archiveHandle = 553 prepareArchiveHandle("archives/zip/hello.zip", ".zip", 554 "application/zip"); 555 556 assertThat(transformToIterable(archiveHandle.getEntries())) 557 .containsAllIn(sExpectEntries); 558 } 559 560 @Test getEntries_tarFile_shouldTheSameWithList()561 public void getEntries_tarFile_shouldTheSameWithList() throws Exception { 562 ArchiveHandle archiveHandle = 563 prepareArchiveHandle("archives/tar/hello.tar", ".tar", 564 "application/x-gtar"); 565 566 assertThat(transformToIterable(archiveHandle.getEntries())) 567 .containsAllIn(sExpectEntries); 568 } 569 570 @Test getEntries_tgzFile_shouldTheSameWithList()571 public void getEntries_tgzFile_shouldTheSameWithList() throws Exception { 572 ArchiveHandle archiveHandle = 573 prepareArchiveHandle("archives/tar_gz/hello.tgz", ".tgz", 574 "application/x-compressed-tar"); 575 576 assertThat(transformToIterable(archiveHandle.getEntries())) 577 .containsAllIn(sExpectEntries); 578 } 579 580 @Test getEntries_tarBzFile_shouldTheSameWithList()581 public void getEntries_tarBzFile_shouldTheSameWithList() throws Exception { 582 ArchiveHandle archiveHandle = 583 prepareArchiveHandle("archives/tar_bz2/hello.tar.bz2", ".tar.bz2", 584 "application/x-bzip-compressed-tar"); 585 586 assertThat(transformToIterable(archiveHandle.getEntries())) 587 .containsAllIn(sExpectEntries); 588 } 589 590 @Test getEntries_tarBrotliFile_shouldTheSameWithList()591 public void getEntries_tarBrotliFile_shouldTheSameWithList() throws Exception { 592 ArchiveHandle archiveHandle = 593 prepareArchiveHandle("archives/brotli/hello.tar.br", ".tar.br", 594 "application/x-brotli-compressed-tar"); 595 596 assertThat(transformToIterable(archiveHandle.getEntries())) 597 .containsAllIn(sExpectEntries); 598 } 599 600 @Test getEntries_tarXzFile_shouldTheSameWithList()601 public void getEntries_tarXzFile_shouldTheSameWithList() throws Exception { 602 ArchiveHandle archiveHandle = 603 prepareArchiveHandle("archives/xz/hello.tar.xz", ".tar.xz", 604 "application/x-xz-compressed-tar"); 605 606 assertThat(transformToIterable(archiveHandle.getEntries())) 607 .containsAllIn(sExpectEntries); 608 } 609 }