"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "flow-server/src/test/java/com/vaadin/flow/server/DevModeHandlerTest.java" between
vaadin-flow-4.0.4.tar.gz and vaadin-flow-4.0.5.tar.gz

About: Vaadin flow is a Java framework binding Vaadin web components to Java.

DevModeHandlerTest.java  (vaadin-flow-4.0.4):DevModeHandlerTest.java  (vaadin-flow-4.0.5)
skipping to change at line 59 skipping to change at line 59
import javax.servlet.ServletConfig; import javax.servlet.ServletConfig;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.hamcrest.CoreMatchers; import org.hamcrest.CoreMatchers;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.junit.After; import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import org.mockito.Mockito; import org.mockito.Mockito;
skipping to change at line 558 skipping to change at line 560
@Test @Test
public void start_serverPortDoesNotWork_throws() throws Exception { public void start_serverPortDoesNotWork_throws() throws Exception {
exception.expect(CompletionException.class); exception.expect(CompletionException.class);
exception.expectCause(Matchers.instanceOf(IllegalStateException.class)); exception.expectCause(Matchers.instanceOf(IllegalStateException.class));
int port = DevModeHandler.getFreePort(); int port = DevModeHandler.getFreePort();
DevModeHandler handler = DevModeHandler.start(port, configuration, DevModeHandler handler = DevModeHandler.start(port, configuration,
npmFolder, CompletableFuture.completedFuture(null)); npmFolder, CompletableFuture.completedFuture(null));
handler.join(); handler.join();
} }
@Test
public void devModeNotReady_handleRequest_returnsHtml() throws Exception {
DevModeHandler handler = DevModeHandler.start(configuration, npmFolder,
CompletableFuture.completedFuture(null));
VaadinResponse response = Mockito.mock(VaadinResponse.class);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
Mockito.when(response.getOutputStream()).thenReturn(stream);
handler.handleRequest(Mockito.mock(VaadinSession.class),
Mockito.mock(VaadinRequest.class), response);
String devModeNotReadyContents = stream.toString("UTF-8");
Document document = Jsoup.parse(devModeNotReadyContents);
Assert.assertTrue("expected a head child",
document.head().children().size() > 0);
Assert.assertTrue("expected a body child",
document.body().children().size() > 0);
Mockito.verify(response).setContentType("text/html;charset=utf-8");
}
private VaadinServlet prepareServlet(int port) private VaadinServlet prepareServlet(int port)
throws ServletException, IOException { throws ServletException, IOException {
DevModeHandler.start(port, configuration, npmFolder, DevModeHandler.start(port, configuration, npmFolder,
CompletableFuture.completedFuture(null)).join(); CompletableFuture.completedFuture(null)).join();
VaadinServlet servlet = new VaadinServlet(); VaadinServlet servlet = new VaadinServlet();
ServletConfig cfg = mock(ServletConfig.class); ServletConfig cfg = mock(ServletConfig.class);
ServletContext ctx = mock(ServletContext.class); ServletContext ctx = mock(ServletContext.class);
Mockito.doAnswer(invocation -> ctx.getClass().getClassLoader()) Mockito.doAnswer(invocation -> ctx.getClass().getClassLoader())
.when(ctx).getClassLoader(); .when(ctx).getClassLoader();
Mockito.doAnswer(invocation -> ctx).when(cfg).getServletContext(); Mockito.doAnswer(invocation -> ctx).when(cfg).getServletContext();
 End of changes. 2 change blocks. 
0 lines changed or deleted 20 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)