### Question:
S3FileHandler { public Resource[] listFilesInFolder(String bucketName, String folderPath, String filePattern) { var s3FolderUrl = "s3: var searchPath = s3FolderUrl + "/" + filePattern; try { return resolver.getResources(searchPath); } catch (IOException e) { throw new RuntimeException(e); } } S3FileHandler(AmazonS3 amazonS3, ApplicationContext context); Resource[] listFilesInFolder(String bucketName, String folderPath, String filePattern); void deleteFile(String bucketName, String filePath); void copyFile(String fromBucketName, String fromFilePath, String toBucketName, String toFilePath); Resource moveFileToWorkFolder(String bucketName, String filePath, String folderName, String workFolderSuffix); void deleteAllFilesInFolder(String bucketName, String folderPath); void deleteAllFilesInFolderExcept(String bucketName, String folderPath, List<String> excludeList);  }### Answer:
@Test @Tag("S3Test") public void testListFilesInFolder() { Resource[] files = handler.listFilesInFolder(BUCKET_NAME, "_unittest/forListFiles", "*"); assertThat(files).filteredOn(Resource::isReadable) .extracting(Resource::getFilename) .hasSize(3) .contains("_unittest/forListFiles/dummyfile.txt") .contains("_unittest/forListFiles/testfile") .contains("_unittest/forListFiles/テストファイル.CSV"); }
@Test @Tag("S3Test") public void testListFilesInFolderAndRead() { Resource[] files = handler.listFilesInFolder(BUCKET_NAME, "_unittest/forListFiles", "*"); Arrays.stream(files).filter(r -> r.getFilename().equals("_unittest/forListFiles/dummyfile.txt")) .forEach(r -> { try (var br = new BufferedReader(new InputStreamReader(r.getInputStream(), StandardCharsets.UTF_8))) { assertThat(br.readLine()).isEqualTo("dummy"); } catch (IOException e) { throw new RuntimeException(e); } }); }