]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9520 fix Tomcat error "Unexpected state: headers already parsed"
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 6 Jul 2017 07:25:30 +0000 (09:25 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 7 Jul 2017 09:36:41 +0000 (11:36 +0200)
pom.xml
server/sonar-server/pom.xml
tests/src/test/java/org/sonarqube/tests/serverSystem/ServerSystemTest.java
tests/src/test/resources/serverSystem/ServerSystemTest/url_ending_by_jsp.html

diff --git a/pom.xml b/pom.xml
index 36be56adfa3af0392f9c1c0c626fac9f6ce5ff37..254439d45da0326f70951a30484306c4e4d17452 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -67,7 +67,7 @@
     <jetty.version>8.1.12.v20130726</jetty.version>
     <logback.version>1.1.7</logback.version>
     <slf4j.version>1.7.21</slf4j.version>
-    <tomcat.version>8.5.11</tomcat.version>
+    <tomcat.version>8.5.16</tomcat.version>
     <elasticsearch.version>2.4.4</elasticsearch.version>
     <orchestrator.version>3.15.0.1090</orchestrator.version>
     <okhttp.version>3.7.0</okhttp.version>
         <groupId>org.apache.tomcat.embed</groupId>
         <artifactId>tomcat-embed-core</artifactId>
         <version>${tomcat.version}</version>
-      </dependency>
-      <dependency>
-        <groupId>org.apache.tomcat.embed</groupId>
-        <artifactId>tomcat-embed-jasper</artifactId>
-        <version>${tomcat.version}</version>
         <exclusions>
           <exclusion>
-            <groupId>org.eclipse.jdt.core.compiler</groupId>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-jasper</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>org.eclipse.jdt</groupId>
             <artifactId>ecj</artifactId>
           </exclusion>
         </exclusions>
index 41d96fa853432c26f8397110df350a8bc77ccb1f..89053a27fcbc2714807b37e4f5234422a94b32cd 100644 (file)
       <groupId>org.apache.tomcat.embed</groupId>
       <artifactId>tomcat-embed-core</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.apache.tomcat.embed</groupId>
-      <artifactId>tomcat-embed-jasper</artifactId>
-    </dependency>
     <dependency>
       <groupId>com.google.code.gson</groupId>
       <artifactId>gson</artifactId>
index ad4adf465199a2f52a5d870b72af75149d8791aa..ed7784b3db91c869c7fc62e24c02302c45e4a578 100644 (file)
@@ -21,7 +21,6 @@ package org.sonarqube.tests.serverSystem;
 
 import com.sonar.orchestrator.Orchestrator;
 import com.sonar.orchestrator.build.SonarScanner;
-import org.sonarqube.tests.Category4Suite;
 import java.io.File;
 import java.io.IOException;
 import java.util.Map;
@@ -29,28 +28,24 @@ import okhttp3.Response;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.json.simple.JSONValue;
-import org.junit.After;
 import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
+import org.sonarqube.pageobjects.Navigation;
+import org.sonarqube.pageobjects.ServerIdPage;
+import org.sonarqube.tests.Category4Suite;
+import org.sonarqube.tests.Tester;
 import org.sonarqube.ws.MediaTypes;
 import org.sonarqube.ws.ServerId.ShowWsResponse;
 import org.sonarqube.ws.client.GetRequest;
-import org.sonarqube.ws.client.WsClient;
 import org.sonarqube.ws.client.WsResponse;
-import org.sonarqube.pageobjects.Navigation;
-import org.sonarqube.pageobjects.ServerIdPage;
 import util.ItUtils;
-import util.user.UserRule;
 
 import static org.apache.commons.lang.StringUtils.startsWithAny;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.fail;
 import static util.ItUtils.call;
-import static util.ItUtils.newAdminWsClient;
-import static util.ItUtils.newWsClient;
-import static util.selenium.Selenese.runSelenese;
 
 public class ServerSystemTest {
 
@@ -60,16 +55,11 @@ public class ServerSystemTest {
   public static final Orchestrator orchestrator = Category4Suite.ORCHESTRATOR;
 
   @Rule
-  public UserRule userRule = UserRule.from(orchestrator);
+  public Tester tester = new Tester(orchestrator).disableOrganizations();
 
   @Before
   public void initAdminUser() {
-    userRule.createAdminUser(ADMIN_USER_LOGIN, ADMIN_USER_LOGIN);
-  }
-
-  @After
-  public void deleteAdminUser() {
-    userRule.resetUsers();
+    tester.users().generateAdministrator(u -> u.setLogin(ADMIN_USER_LOGIN).setPassword(ADMIN_USER_LOGIN));
   }
 
   @Test
@@ -90,7 +80,7 @@ public class ServerSystemTest {
 
   @Test
   public void generate_server_id() throws IOException {
-    Navigation nav = Navigation.create(orchestrator).openHome().logIn().submitCredentials(ADMIN_USER_LOGIN);
+    Navigation nav = tester.openBrowser().openHome().logIn().submitCredentials(ADMIN_USER_LOGIN);
     String validIpAddress = getValidIpAddress();
 
     nav.openServerId()
@@ -115,20 +105,20 @@ public class ServerSystemTest {
   }
 
   private Map<String, Object> callStatus() {
-    WsResponse statusResponse = newWsClient(orchestrator).wsConnector().call(new GetRequest("api/system/status"));
+    WsResponse statusResponse = tester.wsClient().wsConnector().call(new GetRequest("api/system/status"));
     return ItUtils.jsonToMap(statusResponse.content());
   }
 
   @Test
   public void display_system_info() {
-    runSelenese(orchestrator, "/serverSystem/ServerSystemTest/system_info.html");
+    tester.runHtmlTests("/serverSystem/ServerSystemTest/system_info.html");
   }
 
   @Test
   public void download_system_info() throws Exception {
     waitForComputeEngineToBeUp(orchestrator);
 
-    WsResponse response = newAdminWsClient(orchestrator).wsConnector().call(
+    WsResponse response = tester.wsClient().wsConnector().call(
       new GetRequest("api/system/info"));
 
     assertThat(response.code()).isEqualTo(200);
@@ -162,8 +152,9 @@ public class ServerSystemTest {
    */
   @Test
   public void display_warnings_when_using_h2() {
-    if (orchestrator.getConfiguration().getString("sonar.jdbc.dialect").equals("h2")) {
-      runSelenese(orchestrator, "/serverSystem/ServerSystemTest/derby-warning.html");
+    String dialect = orchestrator.getConfiguration().getString("sonar.jdbc.dialect");
+    if (dialect == null || dialect.equals("h2") || dialect.equals("embedded")) {
+      tester.runHtmlTests("/serverSystem/ServerSystemTest/derby-warning.html");
     }
   }
 
@@ -172,7 +163,7 @@ public class ServerSystemTest {
    */
   @Test
   public void hide_jdbc_settings_to_non_admin() {
-    runSelenese(orchestrator, "/serverSystem/ServerSystemTest/hide-jdbc-settings.html");
+    tester.runHtmlTests( "/serverSystem/ServerSystemTest/hide-jdbc-settings.html");
   }
 
   @Test
@@ -190,13 +181,12 @@ public class ServerSystemTest {
   /**
    * SONAR-3962
    */
-  // TODO should be moved elsewhere
   @Test
   public void not_fail_with_url_ending_by_jsp() {
     orchestrator.executeBuild(SonarScanner.create(ItUtils.projectDir("shared/xoo-sample"))
       .setProperty("sonar.projectKey", "myproject.jsp"));
     // Access dashboard
-    runSelenese(orchestrator, "/serverSystem/ServerSystemTest/url_ending_by_jsp.html");
+    tester.runHtmlTests("/serverSystem/ServerSystemTest/url_ending_by_jsp.html");
   }
 
   /**
@@ -213,8 +203,7 @@ public class ServerSystemTest {
   }
 
   private String getValidIpAddress() throws IOException {
-    WsClient adminWsClient = newAdminWsClient(orchestrator);
-    ShowWsResponse response = ShowWsResponse.parseFrom(adminWsClient.wsConnector().call(
+    ShowWsResponse response = ShowWsResponse.parseFrom(tester.wsClient().wsConnector().call(
       new GetRequest("api/server_id/show").setMediaType(MediaTypes.PROTOBUF)).contentStream());
     assertThat(response.getValidIpAddressesCount()).isGreaterThan(0);
     return response.getValidIpAddresses(0);
index 12056550fc21f8eda8011796d67ce7e57c281b7c..e162439dad9615a0577a5f685081cf10113c1ed0 100644 (file)
@@ -29,7 +29,7 @@
   <tbody>
   <tr>
     <td>open</td>
-    <td>/dashboard/index/myproject.jsp</td>
+    <td>/dashboard?id=myproject.jsp</td>
     <td></td>
   </tr>
   <tr>