Add I18nTest test

This commit is contained in:
Julien Lancelot 2015-07-24 12:22:32 +02:00
parent 05e45302f2
commit 78afe1925d
13 changed files with 358 additions and 0 deletions

View File

@ -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>

View File

@ -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();
}
}

View File

@ -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

View File

@ -30,6 +30,7 @@
</properties>
<modules>
<module>l10n-fr-pack</module>
<module>sonar-fake-plugin</module>
</modules>
</project>

View File

@ -0,0 +1,5 @@
sonar.projectKey=sample
sonar.projectName=Sample
sonar.projectVersion=1.0-SNAPSHOT
sonar.sources=src/main/xoo
sonar.language=xoo

View File

@ -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();
}
}
}

View File

@ -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

View File

@ -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);
}
}

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>