@Override public String getContentUrl() { return delegatee.getContentUrl(); }
@Override public String getContentUrl() { return this.cacheWriter.getContentUrl(); }
@Override public String getContentUrl() { return delegatee.getContentUrl(); }
@Override public String getContentUrl() { return this.cacheWriter.getContentUrl(); }
public String execute() throws Throwable { ContentWriter writer = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true); writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); writer.putContent("CONTENT FOR SUCCESS"); // We expect the URL to be there, but the original URL must be removed urlsToMiss.addAll(urlsToExist); urlsToExist.clear(); urlsToExist.add(writer.getContentUrl()); // Done return writer.getContentUrl(); } };
public void testTempWrite() throws Exception { // get a temporary writer ContentWriter writer1 = contentService.getTempWriter(); // and another ContentWriter writer2 = contentService.getTempWriter(); // check assertNotSame("Temp URLs must be different", writer1.getContentUrl(), writer2.getContentUrl()); }
/** * {@inheritDoc} * <p> * This implementation creates some content in the store and returns the new content URL. */ protected String getExistingContentUrl() { ContentWriter writer = getWriter(); writer.putContent("Content for getExistingContentUrl"); return writer.getContentUrl(); }
public String execute() throws Throwable { ContentWriter writer = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true); writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); writer.putContent("CONTENT FOR FAIL"); // This will have updated the metadata, so we can fail now urlsToMiss.add(writer.getContentUrl()); // Done throw new RuntimeException("FAIL"); } };
/** * {@inheritDoc} * <p> * This implementation creates some content in the store and returns the new content URL. */ protected String getExistingContentUrl() { ContentWriter writer = getWriter(); writer.putContent("Content for getExistingContentUrl"); return writer.getContentUrl(); }
public void testReadFromSecondaryStore() { // pick a secondary store and write some content to it ContentStore secondaryStore = secondaryStores.get(2); ContentWriter writer = secondaryStore.getWriter(ContentContext.NULL_CONTEXT); writer.putContent(SOME_CONTENT); String contentUrl = writer.getContentUrl(); checkForUrl(contentUrl, true); }
private ContentData getContentData() { ContentContext contentCtx = new ContentContext(null, null); String contentUrl = contentStore.getWriter(contentCtx).getContentUrl(); ContentData contentData = new ContentData( contentUrl, MimetypeMap.MIMETYPE_TEXT_PLAIN, 12335L, "UTF-8", Locale.FRENCH); return contentData; }
public void testAddContent() throws Exception { ContentWriter writer = getWriter(); writer.putContent(SOME_CONTENT); String contentUrl = writer.getContentUrl(); checkForUrl(contentUrl, true); }
private String writeSingleFileInMB(int sizeInMb) throws IOException { ContentWriter writer = store.getWriter(ContentContext.NULL_CONTEXT); File content = createFileOfSize(sizeInMb * 1024); writer.putContent(content); return writer.getContentUrl(); }
@Test public void writeToCacheWithContentContext() { // Write through the caching content store - cache during the process. final String proposedUrl = FileContentStore.createNewFileStoreUrl(); ContentWriter writer = store.getWriter(new ContentContext(null, proposedUrl)); final String content = makeContent(); writer.putContent(content); assertEquals("Writer should have correct URL", proposedUrl, writer.getContentUrl()); ContentReader reader = store.getReader(writer.getContentUrl()); assertEquals("Reader and writer should have same URLs", writer.getContentUrl(), reader.getContentUrl()); assertEquals("Reader should get correct content", content, reader.getContentString()); }
@Test public void canUseCachingContentStore() { // Write through the caching content store - cache during the process. ContentWriter writer = store.getWriter(ContentContext.NULL_CONTEXT); final String content = makeContent(); writer.putContent(content); ContentReader reader = store.getReader(writer.getContentUrl()); assertEquals("Reader and writer should have same URLs", writer.getContentUrl(), reader.getContentUrl()); assertEquals("Reader should get correct content", content, reader.getContentString()); }
@Before public void before() throws Exception { // create a store that uses a subdirectory of the temp directory File tempDir = TempFileProvider.getTempDir(); store = new FileContentStore(ctx, tempDir.getAbsolutePath() + File.separatorChar + getName()); // Put some content into it ContentWriter writer = store.getWriter(new ContentContext(null, null)); writer.putContent("Content for getExistingContentUrl"); this.contentUrl = writer.getContentUrl(); // disallow random access store.setReadOnly(true); }
@Test public void testGeneralUse() { for (int i = 0 ; i < 20; i++) { ContentContext contentContext = new ContentContext(null, null); ContentWriter writer = routingStore.getWriter(contentContext); String content = "This was generated by " + this.getClass().getName() + "#testGeneralUse number " + i; writer.putContent(content); // Check that it exists String contentUrl = writer.getContentUrl(); checkForContent(contentUrl, content); // Now go direct to the routing store and check that it is able to find the appropriate URLs ContentReader reader = routingStore.getReader(contentUrl); assertNotNull("Null reader returned", reader); assertTrue("Reader should be onto live content", reader.exists()); } }
public void testDelete() throws Exception { // write some content ContentWriter writer = getWriter(); writer.putContent(SOME_CONTENT); String contentUrl = writer.getContentUrl(); ContentReader reader = primaryStore.getReader(contentUrl); assertTrue("Content was not in the primary store", reader.exists()); assertEquals("The content was incorrect", SOME_CONTENT, reader.getContentString()); getStore().delete(contentUrl); checkForUrl(contentUrl, false); }
public void testGetRawReader() throws Exception { ContentReader reader = contentService.getRawReader("test://non-existence"); assertNotNull("A reader is expected with content URL referencing no content", reader); assertFalse("Reader should not have any content", reader.exists()); // Now write something ContentWriter writer = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, false); writer.putContent("ABC from " + getName()); // Try again String contentUrl = writer.getContentUrl(); reader = contentService.getRawReader(contentUrl); assertNotNull("Expected reader for live, raw content", reader); assertEquals("Content sizes don't match", writer.getSize(), reader.getSize()); }
public void testStoreWillReadFromCacheWhenAvailable() { final String content = "Content for " + getName() + " test."; // Write some content to the backing store. ContentWriter writer = backingStore.getWriter(ContentContext.NULL_CONTEXT); writer.putContent(content); final String contentUrl = writer.getContentUrl(); // Read content using the CachingContentStore - will cause content to be cached. String retrievedContent = store.getReader(contentUrl).getContentString(); assertEquals(content, retrievedContent); // Remove the original content from the backing store. backingStore.delete(contentUrl); assertFalse("Original content should have been deleted", backingStore.exists(contentUrl)); // The cached version is still available. String contentAfterDelete = store.getReader(contentUrl).getContentString(); assertEquals(content, contentAfterDelete); }