diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-07-24 12:22:32 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-07-24 12:22:48 +0200 |
commit | 78afe1925d8d02a28516cc3768e8fc42e3d7b71d (patch) | |
tree | 3b6e386a27309c7057be42c15a0e6e8681e2e677 | |
parent | 05e45302f2bc7263da1d298bf2ad4178bebdd26f (diff) | |
download | sonarqube-78afe1925d8d02a28516cc3768e8fc42e3d7b71d.tar.gz sonarqube-78afe1925d8d02a28516cc3768e8fc42e3d7b71d.zip |
Add I18nTest test
13 files changed, 358 insertions, 0 deletions
diff --git a/it/it-plugins/l10n-fr-pack/pom.xml b/it/it-plugins/l10n-fr-pack/pom.xml new file mode 100644 index 00000000000..94f31bdaf6b --- /dev/null +++ b/it/it-plugins/l10n-fr-pack/pom.xml @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.sonarsource.it</groupId> + <artifactId>it-plugins</artifactId> + <version>5.2-SNAPSHOT</version> + </parent> + + <artifactId>l10n-fr-pack</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>sonar-plugin</packaging> + <description>IT :: Simple French Language Pack</description> + + <dependencies> + <dependency> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-plugin-api</artifactId> + <version>${apiVersion}</version> + <scope>provided</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-packaging-maven-plugin</artifactId> + <version>1.12.1</version> + <extensions>true</extensions> + <configuration> + <basePlugin>l10nen</basePlugin> + <pluginClass>SimpleFrenchPackPlugin</pluginClass> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>native2ascii-maven-plugin</artifactId> + <version>1.0-beta-1</version> + <executions> + <execution> + <goals> + <goal>native2ascii</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/it/it-plugins/l10n-fr-pack/src/main/java/SimpleFrenchPackPlugin.java b/it/it-plugins/l10n-fr-pack/src/main/java/SimpleFrenchPackPlugin.java new file mode 100644 index 00000000000..9688d18ff89 --- /dev/null +++ b/it/it-plugins/l10n-fr-pack/src/main/java/SimpleFrenchPackPlugin.java @@ -0,0 +1,29 @@ +/* + * 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. + */ + +import java.util.Collections; +import java.util.List; +import org.sonar.api.SonarPlugin; + +public final class SimpleFrenchPackPlugin extends SonarPlugin { + public List getExtensions() { + return Collections.emptyList(); + } +} diff --git a/it/it-plugins/l10n-fr-pack/src/main/resources/org/sonar/l10n/core_fr.properties b/it/it-plugins/l10n-fr-pack/src/main/resources/org/sonar/l10n/core_fr.properties new file mode 100644 index 00000000000..2d28afe84f0 --- /dev/null +++ b/it/it-plugins/l10n-fr-pack/src/main/resources/org/sonar/l10n/core_fr.properties @@ -0,0 +1,6 @@ +metric.ncloc.name=Lignes de code +metric.ncloc.description=Lignes de code (non commentaire) +widget.size.lines_of_code=Lignes de code + +layout.login=Se connecter +layout.powered_by=Propulsé par diff --git a/it/it-plugins/pom.xml b/it/it-plugins/pom.xml index 439f0a51aaa..295cf70e24b 100644 --- a/it/it-plugins/pom.xml +++ b/it/it-plugins/pom.xml @@ -30,6 +30,7 @@ </properties> <modules> + <module>l10n-fr-pack</module> <module>sonar-fake-plugin</module> </modules> </project> diff --git a/it/it-projects/ui/xoo-sample/sonar-project.properties b/it/it-projects/ui/xoo-sample/sonar-project.properties new file mode 100644 index 00000000000..9e4aa0e3584 --- /dev/null +++ b/it/it-projects/ui/xoo-sample/sonar-project.properties @@ -0,0 +1,5 @@ +sonar.projectKey=sample +sonar.projectName=Sample +sonar.projectVersion=1.0-SNAPSHOT +sonar.sources=src/main/xoo +sonar.language=xoo diff --git a/it/it-projects/ui/xoo-sample/src/main/xoo/sample/Sample.xoo b/it/it-projects/ui/xoo-sample/src/main/xoo/sample/Sample.xoo new file mode 100644 index 00000000000..41871e123a3 --- /dev/null +++ b/it/it-projects/ui/xoo-sample/src/main/xoo/sample/Sample.xoo @@ -0,0 +1,16 @@ +package sample; + +public class Sample { + + public Sample(int i) { + int j = i++; + } + + private String myMethod() { + if (foo == bar) { + return "hello"; + } else { + throw new IllegalStateException(); + } + } +} diff --git a/it/it-projects/ui/xoo-sample/src/main/xoo/sample/Sample.xoo.measures b/it/it-projects/ui/xoo-sample/src/main/xoo/sample/Sample.xoo.measures new file mode 100644 index 00000000000..3f73ea8f695 --- /dev/null +++ b/it/it-projects/ui/xoo-sample/src/main/xoo/sample/Sample.xoo.measures @@ -0,0 +1,11 @@ +ncloc:13 +#Used by dashboard/widgets tests +complexity:3 +complexity_in_classes:3 +classes:1 +comment_lines:3 +public_api:5 +public_undocumented_api:2 +duplicated_files:1 +duplicated_blocks:2 +duplicated_lines:3 diff --git a/it/it-tests/src/test/java/ui/I18nTest.java b/it/it-tests/src/test/java/ui/I18nTest.java new file mode 100644 index 00000000000..f61527f87a5 --- /dev/null +++ b/it/it-tests/src/test/java/ui/I18nTest.java @@ -0,0 +1,63 @@ +/* + * 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 ui; + +import com.sonar.orchestrator.Orchestrator; +import com.sonar.orchestrator.build.SonarRunner; +import com.sonar.orchestrator.selenium.Selenese; +import org.junit.After; +import org.junit.ClassRule; +import org.junit.Test; + +import static util.ItUtils.pluginArtifact; +import static util.ItUtils.projectDir; +import static util.ItUtils.xooPlugin; + +public class I18nTest { + + @ClassRule + public static Orchestrator orchestrator = Orchestrator.builderEnv() + .addPlugin(pluginArtifact("l10n-fr-pack")) + .addPlugin(xooPlugin()) + .build(); + + @After + public void cleanDatabase() { + orchestrator.resetData(); + } + + /** + * TODO This test should use a fake widget that display a fake metric with decimals instead of using provided metric + */ + @Test + public void test_localization() { + orchestrator.executeBuild(SonarRunner.create(projectDir("ui/xoo-sample"))); + + Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("ui-i18n", + "/ui/i18n/default-locale-is-english.html", + "/ui/i18n/french-locale.html", + "/ui/i18n/french-pack.html", + "/ui/i18n/locale-with-france-country.html", + "/ui/i18n/locale-with-swiss-country.html").build(); + orchestrator.executeSelenese(selenese); + } + +} diff --git a/it/it-tests/src/test/resources/ui/i18n/default-locale-is-english.html b/it/it-tests/src/test/resources/ui/i18n/default-locale-is-english.html new file mode 100644 index 00000000000..a918e54543b --- /dev/null +++ b/it/it-tests/src/test/resources/ui/i18n/default-locale-is-english.html @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> + <title>default_locale_is_english</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> + <thead> + <tr> + <td rowspan="1" colspan="3">default_locale_is_english</td> + </tr> + </thead> + <tbody> + <tr> + <td>open</td> + <td>/sonar/dashboard/index/sample?locale=foo</td> + <td></td> + </tr> + <tr> + <td>waitForText</td> + <td>css=.navbar-context</td> + <td>regexp:.*Jan.*|.*Feb.*|.*Mar.*|.*Apr.*|.*May.*|.*Jun.*|.*Jul.*|.*Aug.*|.*Sep.*|.*Oct.*|.*Nov.*|.*Dec.*</td> + </tr> + <tr> + <td>assertText</td> + <td>m_duplicated_lines_density</td> + <td>0.0%</td> + </tr> + </tbody> +</table> +</body> +</html> diff --git a/it/it-tests/src/test/resources/ui/i18n/french-locale.html b/it/it-tests/src/test/resources/ui/i18n/french-locale.html new file mode 100644 index 00000000000..e4c8681e3fd --- /dev/null +++ b/it/it-tests/src/test/resources/ui/i18n/french-locale.html @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> + <title>french</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> + <thead> + <tr> + <td rowspan="1" colspan="3">french</td> + </tr> + </thead> + <tbody> + <tr> + <td>open</td> + <td>/sonar/dashboard/index/sample?locale=fr</td> + <td></td> + </tr> + <tr> + <td>waitForText</td> + <td>css=.navbar-context</td> + <td>regexp:.*jan.*|.*fév.*|.*mar.*|.*avr.*|.*mai.*|.*juin.*|.*juil.*|.*août.*|.*sept.*|.*oct.*|.*nov.*|.*déc.*</td> + </tr> + <tr> + <td>assertText</td> + <td>m_duplicated_lines_density</td> + <td>0,0%</td> + </tr> + </tbody> +</table> +</body> +</html> diff --git a/it/it-tests/src/test/resources/ui/i18n/french-pack.html b/it/it-tests/src/test/resources/ui/i18n/french-pack.html new file mode 100644 index 00000000000..ce98f2206a5 --- /dev/null +++ b/it/it-tests/src/test/resources/ui/i18n/french-pack.html @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> + <title>french-pack</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> + <thead> + <tr> + <td rowspan="1" colspan="3">french-pack</td> + </tr> + </thead> + <tbody> + <tr> + <td>open</td> + <td>/sonar/?locale=fr</td> + <td></td> + </tr> + <tr> + <td>waitForText</td> + <td>css=.navbar</td> + <td>glob:*Se connecter*</td> + </tr> + <tr> + <td>open</td> + <td>/sonar/dashboard/index/sample?locale=fr</td> + <td></td> + </tr> + <tr> + <td>assertText</td> + <td>css=.size</td> + <td>glob:*Lignes de code*</td> + </tr> + </tbody> +</table> +</body> +</html> diff --git a/it/it-tests/src/test/resources/ui/i18n/locale-with-france-country.html b/it/it-tests/src/test/resources/ui/i18n/locale-with-france-country.html new file mode 100644 index 00000000000..2839f332c2d --- /dev/null +++ b/it/it-tests/src/test/resources/ui/i18n/locale-with-france-country.html @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> + <title>french-france</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> + <thead> + <tr> + <td rowspan="1" colspan="3">french-france</td> + </tr> + </thead> + <tbody> + <tr> + <td>open</td> + <td>/sonar/dashboard/index/sample?locale=fr-FR</td> + <td></td> + </tr> + <tr> + <td>waitForText</td> + <td>css=.navbar-context</td> + <td>regexp:.*jan.*|.*fév.*|.*mar.*|.*avr.*|.*mai.*|.*juin.*|.*juil.*|.*août.*|.*sept.*|.*oct.*|.*nov.*|.*déc.*</td> + </tr> + <tr> + <td>assertText</td> + <td>m_duplicated_lines_density</td> + <td>0,0%</td> + </tr> + </tbody> +</table> +</body> +</html> diff --git a/it/it-tests/src/test/resources/ui/i18n/locale-with-swiss-country.html b/it/it-tests/src/test/resources/ui/i18n/locale-with-swiss-country.html new file mode 100644 index 00000000000..e2caf04b56c --- /dev/null +++ b/it/it-tests/src/test/resources/ui/i18n/locale-with-swiss-country.html @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> + <title>french-switzerland</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> + <thead> + <tr> + <td rowspan="1" colspan="3">french-switzerland</td> + </tr> + </thead> + <tbody> + <tr> + <td>open</td> + <td>/sonar/dashboard/index/sample?locale=fr-CH</td> + <td></td> + </tr> + <tr> + <td>waitForText</td> + <td>css=.navbar-context</td> + <td>regexp:.*jan.*|.*fév.*|.*mar.*|.*avr.*|.*mai.*|.*juin.*|.*juil.*|.*août.*|.*sept.*|.*oct.*|.*nov.*|.*déc.*</td> + </tr> + <tr> + <td>assertText</td> + <td>m_duplicated_lines_density</td> + <td>0.0%</td> + </tr> + </tbody> +</table> +</body> +</html> |