/** * Setup a disk cache. Configure the disk usage pattern to not swap. Call spool. Verify that the * item is not put to disk. */ public void testSpoolNotAllowed() { // SETUP ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setCacheName(CACHE_NAME); cattr.setDiskUsagePattern( ICompositeCacheAttributes.DiskUsagePattern.UPDATE ); IElementAttributes attr = new ElementAttributes(); CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr ); MockAuxCache<String, String> mock = new MockAuxCache<String, String>(); mock.cacheType = CacheType.DISK_CACHE; @SuppressWarnings("unchecked") AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock }; cache.setAuxCaches( auxArray ); ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" ); // DO WORK cache.spoolToDisk( inputElement ); // VERIFY assertEquals( "Wrong number of calls to the disk cache update.", 0, mock.updateCount ); }
/** * Setup a disk cache. Configure the disk usage pattern to not swap. Call spool. Verify that the * item is not put to disk. */ public void testSpoolNotAllowed() { // SETUP ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setCacheName(CACHE_NAME); cattr.setDiskUsagePattern( ICompositeCacheAttributes.DiskUsagePattern.UPDATE ); IElementAttributes attr = new ElementAttributes(); CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr ); MockAuxCache<String, String> mock = new MockAuxCache<String, String>(); mock.cacheType = CacheType.DISK_CACHE; @SuppressWarnings("unchecked") AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock }; cache.setAuxCaches( auxArray ); ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" ); // DO WORK cache.spoolToDisk( inputElement ); // VERIFY assertEquals( "Wrong number of calls to the disk cache update.", 0, mock.updateCount ); }
/** * Setup a disk cache. Configure the disk usage pattern to SWAP. Call updateAuxiliaries. Verify * that the item is not put to disk. * <p> * This tests that the items are not put to disk on a normal put when the usage pattern is set * to SWAP. * <p> * @throws IOException */ public void testUpdateNotAllowed() throws IOException { // SETUP ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setCacheName(CACHE_NAME); cattr.setDiskUsagePattern( ICompositeCacheAttributes.DiskUsagePattern.SWAP ); IElementAttributes attr = new ElementAttributes(); CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr ); MockAuxCache<String, String> mock = new MockAuxCache<String, String>(); mock.cacheType = CacheType.DISK_CACHE; @SuppressWarnings("unchecked") AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock }; cache.setAuxCaches( auxArray ); ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" ); // DO WORK cache.updateAuxiliaries( inputElement, true ); // VERIFY assertEquals( "Wrong number of calls to the disk cache update.", 0, mock.updateCount ); }
/** * Setup a disk cache. Configure the disk usage pattern to swap. Call spool. Verify that the * item is put to disk. */ public void testSpoolAllowed() { // SETUP ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setCacheName(CACHE_NAME); cattr.setDiskUsagePattern( ICompositeCacheAttributes.DiskUsagePattern.SWAP ); IElementAttributes attr = new ElementAttributes(); CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr ); MockAuxCache<String, String> mock = new MockAuxCache<String, String>(); mock.cacheType = CacheType.DISK_CACHE; @SuppressWarnings("unchecked") AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock }; cache.setAuxCaches( auxArray ); ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" ); // DO WORK cache.spoolToDisk( inputElement ); // VERIFY assertEquals( "Wrong number of calls to the disk cache update.", 1, mock.updateCount ); assertEquals( "Wrong element updated.", inputElement, mock.lastUpdatedItem ); }
/** * Setup a disk cache. Configure the disk usage pattern to UPDATE. Call updateAuxiliaries. * Verify that the item is put to disk. * <p> * This tests that the items are put to disk on a normal put when the usage pattern is set * appropriately. * @throws IOException */ public void testUpdateAllowed() throws IOException { // SETUP ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setCacheName(CACHE_NAME); cattr.setDiskUsagePattern( ICompositeCacheAttributes.DiskUsagePattern.UPDATE ); IElementAttributes attr = new ElementAttributes(); CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr ); MockAuxCache<String, String> mock = new MockAuxCache<String, String>(); mock.cacheType = CacheType.DISK_CACHE; @SuppressWarnings("unchecked") AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock }; cache.setAuxCaches( auxArray ); ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" ); // DO WORK cache.updateAuxiliaries( inputElement, true ); // VERIFY assertEquals( "Wrong number of calls to the disk cache update.", 1, mock.updateCount ); assertEquals( "Wrong element updated.", inputElement, mock.lastUpdatedItem ); }
/** * Setup a disk cache. Configure the disk usage pattern to SWAP. Call updateAuxiliaries. Verify * that the item is not put to disk. * <p> * This tests that the items are not put to disk on a normal put when the usage pattern is set * to SWAP. * <p> * @throws IOException */ public void testUpdateNotAllowed() throws IOException { // SETUP ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setCacheName(CACHE_NAME); cattr.setDiskUsagePattern( ICompositeCacheAttributes.DiskUsagePattern.SWAP ); IElementAttributes attr = new ElementAttributes(); CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr ); MockAuxCache<String, String> mock = new MockAuxCache<String, String>(); mock.cacheType = CacheType.DISK_CACHE; @SuppressWarnings("unchecked") AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock }; cache.setAuxCaches( auxArray ); ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" ); // DO WORK cache.updateAuxiliaries( inputElement, true ); // VERIFY assertEquals( "Wrong number of calls to the disk cache update.", 0, mock.updateCount ); }
/** * Setup a disk cache. Configure the disk usage pattern to UPDATE. Call updateAuxiliaries with * local only set to false. Verify that the item is put to disk. * <p> * This tests that the items are put to disk on a normal put when the usage pattern is set * appropriately. The local setting should have no impact on whether the item goes to disk. * <p> * @throws IOException */ public void testUpdateAllowed_localFalse() throws IOException { // SETUP ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setCacheName(CACHE_NAME); cattr.setDiskUsagePattern( ICompositeCacheAttributes.DiskUsagePattern.UPDATE ); IElementAttributes attr = new ElementAttributes(); CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr ); MockAuxCache<String, String> mock = new MockAuxCache<String, String>(); mock.cacheType = CacheType.DISK_CACHE; @SuppressWarnings("unchecked") AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock }; cache.setAuxCaches( auxArray ); ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" ); // DO WORK cache.updateAuxiliaries( inputElement, false ); // VERIFY assertEquals( "Wrong number of calls to the disk cache update.", 1, mock.updateCount ); assertEquals( "Wrong element updated.", inputElement, mock.lastUpdatedItem ); }
/** * Setup a disk cache. Configure the disk usage pattern to swap. Call spool. Verify that the * item is put to disk. */ public void testSpoolAllowed() { // SETUP ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setCacheName(CACHE_NAME); cattr.setDiskUsagePattern( ICompositeCacheAttributes.DiskUsagePattern.SWAP ); IElementAttributes attr = new ElementAttributes(); CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr ); MockAuxCache<String, String> mock = new MockAuxCache<String, String>(); mock.cacheType = CacheType.DISK_CACHE; @SuppressWarnings("unchecked") AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock }; cache.setAuxCaches( auxArray ); ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" ); // DO WORK cache.spoolToDisk( inputElement ); // VERIFY assertEquals( "Wrong number of calls to the disk cache update.", 1, mock.updateCount ); assertEquals( "Wrong element updated.", inputElement, mock.lastUpdatedItem ); }
/** * Setup a disk cache. Configure the disk usage pattern to UPDATE. Call updateAuxiliaries with * local only set to false. Verify that the item is put to disk. * <p> * This tests that the items are put to disk on a normal put when the usage pattern is set * appropriately. The local setting should have no impact on whether the item goes to disk. * <p> * @throws IOException */ public void testUpdateAllowed_localFalse() throws IOException { // SETUP ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setCacheName(CACHE_NAME); cattr.setDiskUsagePattern( ICompositeCacheAttributes.DiskUsagePattern.UPDATE ); IElementAttributes attr = new ElementAttributes(); CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr ); MockAuxCache<String, String> mock = new MockAuxCache<String, String>(); mock.cacheType = CacheType.DISK_CACHE; @SuppressWarnings("unchecked") AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock }; cache.setAuxCaches( auxArray ); ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" ); // DO WORK cache.updateAuxiliaries( inputElement, false ); // VERIFY assertEquals( "Wrong number of calls to the disk cache update.", 1, mock.updateCount ); assertEquals( "Wrong element updated.", inputElement, mock.lastUpdatedItem ); }
/** * Setup a disk cache. Configure the disk usage pattern to UPDATE. Call updateAuxiliaries. * Verify that the item is put to disk. * <p> * This tests that the items are put to disk on a normal put when the usage pattern is set * appropriately. * @throws IOException */ public void testUpdateAllowed() throws IOException { // SETUP ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setCacheName(CACHE_NAME); cattr.setDiskUsagePattern( ICompositeCacheAttributes.DiskUsagePattern.UPDATE ); IElementAttributes attr = new ElementAttributes(); CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr ); MockAuxCache<String, String> mock = new MockAuxCache<String, String>(); mock.cacheType = CacheType.DISK_CACHE; @SuppressWarnings("unchecked") AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock }; cache.setAuxCaches( auxArray ); ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" ); // DO WORK cache.updateAuxiliaries( inputElement, true ); // VERIFY assertEquals( "Wrong number of calls to the disk cache update.", 1, mock.updateCount ); assertEquals( "Wrong element updated.", inputElement, mock.lastUpdatedItem ); }
cattr.setDiskUsagePattern( ICompositeCacheAttributes.DiskUsagePattern.UPDATE );
cattr.setDiskUsagePattern( ICompositeCacheAttributes.DiskUsagePattern.UPDATE );