use of com.vaadin.flow.server.MockServletServiceSessionSetup in project flow by vaadin.
the class PublishedServerEventHandlerRpcHandlerTest method setUp.
@Before
public void setUp() throws Exception {
Assert.assertNull(System.getSecurityManager());
MockServletServiceSessionSetup setup = new MockServletServiceSessionSetup();
service = setup.getService();
MockDeploymentConfiguration configuration = setup.getDeploymentConfiguration();
configuration.setProductionMode(false);
VaadinService.setCurrent(service);
session = setup.getSession();
Mockito.when(session.hasLock()).thenReturn(true);
}
use of com.vaadin.flow.server.MockServletServiceSessionSetup in project flow by vaadin.
the class VaadinAppShellInitializerTest method setup.
@Before
public void setup() throws Exception {
logger = mockLog(VaadinAppShellInitializer.class);
mocks = new MockServletServiceSessionSetup();
servletContext = mocks.getServletContext();
appConfig = mockApplicationConfiguration();
Lookup lookup = (Lookup) servletContext.getAttribute(Lookup.class.getName());
Mockito.when(lookup.lookup(AppShellPredicate.class)).thenReturn(AppShellConfigurator.class::isAssignableFrom);
attributeMap.put(Lookup.class.getName(), servletContext.getAttribute(Lookup.class.getName()));
attributeMap.put(ApplicationConfiguration.class.getName(), appConfig);
service = mocks.getService();
Mockito.when(servletContext.getAttribute(Mockito.anyString())).then(invocationOnMock -> attributeMap.get(invocationOnMock.getArguments()[0].toString()));
Mockito.doAnswer(invocationOnMock -> attributeMap.put(invocationOnMock.getArguments()[0].toString(), invocationOnMock.getArguments()[1])).when(servletContext).setAttribute(Mockito.anyString(), Mockito.any());
ServletRegistration registration = Mockito.mock(ServletRegistration.class);
context = new VaadinServletContext(servletContext);
classes = new HashSet<>();
Map<String, ServletRegistration> registry = new HashMap<>();
registry.put("foo", registration);
Mockito.when(servletContext.getServletRegistrations()).thenReturn((Map) registry);
Mockito.when(servletContext.getInitParameterNames()).thenReturn(Collections.emptyEnumeration());
initializer = new VaadinAppShellInitializer();
document = Document.createShell("");
pushConfiguration = Mockito.mock(PushConfiguration.class);
}
Aggregations