use of org.sonar.api.server.ws.internal.ValidatingRequest in project sonarqube by SonarSource.
the class WebServiceEngineTest method unknown_parameter_is_set.
@Test
public void unknown_parameter_is_set() {
ValidatingRequest request = new TestRequest().setMethod("GET").setPath("/api/system/fail_with_undeclared_parameter").setParam("unknown", "Unknown");
DumbResponse response = new DumbResponse();
underTest.execute(request, response);
assertThat(response.stream().outputAsString()).isEqualTo("{\"errors\":[{\"msg\":\"BUG - parameter 'unknown' is undefined for action 'fail_with_undeclared_parameter'\"}]}");
}
use of org.sonar.api.server.ws.internal.ValidatingRequest in project sonarqube by SonarSource.
the class WebServiceEngineTest method no_content.
@Test
public void no_content() {
ValidatingRequest request = new TestRequest().setMethod("GET").setPath("/api/system/alive");
DumbResponse response = new DumbResponse();
underTest.execute(request, response);
assertThat(response.stream().outputAsString()).isEmpty();
}
use of org.sonar.api.server.ws.internal.ValidatingRequest in project sonarqube by SonarSource.
the class WebServiceEngineTest method does_not_fail_when_request_is_aborted_and_response_is_committed.
@Test
public void does_not_fail_when_request_is_aborted_and_response_is_committed() throws Exception {
ValidatingRequest request = new TestRequest().setMethod("GET").setPath("/api/system/fail_with_client_abort_exception");
Response response = mock(Response.class);
ServletResponse.ServletStream servletStream = mock(ServletResponse.ServletStream.class);
when(response.stream()).thenReturn(servletStream);
HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
when(httpServletResponse.isCommitted()).thenReturn(true);
when(servletStream.response()).thenReturn(httpServletResponse);
underTest.execute(request, response);
assertThat(logTester.logs(LoggerLevel.DEBUG)).isNotEmpty();
}
use of org.sonar.api.server.ws.internal.ValidatingRequest in project sonarqube by SonarSource.
the class WebServiceEngineTest method method_post_required.
@Test
public void method_post_required() {
ValidatingRequest request = new TestRequest().setMethod("POST").setPath("/api/system/ping");
DumbResponse response = new DumbResponse();
underTest.execute(request, response);
assertThat(response.stream().outputAsString()).isEqualTo("pong");
}
use of org.sonar.api.server.ws.internal.ValidatingRequest in project sonarqube by SonarSource.
the class WebServiceEngineTest method required_parameter_is_not_set.
@Test
public void required_parameter_is_not_set() {
ValidatingRequest request = new TestRequest().setMethod("GET").setPath("/api/system/print");
DumbResponse response = new DumbResponse();
underTest.execute(request, response);
assertThat(response.stream().outputAsString()).isEqualTo("{\"errors\":[{\"msg\":\"The 'message' parameter is missing\"}]}");
}
Aggregations