Search in sources :

Example 1 with CachingOptions

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

the class TargetedContentStoreAdapterTest method testFindContent.

@Test
public void testFindContent() throws Exception {
    Context context = new TargetedContentStoreAdapter.ContextWrapper(storeAdapter, mock(Context.class));
    CachingOptions cachingOptions = CachingOptions.DEFAULT_CACHING_OPTIONS;
    Content content = storeAdapter.findContent(context, cachingOptions, "/site/website/en/index.xml");
    assertNotNull(content);
    content = storeAdapter.findContent(context, cachingOptions, "/site/website/ja_jp_jp/index.xml");
    assertNotNull(content);
    content = storeAdapter.findContent(context, cachingOptions, "/site/website/index.xml");
    assertNotNull(content);
    content = storeAdapter.findContent(context, cachingOptions, "/static-assets/css/main.css");
    assertNotNull(content);
}
Also used : Context(org.craftercms.core.service.Context) CachingOptions(org.craftercms.core.service.CachingOptions) Content(org.craftercms.core.service.Content) Test(org.junit.Test)

Example 2 with CachingOptions

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

the class TargetedContentStoreAdapterDecoratorTest method testFindItem.

@Test
public void testFindItem() throws Exception {
    Context context = new DecoratedStoreAdapterContext(mock(Context.class), storeAdapter);
    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 : DecoratedStoreAdapterContext(org.craftercms.engine.util.store.decorators.DecoratedStoreAdapterContext) Context(org.craftercms.core.service.Context) Item(org.craftercms.core.service.Item) CachingOptions(org.craftercms.core.service.CachingOptions) DecoratedStoreAdapterContext(org.craftercms.engine.util.store.decorators.DecoratedStoreAdapterContext) Test(org.junit.Test)

Example 3 with CachingOptions

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

the class DeploymentEventsWatcher method loadDeploymentEvents.

private Properties loadDeploymentEvents(SiteContext siteContext) throws IOException {
    ContentStoreService contentStoreService = siteContext.getStoreService();
    Context context = siteContext.getContext();
    CachingOptions cachingOptions = CachingOptions.CACHE_OFF_CACHING_OPTIONS;
    Content content = contentStoreService.findContent(context, cachingOptions, deploymentEventsFileUrl);
    Properties events = new Properties();
    if (content != null) {
        events.load(new InputStreamReader(content.getInputStream(), StandardCharsets.UTF_8));
    }
    return events;
}
Also used : SiteContext(org.craftercms.engine.service.context.SiteContext) Context(org.craftercms.core.service.Context) CachingOptions(org.craftercms.core.service.CachingOptions) ContentStoreService(org.craftercms.core.service.ContentStoreService) InputStreamReader(java.io.InputStreamReader) Content(org.craftercms.core.service.Content) Properties(java.util.Properties)

Example 4 with CachingOptions

use of org.craftercms.core.service.CachingOptions 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)

Example 5 with CachingOptions

use of org.craftercms.core.service.CachingOptions 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)

Aggregations

CachingOptions (org.craftercms.core.service.CachingOptions)9 Context (org.craftercms.core.service.Context)8 Test (org.junit.Test)7 Item (org.craftercms.core.service.Item)4 DecoratedStoreAdapterContext (org.craftercms.engine.util.store.decorators.DecoratedStoreAdapterContext)4 Content (org.craftercms.core.service.Content)3 SiteContext (org.craftercms.engine.service.context.SiteContext)2 InputStreamReader (java.io.InputStreamReader)1 Properties (java.util.Properties)1 ContentStoreService (org.craftercms.core.service.ContentStoreService)1