aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2018-04-26 17:33:08 +0200
committerSonarTech <sonartech@sonarsource.com>2018-04-27 20:20:44 +0200
commit68776c0a9456b77f051baf474810e7a4e2c32694 (patch)
tree3655975642b68574f9f57d9b637789087c193a43 /tests
parent64a7ab5038ad34b5aadb75707109f31d9d8b990e (diff)
downloadsonarqube-68776c0a9456b77f051baf474810e7a4e2c32694.tar.gz
sonarqube-68776c0a9456b77f051baf474810e7a4e2c32694.zip
SONAR-10567 Compute Engine analysis do not fail if project name or description is too long
Diffstat (limited to 'tests')
-rw-r--r--tests/src/test/java/org/sonarqube/tests/project/OrganizationProjectSuite.java1
-rw-r--r--tests/src/test/java/org/sonarqube/tests/project/ProjectInfoTest.java68
2 files changed, 69 insertions, 0 deletions
diff --git a/tests/src/test/java/org/sonarqube/tests/project/OrganizationProjectSuite.java b/tests/src/test/java/org/sonarqube/tests/project/OrganizationProjectSuite.java
index c0675b8159f..75dc194bac2 100644
--- a/tests/src/test/java/org/sonarqube/tests/project/OrganizationProjectSuite.java
+++ b/tests/src/test/java/org/sonarqube/tests/project/OrganizationProjectSuite.java
@@ -36,6 +36,7 @@ import static util.ItUtils.xooPlugin;
ProjectBulkDeletionPageTest.class,
ProjectDeletionTest.class,
ProjectFilterTest.class,
+ ProjectInfoTest.class,
ProjectKeyUpdateTest.class,
ProjectKeyUpdatePageTest.class,
ProjectLeakPageTest.class,
diff --git a/tests/src/test/java/org/sonarqube/tests/project/ProjectInfoTest.java b/tests/src/test/java/org/sonarqube/tests/project/ProjectInfoTest.java
new file mode 100644
index 00000000000..407acd2478f
--- /dev/null
+++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectInfoTest.java
@@ -0,0 +1,68 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonarqube.tests.project;
+
+import com.sonar.orchestrator.Orchestrator;
+import com.sonar.orchestrator.build.SonarScanner;
+import java.io.File;
+import java.io.IOException;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.sonarqube.qa.util.Tester;
+import org.sonarqube.ws.Components.Component;
+import org.sonarqube.ws.Organizations;
+import org.sonarqube.ws.client.components.ShowRequest;
+import util.XooProjectBuilder;
+
+import static org.apache.commons.lang.StringUtils.repeat;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class ProjectInfoTest {
+
+ @ClassRule
+ public static Orchestrator orchestrator = OrganizationProjectSuite.ORCHESTRATOR;
+
+ @Rule
+ public TemporaryFolder temp = new TemporaryFolder();
+ @Rule
+ public Tester tester = new Tester(orchestrator);
+
+ @Test
+ public void project_name_and_description_should_be_truncated_if_too_long() throws IOException {
+ Organizations.Organization organization = tester.organizations().generate();
+ File projectDir = temp.newFolder();
+ new XooProjectBuilder("sample").setFilesPerModule(0).build(projectDir);
+ String longName = repeat("x", 1_000);
+ String longDescription = repeat("y", 3_000);
+
+ orchestrator.executeBuild(SonarScanner.create(projectDir,
+ "sonar.organization", organization.getKey(),
+ "sonar.login", "admin",
+ "sonar.password", "admin",
+ "sonar.projectDescription", longDescription,
+ "sonar.projectName", longName));
+
+ Component createdProject = tester.wsClient().components().show(new ShowRequest().setComponent("sample")).getComponent();
+ assertThat(createdProject.getName()).isEqualTo(repeat("x", 497) + "...");
+ assertThat(createdProject.getDescription()).isEqualTo(repeat("y", 1_997) + "...");
+ }
+}