use of com.vaadin.flow.server.MockVaadinContext in project flow by vaadin.
the class FeatureFlagsTest method before.
@Before
public void before() throws IOException {
propertiesDir = temporaryFolder.newFolder();
context = new MockVaadinContext();
configuration = Mockito.mock(ApplicationConfiguration.class);
Mockito.when(configuration.isProductionMode()).thenReturn(false);
context.setAttribute(ApplicationConfiguration.class, configuration);
featureFlags = FeatureFlags.get(context);
featureFlags.setPropertiesLocation(propertiesDir);
mockResourcesLocation();
}
use of com.vaadin.flow.server.MockVaadinContext in project flow by vaadin.
the class PushAtmosphereHandlerTest method setup.
@Before
public void setup() throws IOException {
request = Mockito.mock(AtmosphereRequest.class);
response = Mockito.mock(AtmosphereResponse.class);
printWriter = Mockito.mock(PrintWriter.class);
Mockito.when(response.getWriter()).thenReturn(printWriter);
resource = Mockito.mock(AtmosphereResource.class);
Mockito.when(resource.getRequest()).thenReturn(request);
Mockito.when(resource.getResponse()).thenReturn(response);
VaadinContext context = new MockVaadinContext();
ApplicationConfiguration config = Mockito.mock(ApplicationConfiguration.class);
Mockito.when(config.getPropertyNames()).thenReturn(Collections.emptyEnumeration());
Mockito.when(config.getContext()).thenReturn(context);
VaadinServletService service = new VaadinServletService(null, new DefaultDeploymentConfiguration(config, getClass(), new Properties()));
PushHandler handler = new PushHandler(service);
atmosphereHandler = new PushAtmosphereHandler();
atmosphereHandler.setPushHandler(handler);
}
use of com.vaadin.flow.server.MockVaadinContext in project flow by vaadin.
the class UidlRequestHandlerTest method writeSessionExpired.
@Test
public void writeSessionExpired() throws Exception {
ApplicationConfiguration config = Mockito.mock(ApplicationConfiguration.class);
Mockito.when(config.getPropertyNames()).thenReturn(Collections.emptyEnumeration());
Mockito.when(config.getBuildFolder()).thenReturn(".");
VaadinContext context = new MockVaadinContext();
Mockito.when(config.getContext()).thenReturn(context);
VaadinService service = new VaadinServletService(null, new DefaultDeploymentConfiguration(config, getClass(), new Properties()));
when(request.getService()).thenReturn(service);
when(request.getParameter(ApplicationConstants.REQUEST_TYPE_PARAMETER)).thenReturn(RequestType.UIDL.getIdentifier());
boolean result = handler.handleSessionExpired(request, response);
Assert.assertTrue("Result should be true", result);
String responseContent = CommunicationUtil.getStringWhenWriteBytesOffsetLength(outputStream);
// response shouldn't contain async
Assert.assertEquals("Invalid response", "for(;;);[{\"meta\":{\"sessionExpired\":true}}]", responseContent);
}
use of com.vaadin.flow.server.MockVaadinContext in project flow by vaadin.
the class NavigationStateRendererTest method init.
@Before
public void init() {
RouteRegistry registry = ApplicationRouteRegistry.getInstance(new MockVaadinContext());
router = new Router(registry);
}
use of com.vaadin.flow.server.MockVaadinContext in project flow by vaadin.
the class RouteConfigurationTest method init.
@Before
public void init() {
servletContext = new MockServletContext();
vaadinContext = new MockVaadinContext(servletContext);
registry = ApplicationRouteRegistry.getInstance(vaadinContext);
vaadinService = Mockito.mock(MockService.class);
Mockito.when(vaadinService.getRouteRegistry()).thenReturn(registry);
Mockito.when(vaadinService.getContext()).thenReturn(vaadinContext);
VaadinService.setCurrent(vaadinService);
session = new MockVaadinSession(vaadinService) {
@Override
public VaadinService getService() {
return vaadinService;
}
};
}
Aggregations