private void innerTestPutKeys(BlockDiskCacheAttributes attributes) { BlockDiskCache<String, String> blockDiskCache = new BlockDiskCache<String, String>( attributes ); BlockDiskKeyStore<String> keyStore = new BlockDiskKeyStore<String>( attributes, blockDiskCache ); // DO WORK int numElements = 100; for ( int i = 0; i < numElements; i++ ) { keyStore.put( String.valueOf( i ), new int[i] ); } // System.out.println( "testPutKeys " + keyStore ); // VERIFY assertEquals( "Wrong number of keys", numElements, keyStore.size() ); for ( int i = 0; i < numElements; i++ ) { int[] result = keyStore.get( String.valueOf( i ) ); assertEquals( "Wrong array returned.", i, result.length ); } }
public void testSaveLoadKeysSize() throws Exception { // SETUP BlockDiskCacheAttributes attributes = new BlockDiskCacheAttributes(); attributes.setCacheName( "testSaveLoadKeys" ); attributes.setDiskPath( rootDirName ); attributes.setMaxKeySize( 10000 ); attributes.setBlockSizeBytes( 2000 ); testSaveLoadKeysInner(attributes); }
public void testObjectLargerThanMaxSize() { BlockDiskCacheAttributes attributes = new BlockDiskCacheAttributes(); attributes.setCacheName("testObjectLargerThanMaxSize"); attributes.setDiskPath(rootDirName); attributes.setMaxKeySize(1000); attributes.setBlockSizeBytes(2000); attributes.setDiskLimitType(DiskLimitType.SIZE); @SuppressWarnings({ "unchecked", "rawtypes" }) BlockDiskKeyStore<String> keyStore = new BlockDiskKeyStore<String>(attributes, new BlockDiskCache(attributes)); keyStore.put("1", new int[1000]); keyStore.put("2", new int[1000]); assertNull(keyStore.get("1")); assertNotNull(keyStore.get("2")); } }
/** * Put a bunch of keys inthe key store and verify that they are present. * <p> * @throws Exception */ public void testPutKeys() throws Exception { // SETUP BlockDiskCacheAttributes attributes = new BlockDiskCacheAttributes(); attributes.setCacheName( "testPutKeys" ); attributes.setDiskPath( rootDirName ); attributes.setMaxKeySize( 1000 ); attributes.setBlockSizeBytes( 2000 ); innerTestPutKeys(attributes); }
public void testObjectLargerThanMaxSize() { BlockDiskCacheAttributes attributes = new BlockDiskCacheAttributes(); attributes.setCacheName( "testObjectLargerThanMaxSize" ); attributes.setDiskPath( rootDirName ); attributes.setMaxKeySize( 1000 ); attributes.setBlockSizeBytes( 2000 ); attributes.setDiskLimitType(DiskLimitType.SIZE); @SuppressWarnings({ "unchecked", "rawtypes" }) BlockDiskKeyStore<String> keyStore = new BlockDiskKeyStore<String>( attributes, new BlockDiskCache(attributes)); keyStore.put("1", new int[1000]); keyStore.put("2", new int[1000]); assertNull(keyStore.get("1")); assertNotNull(keyStore.get("2")); } }
public void testPutKeysSize() throws Exception { // SETUP BlockDiskCacheAttributes attributes = new BlockDiskCacheAttributes(); attributes.setCacheName( "testPutKeys" ); attributes.setDiskPath( rootDirName ); attributes.setMaxKeySize( 100000 ); attributes.setBlockSizeBytes( 1024 ); attributes.setDiskLimitType(DiskLimitType.SIZE); innerTestPutKeys(attributes); }
public void testSaveLoadKeysSize() throws Exception { // SETUP BlockDiskCacheAttributes attributes = new BlockDiskCacheAttributes(); attributes.setCacheName("testSaveLoadKeys"); attributes.setDiskPath(rootDirName); attributes.setMaxKeySize(10000); attributes.setBlockSizeBytes(2000); testSaveLoadKeysInner(attributes); }
public void testPutKeysSize() throws Exception { // SETUP BlockDiskCacheAttributes attributes = new BlockDiskCacheAttributes(); attributes.setCacheName("testPutKeys"); attributes.setDiskPath(rootDirName); attributes.setMaxKeySize(100000); attributes.setBlockSizeBytes(1024); attributes.setDiskLimitType(DiskLimitType.SIZE); innerTestPutKeys(attributes); }
private void innerTestPutKeys(BlockDiskCacheAttributes attributes) { BlockDiskCache<String, String> blockDiskCache = new BlockDiskCache<String, String>(attributes); BlockDiskKeyStore<String> keyStore = new BlockDiskKeyStore<String>(attributes, blockDiskCache); // DO WORK int numElements = 100; for (int i = 0; i < numElements; i++) { keyStore.put(String.valueOf(i), new int[i]); } // System.out.println( "testPutKeys " + keyStore ); // VERIFY assertEquals("Wrong number of keys", numElements, keyStore.size()); for (int i = 0; i < numElements; i++) { int[] result = keyStore.get(String.valueOf(i)); assertEquals("Wrong array returned.", i, result.length); } }
/** * Verify that we can load keys that we saved. Add a bunch. Save them. Clear the memory keyhash. * Load the keys. Verify. * <p> * @throws Exception */ public void testSaveLoadKeys() throws Exception { // SETUP BlockDiskCacheAttributes attributes = new BlockDiskCacheAttributes(); attributes.setCacheName( "testSaveLoadKeys" ); attributes.setDiskPath( rootDirName ); attributes.setMaxKeySize( 10000 ); attributes.setBlockSizeBytes( 2000 ); testSaveLoadKeysInner(attributes); }
/** * Put a bunch of keys in the key store and verify that they are present. * <p> * * @throws Exception */ public void testPutKeys() throws Exception { // SETUP BlockDiskCacheAttributes attributes = new BlockDiskCacheAttributes(); attributes.setCacheName("testPutKeys"); attributes.setDiskPath(rootDirName); attributes.setMaxKeySize(1000); attributes.setBlockSizeBytes(2000); innerTestPutKeys(attributes); }
assertEquals( "Wrong number of keys", numElements, keyStore.size() ); assertEquals( "Wrong number of keys after clearing memory", 0, keyStore.size() ); assertEquals( "Wrong number of keys after loading", numElements, keyStore.size() ); for ( int i = 0; i < numElements; i++ ) assertEquals( "Wrong array returned.", i, result.length );
/** * Verify that we can load keys that we saved. Add a bunch. Save them. Clear * the memory key hash. Load the keys. Verify. * <p> * * @throws Exception */ public void testSaveLoadKeys() throws Exception { // SETUP BlockDiskCacheAttributes attributes = new BlockDiskCacheAttributes(); attributes.setCacheName("testSaveLoadKeys"); attributes.setDiskPath(rootDirName); attributes.setMaxKeySize(10000); attributes.setBlockSizeBytes(2000); testSaveLoadKeysInner(attributes); }
assertEquals("Wrong number of keys", numElements, keyStore.size()); assertEquals("Wrong number of keys after clearing memory", 0, keyStore.size()); assertEquals("Wrong number of keys after loading", numElements, keyStore.size()); for (int i = 0; i < numElements; i++) assertEquals("Wrong array returned.", i, result.length);