diff options
Diffstat (limited to 'it/it-tests/src/test/java/administation/suite/administration/PropertySetsTest.java')
-rw-r--r-- | it/it-tests/src/test/java/administation/suite/administration/PropertySetsTest.java | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/it/it-tests/src/test/java/administation/suite/administration/PropertySetsTest.java b/it/it-tests/src/test/java/administation/suite/administration/PropertySetsTest.java new file mode 100644 index 00000000000..007eac65477 --- /dev/null +++ b/it/it-tests/src/test/java/administation/suite/administration/PropertySetsTest.java @@ -0,0 +1,94 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 administation.suite.administration; + +import administation.suite.AdministrationTestSuite; +import com.sonar.orchestrator.Orchestrator; +import com.sonar.orchestrator.selenium.Selenese; +import org.junit.ClassRule; +import org.junit.Test; +import org.sonar.wsclient.services.PropertyQuery; +import org.sonar.wsclient.services.PropertyUpdateQuery; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PropertySetsTest { + + @ClassRule + public static Orchestrator orchestrator = AdministrationTestSuite.ORCHESTRATOR; + + @Test + public void should_support_property_sets() { + Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("property-sets", + "/administration/suite/PropertySetsTest/property-sets/create.html", + "/administration/suite/PropertySetsTest/property-sets/delete.html", + "/administration/suite/PropertySetsTest/property-sets/reference.html", + "/administration/suite/PropertySetsTest/property-sets/all_types.html" + ).build(); + orchestrator.executeSelenese(selenese); + + // SSF-25 Check that the password has well be setted as now it does not appears in the html source code + String sonarDemoValue = getProperty("sonar.demo"); + assertThat(getProperty("sonar.demo." + sonarDemoValue + ".password")).isEqualTo("abcde"); + } + + @Test + public void should_edit_properties() { + setProperty("sonar.test.jira.servers", "jira1,jira2"); + setProperty("sonar.test.jira.servers.jira1.url", "http://jira1"); + setProperty("sonar.test.jira.servers.jira2.url", "http://jira2"); + setProperty("sonar.test.jira.servers.jira1.port", "12345"); + setProperty("sonar.test.jira.servers.jira2.port", "66666"); + + assertThat(getProperty("sonar.test.jira.servers")).isEqualTo("jira1,jira2"); + assertThat(getProperty("sonar.test.jira.servers.jira1.url")).isEqualTo("http://jira1"); + assertThat(getProperty("sonar.test.jira.servers.jira2.url")).isEqualTo("http://jira2"); + assertThat(getProperty("sonar.test.jira.servers.jira1.port")).isEqualTo("12345"); + assertThat(getProperty("sonar.test.jira.servers.jira2.port")).isEqualTo("66666"); + } + + @Test + public void should_support_property_sets_with_auto_generated_keys() { + orchestrator.executeSelenese(Selenese.builder().setHtmlTestsInClasspath("create-auto-generated", + "/administration/suite/PropertySetsTest/auto-generated/create.html" + ).build()); + + String[] keys = getProperty("sonar.autogenerated").split("[,]"); + assertThat(getProperty("sonar.autogenerated." + keys[0] + ".value")).isEqualTo("FIRST"); + assertThat(getProperty("sonar.autogenerated." + keys[1] + ".value")).isEqualTo("SECOND"); + assertThat(getProperty("sonar.autogenerated." + keys[2] + ".value")).isEqualTo("THIRD"); + + orchestrator.executeSelenese(Selenese.builder().setHtmlTestsInClasspath("update-auto-generated", + "/administration/suite/PropertySetsTest/auto-generated/update.html" + ).build()); + + keys = getProperty("sonar.autogenerated").split("[,]"); + assertThat(getProperty("sonar.autogenerated." + keys[0] + ".value")).isEqualTo("FIRST"); + assertThat(getProperty("sonar.autogenerated." + keys[1] + ".value")).isEqualTo("THIRD"); + } + + static void setProperty(String key, String value) { + orchestrator.getServer().getAdminWsClient().update(new PropertyUpdateQuery(key, value)); + } + + static String getProperty(String key) { + return orchestrator.getServer().getAdminWsClient().find(new PropertyQuery().setKey(key)).getValue(); + } +} |