Search in sources :

Example 16 with ValidatingRequest

use of org.sonar.api.server.ws.internal.ValidatingRequest in project sonarqube by SonarSource.

the class WebServiceEngineTest method execute_request_with_action_suffix.

@Test
public void execute_request_with_action_suffix() {
    ValidatingRequest request = new TestRequest().setMethod("GET").setPath("/api/system/health");
    DumbResponse response = new DumbResponse();
    underTest.execute(request, response);
    assertThat(response.stream().outputAsString()).isEqualTo("good");
}
Also used : ValidatingRequest(org.sonar.api.server.ws.internal.ValidatingRequest) Test(org.junit.Test)

Example 17 with ValidatingRequest

use of org.sonar.api.server.ws.internal.ValidatingRequest in project sonarqube by SonarSource.

the class WebServiceEngineTest method method_get_not_allowed.

@Test
public void method_get_not_allowed() {
    ValidatingRequest request = new TestRequest().setMethod("GET").setPath("/api/system/ping");
    DumbResponse response = new DumbResponse();
    underTest.execute(request, response);
    assertThat(response.stream().outputAsString()).isEqualTo("{\"errors\":[{\"msg\":\"HTTP method POST is required\"}]}");
}
Also used : ValidatingRequest(org.sonar.api.server.ws.internal.ValidatingRequest) Test(org.junit.Test)

Example 18 with ValidatingRequest

use of org.sonar.api.server.ws.internal.ValidatingRequest in project sonarqube by SonarSource.

the class WebServiceEngineTest method method_put_not_allowed.

@Test
public void method_put_not_allowed() {
    ValidatingRequest request = new TestRequest().setMethod("PUT").setPath("/api/system/ping");
    DumbResponse response = new DumbResponse();
    underTest.execute(request, response);
    assertThat(response.stream().outputAsString()).isEqualTo("{\"errors\":[{\"msg\":\"HTTP method PUT is not allowed\"}]}");
}
Also used : ValidatingRequest(org.sonar.api.server.ws.internal.ValidatingRequest) Test(org.junit.Test)

Example 19 with ValidatingRequest

use of org.sonar.api.server.ws.internal.ValidatingRequest in project sonarqube by SonarSource.

the class WebServiceEngineTest method method_delete_not_allowed.

@Test
public void method_delete_not_allowed() {
    ValidatingRequest request = new TestRequest().setMethod("DELETE").setPath("/api/system/ping");
    DumbResponse response = new DumbResponse();
    underTest.execute(request, response);
    assertThat(response.stream().outputAsString()).isEqualTo("{\"errors\":[{\"msg\":\"HTTP method DELETE is not allowed\"}]}");
}
Also used : ValidatingRequest(org.sonar.api.server.ws.internal.ValidatingRequest) Test(org.junit.Test)

Example 20 with ValidatingRequest

use of org.sonar.api.server.ws.internal.ValidatingRequest in project sonarqube by SonarSource.

the class WebServiceEngineTest method optional_parameter_is_not_set.

@Test
public void optional_parameter_is_not_set() {
    ValidatingRequest request = new TestRequest().setMethod("GET").setPath("/api/system/print").setParam("message", "Hello World");
    DumbResponse response = new DumbResponse();
    underTest.execute(request, response);
    assertThat(response.stream().outputAsString()).isEqualTo("Hello World by -");
}
Also used : ValidatingRequest(org.sonar.api.server.ws.internal.ValidatingRequest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)23 ValidatingRequest (org.sonar.api.server.ws.internal.ValidatingRequest)23 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 Response (org.sonar.api.server.ws.Response)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ClientAbortException (org.apache.catalina.connector.ClientAbortException)1 IOUtils (org.apache.commons.io.IOUtils)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 After (org.junit.After)1 Before (org.junit.Before)1 Rule (org.junit.Rule)1 ExpectedException (org.junit.rules.ExpectedException)1 Mockito.mock (org.mockito.Mockito.mock)1 Mockito.when (org.mockito.Mockito.when)1 WebService (org.sonar.api.server.ws.WebService)1 LogTester (org.sonar.api.utils.log.LogTester)1 LoggerLevel (org.sonar.api.utils.log.LoggerLevel)1 BadRequestException (org.sonar.server.exceptions.BadRequestException)1