Add a failing test.

Making a static method easier accessible for tests.
This commit is contained in:
iwakeh 2018-03-07 13:46:51 +00:00
parent 727d4e54ef
commit 2e6fa506b3
2 changed files with 21 additions and 1 deletions

View File

@ -187,7 +187,7 @@ public class SanitizeWeblogs extends CollecTorMain {
}
}
private static byte[] bytesFor(String line, long times) {
public static byte[] bytesFor(String line, long times) {
return Stream.of(line).limit(times)
.collect(Collectors.joining("\n", "", "\n")).getBytes();
}

View File

@ -0,0 +1,20 @@
/* Copyright 2017--2018 The Tor Project
* See LICENSE for licensing information */
package org.torproject.collector.webstats;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class SanitizeWeblogsTest {
@Test
public void bytesForTest() {
String lines = "line\nline\nline\nline\nline\n"
+ "line\nline\nline\nline\nline\n";
assertEquals(lines, new String(SanitizeWeblogs.bytesFor("line", 10)));
}
}