aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-process/src/test/java
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2018-08-05 23:02:28 +0200
committerSonarTech <sonartech@sonarsource.com>2018-08-07 20:21:21 +0200
commit04789e3182ecf712121dc9f329ef01c3d1b914cf (patch)
tree61f0e38af2ca84a4f4492b0dd96976b1fc9092c4 /server/sonar-process/src/test/java
parentd8348faaa3f0030ef42364ff0e0c2792b085c56f (diff)
downloadsonarqube-04789e3182ecf712121dc9f329ef01c3d1b914cf.tar.gz
sonarqube-04789e3182ecf712121dc9f329ef01c3d1b914cf.zip
SONAR-11077 ignore size of symlinks in FileUtils2#sizeOf()
Diffstat (limited to 'server/sonar-process/src/test/java')
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/FileUtils2Test.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/server/sonar-process/src/test/java/org/sonar/process/FileUtils2Test.java b/server/sonar-process/src/test/java/org/sonar/process/FileUtils2Test.java
index 890a21d782a..2c7b9af0845 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/FileUtils2Test.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/FileUtils2Test.java
@@ -281,6 +281,21 @@ public class FileUtils2Test {
FileUtils2.sizeOf(path);
}
+ @Test
+ public void sizeOf_ignores_size_of_non_regular_files() throws IOException {
+ File outside = temporaryFolder.newFile();
+ FileUtils.write(outside, "outside!!!", UTF_8);
+ File dir = temporaryFolder.newFolder();
+ File child = new File(dir, "child1.txt");
+ FileUtils.write(child, "inside!!!", UTF_8);
+ File symlink = new File(dir, "child2.txt");
+ Files.createSymbolicLink(symlink.toPath(), outside.toPath());
+
+ assertThat(FileUtils2.sizeOf(dir.toPath()))
+ .isPositive()
+ .isEqualTo(FileUtils2.sizeOf(child.toPath()));
+ }
+
private void expectDirectoryCanNotBeNullNPE() {
expectedException.expect(NullPointerException.class);
expectedException.expectMessage("Directory can not be null");