use of com.vaadin.flow.server.VaadinServletService in project flow by vaadin.
the class WebComponentBootstrapHandlerTest method writeBootstrapPage_noExportChunk.
@Test
public void writeBootstrapPage_noExportChunk() throws IOException, ServiceException {
TestWebComponentBootstrapHandler handler = new TestWebComponentBootstrapHandler();
VaadinServletService service = new MockVaadinServletService();
initLookup(service);
VaadinSession session = new MockVaadinSession(service);
session.lock();
session.setConfiguration(service.getDeploymentConfiguration());
MockDeploymentConfiguration config = (MockDeploymentConfiguration) service.getDeploymentConfiguration();
config.setApplicationOrSystemProperty(SERVLET_PARAMETER_STATISTICS_JSON, VAADIN_SERVLET_RESOURCES + "config/stats_no_export.json");
config.setEnableDevServer(false);
VaadinServletRequest request = Mockito.mock(VaadinServletRequest.class);
Mockito.when(request.getService()).thenReturn(service);
Mockito.when(request.getServletPath()).thenReturn("/");
VaadinResponse response = getMockResponse(null);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
Mockito.when(response.getOutputStream()).thenReturn(stream);
handler.synchronizedHandleRequest(session, request, response);
// no "export" chunk, expect "bundle" in result instead
String result = stream.toString(StandardCharsets.UTF_8.name());
Assert.assertTrue(result.contains("VAADIN/build/vaadin-bundle-1111.cache.js"));
}
use of com.vaadin.flow.server.VaadinServletService in project flow by vaadin.
the class FrontendUtilsTest method getStatsAssetsByChunkName_getStatsFromClassPath_delegateToGetApplicationResource.
@Test
public void getStatsAssetsByChunkName_getStatsFromClassPath_delegateToGetApplicationResource() throws IOException {
VaadinServletService service = mockServletService();
ResourceProvider provider = mockResourceProvider(service);
FrontendUtils.getStatsAssetsByChunkName(service);
Mockito.verify(provider).getApplicationResource("foo");
}
use of com.vaadin.flow.server.VaadinServletService in project flow by vaadin.
the class FrontendUtilsTest method mockServletService.
private VaadinServletService mockServletService() {
VaadinServletService service = Mockito.mock(VaadinServletService.class);
VaadinServlet servlet = Mockito.mock(VaadinServlet.class);
Mockito.when(service.getServlet()).thenReturn(servlet);
return service;
}
Aggregations