|
19 | 19 | import org.junit.jupiter.api.Test; |
20 | 20 | import static org.junit.jupiter.api.Assertions.assertArrayEquals; |
21 | 21 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 22 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
22 | 23 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
23 | 24 | import static org.junit.jupiter.api.Assertions.assertThrows; |
24 | 25 | import static org.junit.jupiter.api.Assertions.assertTrue; |
@@ -126,6 +127,37 @@ void copyAlreadyExists() |
126 | 127 | assertNotNull(exception); |
127 | 128 | } |
128 | 129 |
|
| 130 | + @Test |
| 131 | + public void copyDirectory() throws IOException |
| 132 | + { |
| 133 | + final String content = "sample-content"; |
| 134 | + |
| 135 | + // fixtures |
| 136 | + S3ClientMock client = S3MockFactory.getS3ClientMock(); |
| 137 | + client.bucket("bucketA").dir("dir1").file("dir1/file", content.getBytes()); |
| 138 | + FileSystem fs = createNewS3FileSystem(); |
| 139 | + Path dir1 = fs.getPath("/bucketA", "dir1"); |
| 140 | + Path file1 = fs.getPath("/bucketA", "dir1", "file"); |
| 141 | + Path dir2 = fs.getPath("/bucketA", "dir2"); |
| 142 | + Path file2 = fs.getPath("/bucketA", "dir2", "file"); |
| 143 | + |
| 144 | + // assert |
| 145 | + assertTrue(Files.exists(dir1)); |
| 146 | + assertTrue(Files.exists(file1)); |
| 147 | + assertTrue(Files.isDirectory(dir1)); |
| 148 | + assertTrue(Files.isRegularFile(file1)); |
| 149 | + assertFalse(Files.exists(dir2)); |
| 150 | + assertFalse(Files.exists(file2)); |
| 151 | + |
| 152 | + // act |
| 153 | + s3fsProvider.copy(dir1, dir2); |
| 154 | + |
| 155 | + // assertions |
| 156 | + assertTrue(Files.exists(dir2)); |
| 157 | + assertTrue(Files.isDirectory(dir2)); |
| 158 | + assertFalse(Files.exists(file2)); |
| 159 | + } |
| 160 | + |
129 | 161 | /** |
130 | 162 | * create a new file system for s3 scheme with fake credentials |
131 | 163 | * and global endpoint |
|
0 commit comments