Search in sources :

Example 6 with Context

use of org.craftercms.core.service.Context in project engine by craftercms.

the class TargetedContentStoreAdapterTest method testExists.

@Test
public void testExists() throws Exception {
    Context context = new TargetedContentStoreAdapter.ContextWrapper(storeAdapter, mock(Context.class));
    boolean exists = storeAdapter.exists(context, "/site/website/en");
    assertTrue(exists);
    exists = storeAdapter.exists(context, "/site/website/ja_JP_JP");
    assertTrue(exists);
    exists = storeAdapter.exists(context, "/site/website/ja_JP_JP/index.xml");
    assertTrue(exists);
    exists = storeAdapter.exists(context, "/site/website/index.xml");
    assertTrue(exists);
    exists = storeAdapter.exists(context, "/static-assets/css/main.css");
    assertTrue(exists);
}
Also used : Context(org.craftercms.core.service.Context) Test(org.junit.Test)

Example 7 with Context

use of org.craftercms.core.service.Context in project engine by craftercms.

the class TargetedContentStoreAdapterTest method testFindItems.

@Test
public void testFindItems() throws Exception {
    Context context = new TargetedContentStoreAdapter.ContextWrapper(storeAdapter, mock(Context.class));
    CachingOptions cachingOptions = CachingOptions.DEFAULT_CACHING_OPTIONS;
    List<Item> items = storeAdapter.findItems(context, cachingOptions, "/site/website/en", true);
    assertNotNull(items);
    assertEquals(2, items.size());
    assertEquals("index.xml", items.get(0).getName());
    assertEquals("/site/website/en/index.xml", items.get(0).getUrl());
    assertEquals("about-us", items.get(1).getName());
    assertEquals("/site/website/en/about-us", items.get(1).getUrl());
    items = storeAdapter.findItems(context, cachingOptions, "/site/website/ja_JP_JP", true);
    assertNotNull(items);
    assertEquals(2, items.size());
    assertEquals("index.xml", items.get(0).getName());
    assertEquals("/site/website/ja/index.xml", items.get(0).getUrl());
    assertEquals("about-us", items.get(1).getName());
    assertEquals("/site/website/en/about-us", items.get(1).getUrl());
    config.setProperty(SiteProperties.MERGE_FOLDERS_CONFIG_KEY, false);
    items = storeAdapter.findItems(context, cachingOptions, "/site/website/ja_JP_JP", true);
    assertNotNull(items);
    assertEquals(1, items.size());
    assertEquals("index.xml", items.get(0).getName());
    assertEquals("/site/website/ja/index.xml", items.get(0).getUrl());
}
Also used : Context(org.craftercms.core.service.Context) Item(org.craftercms.core.service.Item) CachingOptions(org.craftercms.core.service.CachingOptions) Test(org.junit.Test)

Example 8 with Context

use of org.craftercms.core.service.Context in project engine by craftercms.

the class TargetedContentStoreAdapterTest method testFindItem.

@Test
public void testFindItem() throws Exception {
    Context context = new TargetedContentStoreAdapter.ContextWrapper(storeAdapter, mock(Context.class));
    CachingOptions cachingOptions = CachingOptions.DEFAULT_CACHING_OPTIONS;
    Item item = storeAdapter.findItem(context, cachingOptions, "/site/website/en", true);
    assertNotNull(item);
    assertEquals("en", item.getName());
    assertEquals("/site/website/en", item.getUrl());
    item = storeAdapter.findItem(context, cachingOptions, "/site/website/ja_JP_JP", true);
    assertNotNull(item);
    assertEquals("en", item.getName());
    assertEquals("/site/website/en", item.getUrl());
    item = storeAdapter.findItem(context, cachingOptions, "/site/website/ja_JP_JP/index.xml", true);
    assertNotNull(item);
    assertEquals("index.xml", item.getName());
    assertEquals("/site/website/en/index.xml", item.getUrl());
    item = storeAdapter.findItem(context, cachingOptions, "/site/website/index.xml", true);
    assertNotNull(item);
    assertEquals("index.xml", item.getName());
    assertEquals("/site/website/index.xml", item.getUrl());
    item = storeAdapter.findItem(context, cachingOptions, "/static-assets/css/main.css", true);
    assertNotNull(item);
    assertEquals("main.css", item.getName());
    assertEquals("/static-assets/css/main.css", item.getUrl());
}
Also used : Context(org.craftercms.core.service.Context) Item(org.craftercms.core.service.Item) CachingOptions(org.craftercms.core.service.CachingOptions) Test(org.junit.Test)

Aggregations

Context (org.craftercms.core.service.Context)8 Test (org.junit.Test)5 CachingOptions (org.craftercms.core.service.CachingOptions)4 Item (org.craftercms.core.service.Item)3 SiteContext (org.craftercms.engine.service.context.SiteContext)3 ServletContext (javax.servlet.ServletContext)2 ContentStoreService (org.craftercms.core.service.ContentStoreService)2 ScriptFactory (org.craftercms.engine.scripting.ScriptFactory)2 JobContext (org.craftercms.engine.util.quartz.JobContext)2 URLClassLoader (java.net.URLClassLoader)1 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1 ConfigurationException (org.apache.commons.configuration.ConfigurationException)1 HierarchicalConfiguration (org.apache.commons.configuration.HierarchicalConfiguration)1 Content (org.craftercms.core.service.Content)1 ContentStoreAdapter (org.craftercms.core.store.ContentStoreAdapter)1 MergeableDescriptor (org.craftercms.core.xml.mergers.MergeableDescriptor)1 SiteContextCreationException (org.craftercms.engine.exception.SiteContextCreationException)1 GroovyScriptFactory (org.craftercms.engine.scripting.impl.GroovyScriptFactory)1 ContentStoreGroovyResourceLoader (org.craftercms.engine.util.groovy.ContentStoreGroovyResourceLoader)1