aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src/test/java/org/sonar
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-04-13 11:59:54 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2015-04-13 11:59:54 +0200
commit1434abc6dcf716a06267a109908c7dc920fad9c8 (patch)
treed64988b92b74bc4372fd1836f4296d9796b676e3 /sonar-plugin-api/src/test/java/org/sonar
parentb80b6a014a747f42f589cc9c7cc59b5a42b21e9a (diff)
downloadsonarqube-1434abc6dcf716a06267a109908c7dc920fad9c8.tar.gz
sonarqube-1434abc6dcf716a06267a109908c7dc920fad9c8.zip
Restore old behavior for InputFile::lines() -> returns 1 for empty files
Diffstat (limited to 'sonar-plugin-api/src/test/java/org/sonar')
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/FileMetadataTest.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/FileMetadataTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/FileMetadataTest.java
index 9e06a3e9e5c..e26451cf82d 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/FileMetadataTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/FileMetadataTest.java
@@ -56,7 +56,7 @@ public class FileMetadataTest {
FileUtils.touch(tempFile);
FileMetadata.Metadata metadata = new FileMetadata().readMetadata(tempFile, Charsets.UTF_8);
- assertThat(metadata.lines).isEqualTo(0);
+ assertThat(metadata.lines).isEqualTo(1);
assertThat(metadata.nonBlankLines).isEqualTo(0);
assertThat(metadata.hash).isNotEmpty();
assertThat(metadata.originalLineOffsets).containsOnly(0);
@@ -219,6 +219,8 @@ public class FileMetadataTest {
case 3:
assertThat(Hex.encodeHexString(hash)).isEqualTo(md5Hex("baz"));
break;
+ default:
+ fail("Invalid line");
}
}
});
@@ -236,7 +238,13 @@ public class FileMetadataTest {
@Override
public void consume(int lineIdx, @Nullable byte[] hash) {
- fail("File is empty and should not report any line hash");
+ switch (lineIdx) {
+ case 1:
+ assertThat(hash).isNull();
+ break;
+ default:
+ fail("Invalid line");
+ }
}
});
}