Search in sources :

Example 36 with SiteContext

use of org.craftercms.engine.service.context.SiteContext in project engine by craftercms.

the class ToCurrentTargetedVersionItemProcessorTest method setUpCurrentConfig.

private void setUpCurrentConfig() {
    XMLConfiguration config = mock(XMLConfiguration.class);
    when(config.getBoolean(TARGETING_ENABLED_CONFIG_KEY, false)).thenReturn(true);
    SiteContext siteContext = mock(SiteContext.class);
    when(siteContext.getSiteName()).thenReturn("test");
    when(siteContext.getConfig()).thenReturn(config);
    SiteContext.setCurrent(siteContext);
}
Also used : XMLConfiguration(org.apache.commons.configuration2.XMLConfiguration) SiteContext(org.craftercms.engine.service.context.SiteContext)

Example 37 with SiteContext

use of org.craftercms.engine.service.context.SiteContext in project engine by craftercms.

the class ConfigurationScriptJobResolverTest method setUpSiteContext.

private void setUpSiteContext(SiteContext siteContext, ContentStoreService storeService) throws Exception {
    XMLConfiguration config = ConfigUtils.readXmlConfiguration(new ClassPathResource("config/site-config.xml"), ',');
    config.setListDelimiterHandler(new DefaultListDelimiterHandler(','));
    when(siteContext.getSiteName()).thenReturn("default");
    when(siteContext.getContext()).thenReturn(mock(Context.class));
    when(siteContext.getStoreService()).thenReturn(storeService);
    when(siteContext.getConfig()).thenReturn(config);
}
Also used : SiteContext(org.craftercms.engine.service.context.SiteContext) Context(org.craftercms.core.service.Context) JobContext(org.craftercms.engine.util.quartz.JobContext) XMLConfiguration(org.apache.commons.configuration2.XMLConfiguration) DefaultListDelimiterHandler(org.apache.commons.configuration2.convert.DefaultListDelimiterHandler) ClassPathResource(org.springframework.core.io.ClassPathResource)

Example 38 with SiteContext

use of org.craftercms.engine.service.context.SiteContext in project engine by craftercms.

the class CandidateTargetedUrlsResolverImplTest method setUpCurrentSiteContext.

private void setUpCurrentSiteContext() {
    HierarchicalConfiguration config = mock(HierarchicalConfiguration.class);
    when(config.getStringArray(ROOT_FOLDERS_CONFIG_KEY)).thenReturn(ROOT_FOLDERS);
    SiteContext context = new SiteContext();
    context.setSiteName(SITE_NAME);
    context.setConfig(config);
    SiteContext.setCurrent(context);
}
Also used : SiteContext(org.craftercms.engine.service.context.SiteContext) HierarchicalConfiguration(org.apache.commons.configuration2.HierarchicalConfiguration)

Example 39 with SiteContext

use of org.craftercms.engine.service.context.SiteContext in project engine by craftercms.

the class TargetedContentDescriptorMergeStrategyTest method setUpCurrentSiteContext.

private void setUpCurrentSiteContext() {
    HierarchicalConfiguration config = mock(HierarchicalConfiguration.class);
    when(config.getStringArray(ROOT_FOLDERS_CONFIG_KEY)).thenReturn(ROOT_FOLDERS);
    when(config.getStringArray(AVAILABLE_TARGET_IDS_CONFIG_KEY)).thenReturn(AVAILABLE_TARGET_IDS);
    when(config.getString(FALLBACK_ID_CONFIG_KEY)).thenReturn(FALLBACK_TARGET_ID);
    SiteContext siteContext = new SiteContext();
    siteContext.setSiteName(SITE_NAME);
    siteContext.setConfig(config);
    SiteContext.setCurrent(siteContext);
}
Also used : SiteContext(org.craftercms.engine.service.context.SiteContext) HierarchicalConfiguration(org.apache.commons.configuration2.HierarchicalConfiguration)

Aggregations

SiteContext (org.craftercms.engine.service.context.SiteContext)39 HierarchicalConfiguration (org.apache.commons.configuration2.HierarchicalConfiguration)8 ScriptFactory (org.craftercms.engine.scripting.ScriptFactory)8 Context (org.craftercms.core.service.Context)7 HashMap (java.util.HashMap)4 ServletContext (javax.servlet.ServletContext)4 XMLConfiguration (org.apache.commons.configuration2.XMLConfiguration)4 RequestContext (org.craftercms.commons.http.RequestContext)4 IOException (java.io.IOException)3 Callback (org.craftercms.commons.lang.Callback)3 Content (org.craftercms.core.service.Content)3 ContentStoreService (org.craftercms.core.service.ContentStoreService)3 Script (org.craftercms.engine.scripting.Script)3 TemplateException (freemarker.template.TemplateException)2 ArrayList (java.util.ArrayList)2 Configuration (org.apache.commons.configuration2.Configuration)2 DefaultListDelimiterHandler (org.apache.commons.configuration2.convert.DefaultListDelimiterHandler)2 CrafterException (org.craftercms.core.exception.CrafterException)2 ConfigurationException (org.craftercms.engine.exception.ConfigurationException)2 JobContext (org.craftercms.engine.util.quartz.JobContext)2