private void fireChannelClosed() { if (listeners.size() == 0) { // nothing to do return; } for (ContentStreamListener listener : listeners) { listener.contentStreamClosed(); } // done if (logger.isDebugEnabled()) { logger.debug("" + listeners.size() + " content listeners called: close"); } } }
private void fireChannelClosed() { if (listeners.size() == 0) { // nothing to do return; } for (ContentStreamListener listener : listeners) { listener.contentStreamClosed(); } // done if (logger.isDebugEnabled()) { logger.debug("" + listeners.size() + " content listeners called: close"); } } }
/** * Helper method to notify stream listeners */ private void fireChannelClosed() { if (listeners.size() == 0) { // nothing to do return; } for (ContentStreamListener listener : listeners) { listener.contentStreamClosed(); } // done if (logger.isDebugEnabled()) { logger.debug("" + listeners.size() + " content listeners called: close"); } }
/** * Helper method to notify stream listeners */ private void fireChannelClosed() { if (listeners.size() == 0) { // nothing to do return; } for (ContentStreamListener listener : listeners) { listener.contentStreamClosed(); } // done if (logger.isDebugEnabled()) { logger.debug("" + listeners.size() + " content listeners called: close"); } }
@Test(expected=RuntimeException.class) // Check that exceptions raised by the backing store's putContent(ContentReader) // aren't swallowed and can therefore cause the transaction to fail. public void exceptionRaisedWhenCopyingTempToBackingStoreIsPropogatedCorrectly() throws ContentIOException, IOException { cachingStore = new CachingContentStore(backingStore, cache, true); ContentContext ctx = ContentContext.NULL_CONTEXT; ContentWriter bsWriter = mock(ContentWriter.class); when(backingStore.getWriter(ctx)).thenReturn(bsWriter); when(bsWriter.getContentUrl()).thenReturn("url"); ContentWriter cacheWriter = mock(ContentWriter.class); when(cache.getWriter("url")).thenReturn(cacheWriter); ContentReader readerFromCacheWriter = mock(ContentReader.class); when(cacheWriter.getReader()).thenReturn(readerFromCacheWriter); doThrow(new RuntimeException()).when(bsWriter).putContent(any(ContentReader.class)); cachingStore.getWriter(ctx); // Get the stream listener and trigger it ArgumentCaptor<ContentStreamListener> arg = ArgumentCaptor.forClass(ContentStreamListener.class); verify(cacheWriter).addListener(arg.capture()); // Simulate a stream close arg.getValue().contentStreamClosed(); }
@Test public void encodingAttrsCopiedToBackingStoreWriter() { cachingStore = new CachingContentStore(backingStore, cache, true); ContentContext ctx = ContentContext.NULL_CONTEXT; ContentWriter bsWriter = mock(ContentWriter.class); when(backingStore.getWriter(ctx)).thenReturn(bsWriter); when(bsWriter.getContentUrl()).thenReturn("url"); ContentWriter cacheWriter = mock(ContentWriter.class); when(cache.getWriter("url")).thenReturn(cacheWriter); ContentReader readerFromCacheWriter = mock(ContentReader.class); when(cacheWriter.getReader()).thenReturn(readerFromCacheWriter); when(cacheWriter.getEncoding()).thenReturn("UTF-8"); when(cacheWriter.getLocale()).thenReturn(Locale.UK); when(cacheWriter.getMimetype()).thenReturn("not/real/mimetype"); cachingStore.getWriter(ctx); // Get the stream listener and trigger it ArgumentCaptor<ContentStreamListener> arg = ArgumentCaptor.forClass(ContentStreamListener.class); verify(cacheWriter).addListener(arg.capture()); // Simulate a stream close arg.getValue().contentStreamClosed(); verify(bsWriter).setEncoding("UTF-8"); verify(bsWriter).setLocale(Locale.UK); verify(bsWriter).setMimetype("not/real/mimetype"); }
verify(cacheWriter).addListener(arg.capture()); arg.getValue().contentStreamClosed();
arg.getValue().contentStreamClosed();