commit 2e6fa506b3c9634837e6da4c8ad3dbf477936232 Author: iwakeh iwakeh@torproject.org Date: Wed Mar 7 13:46:51 2018 +0000
Add a failing test.
Making a static method easier accessible for tests. --- .../collector/webstats/SanitizeWeblogs.java | 2 +- .../collector/webstats/SanitizeWeblogsTest.java | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/torproject/collector/webstats/SanitizeWeblogs.java b/src/main/java/org/torproject/collector/webstats/SanitizeWeblogs.java index 5a270dd..8ef9dde 100644 --- a/src/main/java/org/torproject/collector/webstats/SanitizeWeblogs.java +++ b/src/main/java/org/torproject/collector/webstats/SanitizeWeblogs.java @@ -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(); } diff --git a/src/test/java/org/torproject/collector/webstats/SanitizeWeblogsTest.java b/src/test/java/org/torproject/collector/webstats/SanitizeWeblogsTest.java new file mode 100644 index 0000000..9ad4996 --- /dev/null +++ b/src/test/java/org/torproject/collector/webstats/SanitizeWeblogsTest.java @@ -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))); + } + +} +
tor-commits@lists.torproject.org