use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.
the class VaadinServletTest method resolveTranslation_for_servlet_with_muliple_path_parts.
@Test
public void resolveTranslation_for_servlet_with_muliple_path_parts() throws MalformedURLException {
request = Mockito.mock(VaadinServletRequest.class);
CurrentInstance.set(VaadinRequest.class, request);
DeploymentConfiguration configuration = Mockito.mock(DeploymentConfiguration.class);
Mockito.when(((VaadinServletRequest) request).getServletPath()).thenReturn("/app/sub/");
Mockito.when(service.getDeploymentConfiguration()).thenReturn(configuration);
Mockito.when(configuration.isProductionMode()).thenReturn(false);
Mockito.when(factory.getUriResolver(request)).thenReturn(vaadinUriResolver);
String path = "/src/foo";
String resolved = "./../../src/bar";
Mockito.when(vaadinUriResolver.resolveVaadinUri(path)).thenReturn(resolved);
Mockito.when(vaadinUriResolver.resolveVaadinUri("/theme/foo")).thenReturn("./../../theme/foo");
Mockito.when(context.getResource("/./theme/foo")).thenReturn(new URL("http://theme/foo"));
String urlTranslation = servlet.getUrlTranslation(new MyTheme(), path);
Assert.assertEquals("/theme/foo", urlTranslation);
}
use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.
the class VaadinServletTest method resolveResource_webJarResource_resolvedAsWebJarsResource.
@Test
public void resolveResource_webJarResource_resolvedAsWebJarsResource() throws ServletException, MalformedURLException {
String path = "foo";
String frontendPrefix = "context://baz/";
String resolved = "/baz/bower_components/";
Mockito.when(vaadinUriResolver.resolveVaadinUri(path)).thenReturn(resolved);
service = Mockito.mock(VaadinServletService.class);
DeploymentConfiguration configuration = Mockito.mock(DeploymentConfiguration.class);
Mockito.when(configuration.getDevelopmentFrontendPrefix()).thenReturn(frontendPrefix);
Mockito.when(configuration.areWebJarsEnabled()).thenReturn(true);
Mockito.when(service.getDeploymentConfiguration()).thenReturn(configuration);
ServletConfig config = Mockito.mock(ServletConfig.class);
servlet.init(config);
CurrentInstance.set(VaadinRequest.class, request);
CurrentInstance.set(VaadinSession.class, session);
URL url = new URL("http://example.com");
String webjars = "/webjars/";
Mockito.when(context.getResource(webjars)).thenReturn(url);
Assert.assertEquals(webjars, servlet.resolveResource(path));
}
use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.
the class TemplateInitializerTest method createService.
@Override
protected VaadinService createService() {
VaadinService service = mock(VaadinService.class);
DeploymentConfiguration configuration = mock(DeploymentConfiguration.class);
when(configuration.isProductionMode()).thenReturn(false);
when(service.getDeploymentConfiguration()).thenReturn(configuration);
return service;
}
use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.
the class PolymerPublishedEventRpcHandlerTest method setup.
@Before
public void setup() {
service = Mockito.mock(VaadinService.class);
VaadinService.setCurrent(service);
DeploymentConfiguration configuration = Mockito.mock(DeploymentConfiguration.class);
Mockito.when(service.getDeploymentConfiguration()).thenReturn(configuration);
handler = new PolymerPublishedEventRpcHandler();
}
use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.
the class AbstractTemplateTest method init.
@Before
public void init() throws Exception {
service = Mockito.mock(VaadinService.class);
DeploymentConfiguration configuration = Mockito.mock(DeploymentConfiguration.class);
Mockito.when(service.getDeploymentConfiguration()).thenReturn(configuration);
VaadinSession session = Mockito.mock(VaadinSession.class);
ui = new UI();
ui.getInternals().setSession(session);
Mockito.when(session.getService()).thenReturn(service);
Instantiator instantiator = Mockito.mock(Instantiator.class);
Mockito.when(instantiator.createComponent(Mockito.any())).thenAnswer(invocation -> ReflectTools.createInstance(invocation.getArgument(0)));
Mockito.when(service.getInstantiator()).thenReturn(instantiator);
CurrentInstance.setCurrent(ui);
VaadinService.setCurrent(service);
}
Aggregations