|
30 | 30 | import java.util.Set; |
31 | 31 | import java.util.concurrent.TimeUnit; |
32 | 32 |
|
33 | | -import com.upplication.s3fs.util.IOUtils; |
| 33 | +import com.upplication.s3fs.util.*; |
34 | 34 | import org.junit.After; |
35 | 35 | import org.junit.Before; |
36 | 36 | import org.junit.Test; |
37 | 37 |
|
38 | 38 | import com.amazonaws.services.s3.model.AccessControlList; |
39 | 39 | import com.amazonaws.services.s3.model.Owner; |
40 | 40 | import com.google.common.collect.ImmutableMap; |
41 | | -import com.upplication.s3fs.util.AmazonS3ClientMock; |
42 | | -import com.upplication.s3fs.util.AmazonS3MockFactory; |
43 | | -import com.upplication.s3fs.util.MockBucket; |
44 | 41 | import org.mockito.ArgumentMatcher; |
45 | 42 |
|
46 | 43 | public class S3FileSystemProviderTest extends S3UnitTestBase { |
@@ -525,7 +522,7 @@ public void anotherOutputStream() throws IOException { |
525 | 522 | public void seekable() throws IOException { |
526 | 523 | // fixtures |
527 | 524 | AmazonS3ClientMock client = AmazonS3MockFactory.getAmazonClientMock(); |
528 | | - client.bucket("bucketA").dir("dir").file("dir/file"); |
| 525 | + client.bucket("bucketA").dir("dir").file("dir/file", "".getBytes()); |
529 | 526 |
|
530 | 527 | Path base = createNewS3FileSystem().getPath("/bucketA", "dir"); |
531 | 528 |
|
@@ -999,8 +996,9 @@ public void getFileAttributeView() { |
999 | 996 | @Test |
1000 | 997 | public void readAttributesFileEmpty() throws IOException { |
1001 | 998 | // fixtures |
| 999 | + final String content = ""; |
1002 | 1000 | AmazonS3ClientMock client = AmazonS3MockFactory.getAmazonClientMock(); |
1003 | | - client.bucket("bucketA").dir("dir").file("dir/file1"); |
| 1001 | + client.bucket("bucketA").dir("dir").file("dir/file1", content.getBytes()); |
1004 | 1002 |
|
1005 | 1003 | Path file1 = createNewS3FileSystem().getPath("/bucketA/dir/file1"); |
1006 | 1004 |
|
@@ -1115,6 +1113,25 @@ public void readAttributesDirectoryNotExistsAtAmazon() throws IOException { |
1115 | 1113 | assertEquals(fileAttributes.lastAccessTime().to(TimeUnit.SECONDS), fileAttributes.lastModifiedTime().to(TimeUnit.SECONDS)); |
1116 | 1114 | } |
1117 | 1115 |
|
| 1116 | + @Test |
| 1117 | + public void readAttributesRegenerateCacheWhenNotExists() throws IOException { |
| 1118 | + // fixtures |
| 1119 | + final String content = ""; |
| 1120 | + AmazonS3ClientMock client = AmazonS3MockFactory.getAmazonClientMock(); |
| 1121 | + client.bucket("bucketA").dir("dir").file("dir/file1", content.getBytes()); |
| 1122 | + |
| 1123 | + Path file1 = createNewS3FileSystem().getPath("/bucketA/dir/file1"); |
| 1124 | + // create the cache |
| 1125 | + s3fsProvider.readAttributes(file1, BasicFileAttributes.class); |
| 1126 | + assertNotNull(((S3Path) file1).getFileAttributes()); |
| 1127 | + |
| 1128 | + s3fsProvider.readAttributes(file1, BasicFileAttributes.class); |
| 1129 | + assertNull(((S3Path) file1).getFileAttributes()); |
| 1130 | + |
| 1131 | + s3fsProvider.readAttributes(file1, BasicFileAttributes.class); |
| 1132 | + assertNotNull(((S3Path) file1).getFileAttributes()); |
| 1133 | + } |
| 1134 | + |
1118 | 1135 | @Test(expected = NoSuchFileException.class) |
1119 | 1136 | public void readAttributesFileNotExists() throws IOException { |
1120 | 1137 | // fixtures |
|
0 commit comments