diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-08-22 17:34:28 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-08-24 11:54:24 +0200 |
commit | 8bdb9fde4be635c666ce0b09a851789a5ecfc870 (patch) | |
tree | d805da4bcb12289c8a38304cc99eaa924611373c /tests | |
parent | 71291b751aed27c2b62effcd2852e5e89dd4a9e9 (diff) | |
download | sonarqube-8bdb9fde4be635c666ce0b09a851789a5ecfc870.tar.gz sonarqube-8bdb9fde4be635c666ce0b09a851789a5ecfc870.zip |
SONAR-7493 support long issue messages on Oracle
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/test/java/org/sonarqube/tests/issue/IssueCreationTest.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/src/test/java/org/sonarqube/tests/issue/IssueCreationTest.java b/tests/src/test/java/org/sonarqube/tests/issue/IssueCreationTest.java index b6afaf17304..6c7d72ed9d5 100644 --- a/tests/src/test/java/org/sonarqube/tests/issue/IssueCreationTest.java +++ b/tests/src/test/java/org/sonarqube/tests/issue/IssueCreationTest.java @@ -19,6 +19,7 @@ */ package org.sonarqube.tests.issue; +import org.apache.commons.lang.StringUtils; import org.junit.Before; import org.junit.Test; import org.sonar.wsclient.issue.Issue; @@ -32,6 +33,7 @@ import static util.ItUtils.runProjectAnalysis; public class IssueCreationTest extends AbstractIssueTest { private static final String SAMPLE_PROJECT_KEY = "sample"; + private static final int ISSUE_MESSAGE_MAX_LENGTH = 1_333; @Before public void resetData() { @@ -75,4 +77,40 @@ public class IssueCreationTest extends AbstractIssueTest { assertThat(issue.severity()).isEqualTo("BLOCKER"); } } + + /** + * SONAR-7493 + */ + @Test + public void issue_message_should_support_1_333_utf8_characters_encoded_on_3_bytes() { + String longMessage = StringUtils.repeat("を", ISSUE_MESSAGE_MAX_LENGTH); + + assertThat(generateIssueWithMessage(longMessage)).isEqualTo(longMessage); + } + + /** + * Test the maximum size of DB column issues.message, when all characters + * are encoded on 3-bytes + * + * SONAR-7493 + */ + @Test + public void issue_message_should_be_abbreviated_if_longer_than_1333_utf8_characters_encoded_on_3_bytes() { + String character = "を"; + String message = generateIssueWithMessage(StringUtils.repeat(character, 10_000)); + + String abbreviatedMessage = StringUtils.repeat(character, ISSUE_MESSAGE_MAX_LENGTH - 3) + "..."; + assertThat(message).isEqualTo(abbreviatedMessage); + } + + private String generateIssueWithMessage(String longMessage) { + ORCHESTRATOR.getServer().provisionProject(SAMPLE_PROJECT_KEY, SAMPLE_PROJECT_KEY); + ItUtils.restoreProfile(ORCHESTRATOR, getClass().getResource("/issue/IssueCreationTest/with-custom-message.xml")); + ORCHESTRATOR.getServer().associateProjectToQualityProfile(SAMPLE_PROJECT_KEY, "xoo", "with-custom-message"); + + runProjectAnalysis(ORCHESTRATOR, "shared/xoo-sample", "sonar.customMessage.message", longMessage); + + Issue issue = issueClient().find(IssueQuery.create()).list().get(0); + return issue.message(); + } } |