ayushtkn commented on a change in pull request #2060:
URL: https://github.com/apache/hadoop/pull/2060#discussion_r447990862
##########
File path:
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
##########
@@ -1369,4 +1381,61 @@ public void testDeleteOnExit() throws Exception {
viewFs.close();
assertFalse(fsTarget.exists(realTestPath));
}
+
+ @Test
+ public void testGetContentSummary() throws IOException {
+ ContentSummary summaryBefore =
+ fsView.getContentSummary(new Path("/internalDir"));
+ String expected = "GET CONTENT SUMMARY";
+ Path filePath =
+ new Path("/internalDir/internalDir2/linkToDir3", "foo");
+
+ try (FSDataOutputStream outputStream = fsView.create(filePath)) {
+ try (OutputStreamWriter writer =
+ new OutputStreamWriter(outputStream, StandardCharsets.UTF_8)) {
+ try (BufferedWriter buffer = new BufferedWriter(writer)) {
+ buffer.write(expected);
+ }
Review comment:
Will doing just this not work?
```
outputStream.write(expected.getBytes());
```
##########
File path:
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
##########
@@ -1369,4 +1381,61 @@ public void testDeleteOnExit() throws Exception {
viewFs.close();
assertFalse(fsTarget.exists(realTestPath));
}
+
+ @Test
+ public void testGetContentSummary() throws IOException {
+ ContentSummary summaryBefore =
+ fsView.getContentSummary(new Path("/internalDir"));
+ String expected = "GET CONTENT SUMMARY";
+ Path filePath =
+ new Path("/internalDir/internalDir2/linkToDir3", "foo");
+
+ try (FSDataOutputStream outputStream = fsView.create(filePath)) {
+ try (OutputStreamWriter writer =
+ new OutputStreamWriter(outputStream, StandardCharsets.UTF_8)) {
+ try (BufferedWriter buffer = new BufferedWriter(writer)) {
+ buffer.write(expected);
+ }
+ }
+ }
+
+ Path newDirPath = new Path("/internalDir/linkToDir2", "bar");
+ fsView.mkdirs(newDirPath);
+
+ ContentSummary summaryAfter =
+ fsView.getContentSummary(new Path("/internalDir"));
+ Assert.assertEquals("The file count didn't match",
+ summaryBefore.getFileCount() + 1,
+ summaryAfter.getFileCount());
+ Assert.assertEquals("The size didn't match",
+ summaryBefore.getLength() + expected.length(),
+ summaryAfter.getLength());
+ Assert.assertEquals("The directory count didn't match",
Review comment:
nit: There is already a static import -
```
import static org.junit.Assert.*;
```
no need to have `Assert.`
Similarly for the below test aswell
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]