use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.
the class DeploymentConfigurationFactoryTest method servletWithNoEnclosingUI_hasDefaultUiInConfig.
@Test
public void servletWithNoEnclosingUI_hasDefaultUiInConfig() throws Exception {
Class<NoSettings> servlet = NoSettings.class;
Map<String, String> servletConfigParams = new HashMap<>(defaultServletParams);
DeploymentConfiguration config = new DeploymentConfigurationFactory().createDeploymentConfiguration(servlet, createVaadinConfigMock(servletConfigParams, emptyMap()));
Class<?> notUiClass = servlet.getEnclosingClass();
assertFalse(String.format("Servlet '%s' should not have its enclosing class to be UI subclass, but got: '%s'", notUiClass, servlet), UI.class.isAssignableFrom(notUiClass));
assertEquals(String.format("Expected DeploymentConfiguration for servlet '%s' to have its enclosing UI class", servlet), UI.class.getName(), config.getUIClassName());
}
use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.
the class DeploymentConfigurationFactoryTest method externalStatsFileTrue_predefinedValuesAreNotOverridden.
@Test
public void externalStatsFileTrue_predefinedValuesAreNotOverridden() throws Exception {
// note that this situation shouldn't happen that the other
// settings
// would be against the external usage.
FileUtils.writeLines(tokenFile, Arrays.asList("{", "\"enableDevServer\": true,", // are used
"\"productionMode\": true,", "\"externalStatsFile\": true", "}"));
DeploymentConfiguration config = createConfig(Collections.singletonMap(PARAM_TOKEN_FILE, tokenFile.getPath()));
assertEquals(true, config.isProductionMode());
assertEquals(false, config.enableDevServer());
assertEquals(true, config.isStatsExternal());
assertEquals(Constants.DEFAULT_EXTERNAL_STATS_URL, config.getExternalStatsUrl());
}
use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.
the class MockUI method createUI.
public static MockUI createUI() {
DeploymentConfiguration configuration = createConfiguration();
VaadinSession session = createSession();
session.setConfiguration(configuration);
return new MockUI(session);
}
use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.
the class ServletDeployer method contextInitialized.
@Override
public void contextInitialized(ServletContextEvent sce) {
ServletContext context = sce.getServletContext();
Collection<DeploymentConfiguration> servletConfigurations = getServletConfigurations(context);
VaadinServletContext vaadinContext = new VaadinServletContext(context);
ApplicationConfiguration config = ApplicationConfiguration.get(vaadinContext);
boolean enableServlets = !config.disableAutomaticServletRegistration();
boolean productionMode = false;
for (DeploymentConfiguration configuration : servletConfigurations) {
productionMode = productionMode || configuration.isProductionMode();
}
VaadinServletCreation servletCreation = enableServlets ? createAppServlet(context) : null;
logServletCreation(servletCreation, context, productionMode);
}
use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.
the class ServletDeployer method getServletConfigurations.
private Collection<DeploymentConfiguration> getServletConfigurations(ServletContext context) {
Collection<? extends ServletRegistration> registrations = context.getServletRegistrations().values();
Collection<DeploymentConfiguration> result = new ArrayList<>(registrations.size());
for (ServletRegistration registration : registrations) {
loadClass(context.getClassLoader(), registration.getClassName()).ifPresent(servletClass -> result.add(StubServletConfig.createDeploymentConfiguration(context, registration, servletClass)));
}
return result;
}
Aggregations