Search in sources :

Example 1 with RequestHandler

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

the class WebServiceEngineTest method test_response_with_no_content.

@Test
public void test_response_with_no_content() {
    Request request = new TestRequest().setPath("api/foo");
    RequestHandler handler = (req, resp) -> resp.noContent();
    DumbResponse response = run(request, newWs("api/foo", a -> a.setHandler(handler)));
    assertThat(response.stream().outputAsString()).isEmpty();
    assertThat(response.status()).isEqualTo(204);
}
Also used : Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RunWith(org.junit.runner.RunWith) ClientAbortException(org.apache.catalina.connector.ClientAbortException) DataProvider(com.tngtech.java.junit.dataprovider.DataProvider) DataProviderRunner(com.tngtech.java.junit.dataprovider.DataProviderRunner) BadConfigurationException(org.sonar.server.exceptions.BadConfigurationException) BadRequestException(org.sonar.server.exceptions.BadRequestException) Request(org.sonar.api.server.ws.Request) WebService(org.sonar.api.server.ws.WebService) Response(org.sonar.api.server.ws.Response) MediaTypes(org.sonarqube.ws.MediaTypes) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) StringUtils.substringAfterLast(org.apache.commons.lang.StringUtils.substringAfterLast) StringUtils.substringBeforeLast(org.apache.commons.lang.StringUtils.substringBeforeLast) UTF_8(java.nio.charset.StandardCharsets.UTF_8) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider) HttpServletResponse(javax.servlet.http.HttpServletResponse) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) RequestHandler(org.sonar.api.server.ws.RequestHandler) Mockito.verify(org.mockito.Mockito.verify) Consumer(java.util.function.Consumer) Mockito(org.mockito.Mockito) Mockito.never(org.mockito.Mockito.never) Rule(org.junit.Rule) LogTester(org.sonar.api.utils.log.LogTester) LoggerLevel(org.sonar.api.utils.log.LoggerLevel) Mockito.mock(org.mockito.Mockito.mock) RequestHandler(org.sonar.api.server.ws.RequestHandler) Request(org.sonar.api.server.ws.Request) Test(org.junit.Test)

Aggregations

DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)1 DataProviderRunner (com.tngtech.java.junit.dataprovider.DataProviderRunner)1 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)1 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)1 Consumer (java.util.function.Consumer)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 ClientAbortException (org.apache.catalina.connector.ClientAbortException)1 StringUtils.substringAfterLast (org.apache.commons.lang.StringUtils.substringAfterLast)1 StringUtils.substringBeforeLast (org.apache.commons.lang.StringUtils.substringBeforeLast)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Rule (org.junit.Rule)1 Test (org.junit.Test)1 RunWith (org.junit.runner.RunWith)1 ArgumentMatchers.anyInt (org.mockito.ArgumentMatchers.anyInt)1 Mockito (org.mockito.Mockito)1 Mockito.mock (org.mockito.Mockito.mock)1 Mockito.never (org.mockito.Mockito.never)1 Mockito.verify (org.mockito.Mockito.verify)1 Mockito.when (org.mockito.Mockito.when)1 Request (org.sonar.api.server.ws.Request)1