use of com.vaadin.base.devserver.startup.DevModeStartupListener in project flow by vaadin.
the class DevModeEndpointTest method setup.
@Before
@SuppressWarnings({ "unchecked", "rawtypes" })
public void setup() throws Exception {
super.setup();
assertFalse("No DevModeHandler should be available at test start", DevModeHandlerManager.getDevModeHandler(new VaadinServletContext(servletContext)).isPresent());
createStubNode(false, true, baseDir);
createStubWebpackServer("Compiled", 500, baseDir, true);
// Prevent TaskRunNpmInstall#cleanUp from deleting node_modules
new File(baseDir, "node_modules/.modules.yaml").createNewFile();
ServletRegistration vaadinServletRegistration = Mockito.mock(ServletRegistration.class);
Mockito.doReturn(new EndpointGeneratorTaskFactoryImpl()).when(lookup).lookup(EndpointGeneratorTaskFactory.class);
ResourceProvider resourceProvider = Mockito.mock(ResourceProvider.class);
Mockito.when(lookup.lookup(ResourceProvider.class)).thenReturn(resourceProvider);
Mockito.when(vaadinServletRegistration.getClassName()).thenReturn(VaadinServletSubClass.class.getName());
classes = new HashSet<>();
classes.add(this.getClass());
Map registry = new HashMap();
// Adding extra registrations to make sure that
// DevModeInitializer picks
// the correct registration which is a VaadinServlet
// registration.
registry.put("extra1", Mockito.mock(ServletRegistration.class));
registry.put("foo", vaadinServletRegistration);
registry.put("extra2", Mockito.mock(ServletRegistration.class));
Mockito.when(servletContext.getServletRegistrations()).thenReturn(registry);
Mockito.when(servletContext.getInitParameterNames()).thenReturn(Collections.emptyEnumeration());
Mockito.when(servletContext.getClassLoader()).thenReturn(this.getClass().getClassLoader());
FileUtils.forceMkdir(new File(baseDir, DEFAULT_CONNECT_JAVA_SOURCE_FOLDER));
devModeStartupListener = new DevModeStartupListener();
}
Aggregations