Skip to content

Commit

Permalink
Fixes piranhacloud#3532 - Fix SonarCloud issue (piranhacloud#3533)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnriem authored Sep 7, 2023
1 parent f30a00e commit 237e3f8
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@

import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.WriteListener;
import static jakarta.servlet.http.HttpServletResponse.SC_SWITCHING_PROTOCOLS;
import java.io.IOException;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;

/**
* The JUnit tests for the DefaultWebApplicationResponse class.
Expand All @@ -45,17 +47,26 @@ class DefaultWebApplicationOutputStreamTest {
*
* @throws Exception when a serious error occurs.
*/
@Test
void testIsReady() throws Exception {
DefaultWebApplicationResponse response = new DefaultWebApplicationResponse();
ServletOutputStream outputStream = response.getOutputStream();
assertFalse(outputStream.isReady());
assertTrue(outputStream.isReady());
}

/**
* Test setWriteListener method.
*/
@Test
void testWriteListener() throws Exception {
DefaultWebApplication webApplication = new DefaultWebApplication();
DefaultWebApplicationRequest request = new DefaultWebApplicationRequest();
request.setWebApplication(webApplication);
request.setUpgraded(true);
DefaultWebApplicationResponse response = new DefaultWebApplicationResponse();
response.setStatus(SC_SWITCHING_PROTOCOLS);
webApplication.linkRequestAndResponse(request, response);
response.setWebApplication(webApplication);
ServletOutputStream outputStream = response.getOutputStream();
outputStream.setWriteListener(new WriteListener() {
@Override
Expand Down

0 comments on commit 237e3f8

Please sign in to comment.