From 742d043eaaf6fd907e8402eaea8ac675309cb016 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Mon, 8 Feb 2016 16:28:03 +0100 Subject: [PATCH] move in IT HighlightingTest from it-core --- .../sonar-project.properties | 5 ++ .../src/main/xoo/sample/Sample.xoo | 12 ++++ .../main/xoo/sample/Sample.xoo.highlighting | 15 +++++ .../src/main/xoo/sample/Sample.xoo.measures | 2 + .../sonar-project.properties | 5 ++ .../src/main/xoo/sample/Sample.xoo | 12 ++++ .../main/xoo/sample/Sample.xoo.highlighting | 14 +++++ .../src/main/xoo/sample/Sample.xoo.measures | 2 + .../src/main/xoo/sample/Sample.xoo.symbol | 4 ++ .../src/test/java/it/Category4Suite.java | 5 +- .../it/highlighting/HighlightingTest.java | 59 ++++++++++++++++++ .../symbol-usages-highlighting.html | 49 +++++++++++++++ .../syntax-highlighting-v1.html | 60 +++++++++++++++++++ .../syntax-highlighting-v2.html | 59 ++++++++++++++++++ 14 files changed, 302 insertions(+), 1 deletion(-) create mode 100644 it/it-projects/highlighting/xoo-sample-with-highlighting-v1/sonar-project.properties create mode 100644 it/it-projects/highlighting/xoo-sample-with-highlighting-v1/src/main/xoo/sample/Sample.xoo create mode 100644 it/it-projects/highlighting/xoo-sample-with-highlighting-v1/src/main/xoo/sample/Sample.xoo.highlighting create mode 100644 it/it-projects/highlighting/xoo-sample-with-highlighting-v1/src/main/xoo/sample/Sample.xoo.measures create mode 100644 it/it-projects/highlighting/xoo-sample-with-highlighting-v2/sonar-project.properties create mode 100644 it/it-projects/highlighting/xoo-sample-with-highlighting-v2/src/main/xoo/sample/Sample.xoo create mode 100644 it/it-projects/highlighting/xoo-sample-with-highlighting-v2/src/main/xoo/sample/Sample.xoo.highlighting create mode 100644 it/it-projects/highlighting/xoo-sample-with-highlighting-v2/src/main/xoo/sample/Sample.xoo.measures create mode 100644 it/it-projects/highlighting/xoo-sample-with-highlighting-v2/src/main/xoo/sample/Sample.xoo.symbol create mode 100644 it/it-tests/src/test/java/it/highlighting/HighlightingTest.java create mode 100644 it/it-tests/src/test/resources/highlighting/HighlightingTest/symbol-usages-highlighting.html create mode 100644 it/it-tests/src/test/resources/highlighting/HighlightingTest/syntax-highlighting-v1.html create mode 100644 it/it-tests/src/test/resources/highlighting/HighlightingTest/syntax-highlighting-v2.html diff --git a/it/it-projects/highlighting/xoo-sample-with-highlighting-v1/sonar-project.properties b/it/it-projects/highlighting/xoo-sample-with-highlighting-v1/sonar-project.properties new file mode 100644 index 00000000000..8ec6e295138 --- /dev/null +++ b/it/it-projects/highlighting/xoo-sample-with-highlighting-v1/sonar-project.properties @@ -0,0 +1,5 @@ +sonar.projectKey=sample-with-highlighting +sonar.projectName=Sample With Highlighting +sonar.projectVersion=1.0-SNAPSHOT +sonar.sources=src/main/xoo +sonar.language=xoo diff --git a/it/it-projects/highlighting/xoo-sample-with-highlighting-v1/src/main/xoo/sample/Sample.xoo b/it/it-projects/highlighting/xoo-sample-with-highlighting-v1/src/main/xoo/sample/Sample.xoo new file mode 100644 index 00000000000..385b2a549d9 --- /dev/null +++ b/it/it-projects/highlighting/xoo-sample-with-highlighting-v1/src/main/xoo/sample/Sample.xoo @@ -0,0 +1,12 @@ +package sample; + +public class Sample { + + public Sample(int i) { + int j = i++; + } + + private String myMethod() { + return "hello"; + } +} diff --git a/it/it-projects/highlighting/xoo-sample-with-highlighting-v1/src/main/xoo/sample/Sample.xoo.highlighting b/it/it-projects/highlighting/xoo-sample-with-highlighting-v1/src/main/xoo/sample/Sample.xoo.highlighting new file mode 100644 index 00000000000..b4404112cf0 --- /dev/null +++ b/it/it-projects/highlighting/xoo-sample-with-highlighting-v1/src/main/xoo/sample/Sample.xoo.highlighting @@ -0,0 +1,15 @@ +#package +0:7:k +#public +19:25:k +#class +26:31:k +#public +46:52:k +#private +94:101:k +#return +#Here class is wrong and will be fixed during next analysis +125:131:s +#"hello" +132:139:s \ No newline at end of file diff --git a/it/it-projects/highlighting/xoo-sample-with-highlighting-v1/src/main/xoo/sample/Sample.xoo.measures b/it/it-projects/highlighting/xoo-sample-with-highlighting-v1/src/main/xoo/sample/Sample.xoo.measures new file mode 100644 index 00000000000..f95d11f14d0 --- /dev/null +++ b/it/it-projects/highlighting/xoo-sample-with-highlighting-v1/src/main/xoo/sample/Sample.xoo.measures @@ -0,0 +1,2 @@ +ncloc:13 + diff --git a/it/it-projects/highlighting/xoo-sample-with-highlighting-v2/sonar-project.properties b/it/it-projects/highlighting/xoo-sample-with-highlighting-v2/sonar-project.properties new file mode 100644 index 00000000000..8ec6e295138 --- /dev/null +++ b/it/it-projects/highlighting/xoo-sample-with-highlighting-v2/sonar-project.properties @@ -0,0 +1,5 @@ +sonar.projectKey=sample-with-highlighting +sonar.projectName=Sample With Highlighting +sonar.projectVersion=1.0-SNAPSHOT +sonar.sources=src/main/xoo +sonar.language=xoo diff --git a/it/it-projects/highlighting/xoo-sample-with-highlighting-v2/src/main/xoo/sample/Sample.xoo b/it/it-projects/highlighting/xoo-sample-with-highlighting-v2/src/main/xoo/sample/Sample.xoo new file mode 100644 index 00000000000..385b2a549d9 --- /dev/null +++ b/it/it-projects/highlighting/xoo-sample-with-highlighting-v2/src/main/xoo/sample/Sample.xoo @@ -0,0 +1,12 @@ +package sample; + +public class Sample { + + public Sample(int i) { + int j = i++; + } + + private String myMethod() { + return "hello"; + } +} diff --git a/it/it-projects/highlighting/xoo-sample-with-highlighting-v2/src/main/xoo/sample/Sample.xoo.highlighting b/it/it-projects/highlighting/xoo-sample-with-highlighting-v2/src/main/xoo/sample/Sample.xoo.highlighting new file mode 100644 index 00000000000..6acb0fa312e --- /dev/null +++ b/it/it-projects/highlighting/xoo-sample-with-highlighting-v2/src/main/xoo/sample/Sample.xoo.highlighting @@ -0,0 +1,14 @@ +#package +0:7:k +#public +19:25:k +#class +26:31:k +#public +46:52:k +#private +94:101:k +#return +125:131:k +#"hello" +132:139:s \ No newline at end of file diff --git a/it/it-projects/highlighting/xoo-sample-with-highlighting-v2/src/main/xoo/sample/Sample.xoo.measures b/it/it-projects/highlighting/xoo-sample-with-highlighting-v2/src/main/xoo/sample/Sample.xoo.measures new file mode 100644 index 00000000000..f95d11f14d0 --- /dev/null +++ b/it/it-projects/highlighting/xoo-sample-with-highlighting-v2/src/main/xoo/sample/Sample.xoo.measures @@ -0,0 +1,2 @@ +ncloc:13 + diff --git a/it/it-projects/highlighting/xoo-sample-with-highlighting-v2/src/main/xoo/sample/Sample.xoo.symbol b/it/it-projects/highlighting/xoo-sample-with-highlighting-v2/src/main/xoo/sample/Sample.xoo.symbol new file mode 100644 index 00000000000..a670a2d7b2d --- /dev/null +++ b/it/it-projects/highlighting/xoo-sample-with-highlighting-v2/src/main/xoo/sample/Sample.xoo.symbol @@ -0,0 +1,4 @@ +#j +60:61 +#i +64:65,80:81 diff --git a/it/it-tests/src/test/java/it/Category4Suite.java b/it/it-tests/src/test/java/it/Category4Suite.java index 485cc383466..16c26914b50 100644 --- a/it/it-tests/src/test/java/it/Category4Suite.java +++ b/it/it-tests/src/test/java/it/Category4Suite.java @@ -28,6 +28,7 @@ import it.dbCleaner.PurgeTest; import it.duplication.CrossProjectDuplicationsOnRemoveFileTest; import it.duplication.CrossProjectDuplicationsTest; import it.duplication.DuplicationsTest; +import it.highlighting.HighlightingTest; import it.projectEvent.EventTest; import it.serverSystem.ServerSystemTest; import it.user.BaseIdentityProviderTest; @@ -68,7 +69,9 @@ import static util.ItUtils.xooPlugin; // db cleaner PurgeTest.class, // project event - EventTest.class + EventTest.class, + // highlighting + HighlightingTest.class }) public class Category4Suite { diff --git a/it/it-tests/src/test/java/it/highlighting/HighlightingTest.java b/it/it-tests/src/test/java/it/highlighting/HighlightingTest.java new file mode 100644 index 00000000000..afd05117b0e --- /dev/null +++ b/it/it-tests/src/test/java/it/highlighting/HighlightingTest.java @@ -0,0 +1,59 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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 it.highlighting; + +import com.sonar.orchestrator.Orchestrator; +import com.sonar.orchestrator.build.SonarScanner; +import com.sonar.orchestrator.selenium.Selenese; +import it.Category4Suite; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Test; +import util.ItUtils; + +public class HighlightingTest { + + @ClassRule + public static Orchestrator orchestrator = Category4Suite.ORCHESTRATOR; + + @Before + public void deleteData() { + orchestrator.resetData(); + } + + // Check that E/S index is updated when file content is unchanged but plugin generates different syntax/symbol highlighting + @Test + public void updateHighlightingEvenWhenCodeUnchanged() throws Exception { + SonarScanner runner = SonarScanner.create(ItUtils.projectDir("highlighting/xoo-sample-with-highlighting-v1")); + orchestrator.executeBuild(runner); + + Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("syntax-highlighting-v1", + "/highlighting/HighlightingTest/syntax-highlighting-v1.html").build(); + orchestrator.executeSelenese(selenese); + + runner = SonarScanner.create(ItUtils.projectDir("highlighting/xoo-sample-with-highlighting-v2")); + orchestrator.executeBuild(runner); + + selenese = Selenese.builder().setHtmlTestsInClasspath("syntax-highlighting-v2", + "/highlighting/HighlightingTest/syntax-highlighting-v2.html", + "/highlighting/HighlightingTest/symbol-usages-highlighting.html").build(); + orchestrator.executeSelenese(selenese); + } +} diff --git a/it/it-tests/src/test/resources/highlighting/HighlightingTest/symbol-usages-highlighting.html b/it/it-tests/src/test/resources/highlighting/HighlightingTest/symbol-usages-highlighting.html new file mode 100644 index 00000000000..42e1fc154f2 --- /dev/null +++ b/it/it-tests/src/test/resources/highlighting/HighlightingTest/symbol-usages-highlighting.html @@ -0,0 +1,49 @@ + + + + + + highlight-symbol-usages + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
highlight-symbol-usages
open/component/index?id=sample-with-highlighting%3Asrc%2Fmain%2Fxoo%2Fsample%2FSample.xoo
waitForElementPresentcss=.source-line
waitForXpathCount//span[contains(@class, 'sym')]3
waitForXpathCount//span[contains(@class, 'sym highlighted')]0
click//span[contains(@class, 'sym')][2]
waitForXpathCount//span[contains(@class, 'sym highlighted')]2
+ + diff --git a/it/it-tests/src/test/resources/highlighting/HighlightingTest/syntax-highlighting-v1.html b/it/it-tests/src/test/resources/highlighting/HighlightingTest/syntax-highlighting-v1.html new file mode 100644 index 00000000000..368c3bdf58e --- /dev/null +++ b/it/it-tests/src/test/resources/highlighting/HighlightingTest/syntax-highlighting-v1.html @@ -0,0 +1,60 @@ + + + + + + java-syntax-highlighting + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
highlight-syntax-v1
open/component/index?id=sample-with-highlighting%3Asrc%2Fmain%2Fxoo%2Fsample%2FSample.xoo
waitForElementPresentcss=.source-line
storeHtmlSource
verifyHtmlSourceglob:*<span class="k">package</span>*
verifyHtmlSourceglob:*<span class="k">public</span>*
verifyHtmlSourceglob:*<span class="k">class</span>*
verifyHtmlSourceglob:*<span class="s">return</span>*
verifyHtmlSourceglob:*<span class="s">"hello"</span>*
+ + diff --git a/it/it-tests/src/test/resources/highlighting/HighlightingTest/syntax-highlighting-v2.html b/it/it-tests/src/test/resources/highlighting/HighlightingTest/syntax-highlighting-v2.html new file mode 100644 index 00000000000..57c535a10d3 --- /dev/null +++ b/it/it-tests/src/test/resources/highlighting/HighlightingTest/syntax-highlighting-v2.html @@ -0,0 +1,59 @@ + + + + + + java-syntax-highlighting + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
highlight-syntax-v2
open/component/index?id=sample-with-highlighting%3Asrc%2Fmain%2Fxoo%2Fsample%2FSample.xoo
waitForElementPresentcss=.source-line
storeHtmlSource
verifyHtmlSourceglob:*<span class="k">package</span>*
verifyHtmlSourceglob:*<span class="k">public</span>*
verifyHtmlSourceglob:*<span class="k">class</span>*
verifyHtmlSourceglob:*<span class="k">return</span>*
verifyHtmlSourceglob:*<span class="s">"hello"</span>*
+ + -- 2.39.5