WorkspaceInitializer implements ServletContextAware { @PostConstruct public synchronized void contextInitialized() { if(!initialized) { try { workspace.initialize(); for (LiveRepositoryUpdate migration : migrations) { migration.start(); } cleanWorkspace(); initialized = true; } catch (IOException e) { throw new DesignerInitializerException("Unable to initialize workspace", e); } } }  @Resource(name = "liveRepositoriesUpdate") void setMigrations(List<LiveRepositoryUpdate> migrations); @PostConstruct synchronized void contextInitialized(); synchronized void cleanWorkspace(); synchronized void migrateWorkspace(); @Override void setServletContext(ServletContext servletContext); synchronized void indexingArtifacts(List<Page> pages, PageRepository pageRepository);  }
@Test public void should_initialize_workspace() throws Exception { workspaceInitializer.contextInitialized(); verify(workspace).initialize(); verify(workspace).cleanPageWorkspace(); }
@Test public void should_start_page_live_migration() throws Exception { workspaceInitializer.contextInitialized(); verify(pageRepositoryLiveUpdate).start(); }
@Test public void should_start_widget_live_migration() throws Exception { workspaceInitializer.contextInitialized(); verify(widgetRepositoryLiveUpdate).start(); }
@Test(expected = RuntimeException.class) public void should_throw_runtimeException_if_error_occurs_while_initializing_workspace() throws Exception { doThrow(new IOException()).when(workspace).initialize(); workspaceInitializer.contextInitialized(); }