From: Evgeny Mandrikov Date: Sun, 24 Apr 2011 02:51:32 +0000 (+0400) Subject: SONAR-2358 Add unit test X-Git-Tag: 2.8~133 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=29ec06b3e0735692a3d47d2dfd8c8956470ae42f;p=sonarqube.git SONAR-2358 Add unit test --- diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java index cd122a1c635..84b13feeae2 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java @@ -194,8 +194,7 @@ public class ViolationPersisterDecorator implements Decorator { } /** - * @param data - * can't be null + * @param data can't be null */ static List getChecksums(String data) { String[] lines = data.split("\r?\n|\r", -1); diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest.java index 44538c85633..f0c88e7b52f 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest.java @@ -45,8 +45,18 @@ public class ViolationPersisterDecoratorTest { decorator = new ViolationPersisterDecorator(null, null); } + /** + * See http://jira.codehaus.org/browse/SONAR-2358 + */ @Test public void shouldGenerateCorrectChecksums() { + List encoding = ViolationPersisterDecorator.getChecksums("Привет Мир"); + assertThat(encoding.size(), is(1)); + assertThat(encoding.get(0), is("5ba3a45e1299ede07f56e5531351be52")); + } + + @Test + public void shouldSplitLinesAndIgnoreSpaces() { List crlf = ViolationPersisterDecorator.getChecksums("Hello\r\nWorld"); List lf = ViolationPersisterDecorator.getChecksums("Hello\nWorld"); List cr = ViolationPersisterDecorator.getChecksums("Hello\rWorld");