use of com.vaadin.ui.ConnectorTracker in project cuba by cuba-platform.
the class TestUiEnvironment method setupVaadinUi.
protected void setupVaadinUi() {
AutowireCapableBeanFactory injector = getInjector();
app = new DefaultApp();
setThemeConstants(app, new ThemeConstants(new HashMap<>()));
setCookies(app, new AppCookies());
Connection connection = new ConnectionImpl();
injector.autowireBean(connection);
setConnection(app, connection);
VaadinSession vaadinSession = new TestVaadinSession(new WebBrowser(), getLocale());
vaadinSession.setAttribute(App.class, app);
vaadinSession.setAttribute(App.NAME, app);
vaadinSession.setAttribute(Connection.class, connection);
vaadinSession.setAttribute(Connection.NAME, connection);
vaadinSession.setAttribute(UserSession.class, sessionSource.getSession());
VaadinSession.setCurrent(vaadinSession);
injector.autowireBean(app);
ui = new AppUI();
injector.autowireBean(ui);
// setup UI
ConnectorTracker connectorTracker = new TestConnectorTracker(ui);
try {
getDeclaredField(UI.class, "connectorTracker", true).set(ui, connectorTracker);
getDeclaredField(UI.class, "session", true).set(ui, vaadinSession);
} catch (Exception e) {
throw new RuntimeException("Unable to init Vaadin UI state", e);
}
UI.setCurrent(ui);
VaadinRequest vaadinRequest = new TestVaadinRequest();
ui.getPage().init(vaadinRequest);
initUi(ui, vaadinRequest);
}
Aggregations