aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
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);