use of org.craftercms.core.processors.impl.TextMetaDataCollectionExtractingProcessor in project core by craftercms.
the class ContentStoreServiceImplTest method testGetFolderItem.
@Test
public void testGetFolderItem() throws Exception {
Item item = contentStoreService.findItem(context, BUNDLE_FOLDER_PATH);
assertBundleFolderItem(item, false);
// Sleep so that we get a different caching time in the next call if the caching is being done wrong.
Thread.sleep(100);
Item cachedItem = contentStoreService.getItem(context, BUNDLE_FOLDER_PATH);
assertEquals(item, cachedItem);
assertCaching(item, cachedItem);
TextMetaDataCollectionExtractingProcessor extractor = new TextMetaDataCollectionExtractingProcessor("//extension");
item = contentStoreService.findItem(context, DEFAULT_CACHING_OPTIONS, BUNDLE_FOLDER_PATH, extractor);
assertBundleFolderItem(item, true);
// Sleep so that we get a different caching time in the next call if the caching is being done wrong.
Thread.sleep(100);
cachedItem = contentStoreService.getItem(context, DEFAULT_CACHING_OPTIONS, BUNDLE_FOLDER_PATH, extractor);
assertEquals(item, cachedItem);
assertCaching(item, cachedItem);
}
use of org.craftercms.core.processors.impl.TextMetaDataCollectionExtractingProcessor in project core by craftercms.
the class ContentStoreServiceImplTest method testGetChildren.
@Test
public void testGetChildren() throws Exception {
CachingAwareList<Item> children = (CachingAwareList<Item>) contentStoreService.findChildren(context, ROOT_FOLDER_PATH);
assertRootFolderChildren(children, false, false);
// Sleep so that we get a different caching time in the next call if the caching is being done wrong.
Thread.sleep(100);
CachingAwareList<Item> cachedChildren = (CachingAwareList<Item>) contentStoreService.getChildren(context, ROOT_FOLDER_PATH);
assertEquals(children, cachedChildren);
assertListCaching(children, cachedChildren);
children = (CachingAwareList<Item>) contentStoreService.findChildren(context, INVALID_PATH);
assertNull(children);
try {
contentStoreService.getChildren(context, INVALID_PATH);
fail("Expected " + PathNotFoundException.class.getName());
} catch (PathNotFoundException e) {
}
ItemProcessorPipeline extractorPipeline = new ItemProcessorPipeline();
extractorPipeline.addProcessor(new TextMetaDataCollectionExtractingProcessor("//extension"));
extractorPipeline.addProcessor(new TextMetaDataExtractingProcessor("//size"));
children = (CachingAwareList<Item>) contentStoreService.findChildren(context, DEFAULT_CACHING_OPTIONS, ROOT_FOLDER_PATH, OnlyNonDescriptorsFilter.instance, extractorPipeline);
assertRootFolderChildren(children, true, true);
// Sleep so that we get a different caching time in the next call if the caching is being done wrong.
Thread.sleep(100);
cachedChildren = (CachingAwareList<Item>) contentStoreService.getChildren(context, DEFAULT_CACHING_OPTIONS, ROOT_FOLDER_PATH, OnlyNonDescriptorsFilter.instance, extractorPipeline);
assertEquals(children, cachedChildren);
assertListCaching(children, cachedChildren);
children = (CachingAwareList<Item>) contentStoreService.findChildren(context, DEFAULT_CACHING_OPTIONS, INVALID_PATH, OnlyNonDescriptorsFilter.instance, extractorPipeline);
assertNull(children);
try {
contentStoreService.getChildren(context, DEFAULT_CACHING_OPTIONS, INVALID_PATH, OnlyNonDescriptorsFilter.instance, extractorPipeline);
assertNull(children);
fail("Expected " + PathNotFoundException.class.getName());
} catch (PathNotFoundException e) {
}
}
use of org.craftercms.core.processors.impl.TextMetaDataCollectionExtractingProcessor in project core by craftercms.
the class ContentStoreServiceImplTest method testGetTree.
@Test
public void testGetTree() throws Exception {
Tree tree = contentStoreService.findTree(context, ROOT_FOLDER_PATH);
assertRootFolderTree(tree, UNLIMITED_TREE_DEPTH, false, false);
// Sleep so that we get a different caching time in the next call if the caching is being done wrong.
Thread.sleep(100);
Tree cachedTree = contentStoreService.getTree(context, ROOT_FOLDER_PATH);
assertEquals(tree, cachedTree);
assertTreeCaching(tree, cachedTree);
tree = contentStoreService.findTree(context, INVALID_PATH);
assertNull(tree);
try {
contentStoreService.getTree(context, INVALID_PATH);
fail("Expected " + PathNotFoundException.class.getName());
} catch (PathNotFoundException e) {
}
tree = contentStoreService.findTree(context, ROOT_FOLDER_PATH, 1);
assertRootFolderTree(tree, 1, false, false);
// Sleep so that we get a different caching time in the next call if the caching is being done wrong.
Thread.sleep(100);
cachedTree = contentStoreService.getTree(context, ROOT_FOLDER_PATH, 1);
assertEquals(tree, cachedTree);
assertTreeCaching(tree, cachedTree);
tree = contentStoreService.findTree(context, INVALID_PATH, 1);
assertNull(tree);
try {
contentStoreService.getTree(context, INVALID_PATH, 1);
fail("Expected " + PathNotFoundException.class.getName());
} catch (PathNotFoundException e) {
}
ItemProcessorPipeline extractorPipeline = new ItemProcessorPipeline();
extractorPipeline.addProcessor(new TextMetaDataCollectionExtractingProcessor("//extension"));
extractorPipeline.addProcessor(new TextMetaDataExtractingProcessor("//first-quote", "//second-quote", "//third-quote", "//size"));
tree = contentStoreService.findTree(context, DEFAULT_CACHING_OPTIONS, ROOT_FOLDER_PATH, 1, OnlyNonDescriptorsFilter.instance, extractorPipeline);
assertRootFolderTree(tree, 1, true, true);
// Sleep so that we get a different caching time in the next call if the caching is being done wrong.
Thread.sleep(100);
cachedTree = contentStoreService.getTree(context, DEFAULT_CACHING_OPTIONS, ROOT_FOLDER_PATH, 1, OnlyNonDescriptorsFilter.instance, extractorPipeline);
assertEquals(tree, cachedTree);
assertTreeCaching(tree, cachedTree);
tree = contentStoreService.findTree(context, DEFAULT_CACHING_OPTIONS, INVALID_PATH, 1, OnlyNonDescriptorsFilter.instance, extractorPipeline);
assertNull(tree);
try {
contentStoreService.getTree(context, DEFAULT_CACHING_OPTIONS, INVALID_PATH, 1, OnlyNonDescriptorsFilter.instance, extractorPipeline);
fail("Expected " + PathNotFoundException.class.getName());
} catch (PathNotFoundException e) {
}
}
Aggregations