aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2017-07-04 14:05:36 +0200
committerDuarte Meneses <duarte.meneses@sonarsource.com>2017-08-22 09:26:45 +0200
commit440277273355aa69d0df7996d6135f1e2fa7b7bf (patch)
treed86e73bc12e11ee6b48e476b007ca4c1e54dfd75 /sonar-scanner-engine
parent51045662605d5ff9aa48fdf52201c02e8de634cd (diff)
downloadsonarqube-440277273355aa69d0df7996d6135f1e2fa7b7bf.tar.gz
sonarqube-440277273355aa69d0df7996d6135f1e2fa7b7bf.zip
Fix FP in encoding detection test
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/CharsetDetectorTest.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/CharsetDetectorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/CharsetDetectorTest.java
index 0da6349119b..490d5d5f9a8 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/CharsetDetectorTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/CharsetDetectorTest.java
@@ -94,8 +94,20 @@ public class CharsetDetectorTest {
@Test
public void no_encoding_found() throws IOException {
Path filePath = temp.newFile().toPath();
- byte[] b = new byte[512];
+ byte[] b = new byte[4096];
new Random().nextBytes(b);
+ // avoid accidental BOM matching
+ b[0] = 1;
+
+ // avoid UTF-8 / UTF-16
+ b[100] = 0;
+ b[101] = 0;
+ b[102] = 0;
+ b[103] = 0;
+
+ // invalid in win-1258
+ b[200] = (byte) 129;
+
Files.write(filePath, b);
CharsetDetector detector = new CharsetDetector(filePath, UTF_8);