use of org.exoplatform.test.MockConfigurationManagerImpl in project kernel by exoplatform.
the class RootContainer method getPortalContainer.
public PortalContainer getPortalContainer(final String name) {
PortalContainer pcontainer = getComponentInstance(name, PortalContainer.class);
if (pcontainer == null) {
J2EEServerInfo senv = getServerEnvironment();
if ("standalone".equals(senv.getServerName()) || "test".equals(senv.getServerName())) {
try {
MockServletContext scontext = new MockServletContext(name);
pcontainer = new PortalContainer(this, scontext);
final PortalContainer currentPortalContainer = pcontainer;
SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>() {
public Void run() {
PortalContainer.setInstance(currentPortalContainer);
return null;
}
});
final ConfigurationManagerImpl cService = new MockConfigurationManagerImpl(scontext);
cService.addConfiguration(ContainerUtil.getConfigurationURL("conf/portal/configuration.xml"));
cService.addConfiguration(ContainerUtil.getConfigurationURL("conf/portal/test-configuration.xml"));
cService.processRemoveConfiguration();
SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>() {
public Void run() {
currentPortalContainer.registerComponentInstance(ConfigurationManager.class, cService);
registerComponentInstance(name, currentPortalContainer);
currentPortalContainer.start(true);
onStartupComplete();
return null;
}
});
} catch (Exception ex) {
LOG.error(ex.getLocalizedMessage(), ex);
}
}
}
return pcontainer;
}
Aggregations