Package org.castor.cache

Examples of org.castor.cache.Cache


        assertTrue(set.contains("second key"));
        assertTrue(set.contains("third key"));
    }

    public void testValues() throws CacheAcquireException {
        Cache cache = initialize();

        Collection col = cache.values();
       
        assertEquals(3, col.size());
        assertTrue(col.contains("first value"));
        assertTrue(col.contains("second value"));
        assertTrue(col.contains("third value"));
View Full Code Here


        assertTrue(col.contains("second value"));
        assertTrue(col.contains("third value"));
    }

    public void testEntrySet() throws CacheAcquireException {
        Cache cache = initialize();

        Set set = cache.entrySet();
       
        assertEquals(3, set.size());
       
        Object[] objs = set.toArray();
        HashMap map = new HashMap();
View Full Code Here

    }

    public void testGetCache() {
        CacheFactory cf = new NoCacheFactory();
        try {
            Cache c = cf.getCache(null);
            assertTrue(c instanceof NoCache);
        } catch (CacheAcquireException ex) {
            fail("Failed to get instance of NoCache from factroy");
        }
    }
View Full Code Here

        assertEquals("ttl", AbstractHashbelt.PARAM_TTL);
        assertEquals(60, AbstractHashbelt.DEFAULT_TTL);
        assertEquals("monitor", AbstractHashbelt.PARAM_MONITOR);
        assertEquals(0, AbstractHashbelt.DEFAULT_MONITOR);

        Cache cache = new LRUHashbelt();
        assertTrue(cache instanceof LRUHashbelt);
        assertEquals("lru", cache.getType());

        Properties params = new Properties();
        params.put(Cache.PARAM_NAME, "dummy1");
        try {
            cache.initialize(params);
        } catch (CacheAcquireException ex) {
            fail("Failed to initialize LRUHashbelt instance");
        }

        assertFalse(cache.containsKey("first key"));
        assertFalse(cache.containsKey("second key"));

        assertNull(cache.put("first key", "first value"));

        assertTrue(cache.containsKey("first key"));
        assertFalse(cache.containsKey("second key"));

        assertNull(cache.put("second key", "second value"));

        assertTrue(cache.containsKey("first key"));
        assertTrue(cache.containsKey("second key"));
    }
View Full Code Here

        assertTrue(cache.containsKey("first key"));
        assertTrue(cache.containsKey("second key"));
    }

    private Cache initialize() throws CacheAcquireException {
        Cache cache = new LRUHashbelt();
        Properties params = new Properties();
        params.put(Cache.PARAM_NAME, "dummy1");
        cache.initialize(params);

        assertNull(cache.put("first key", "first value"));
        assertNull(cache.put("second key", "second value"));
        assertNull(cache.put("third key", "third value"));
       
        return cache;
    }
View Full Code Here

       
        return cache;
    }
   
    public void testContainsKey() throws CacheAcquireException {
        Cache cache = initialize();

        assertTrue(cache.containsKey("first key"));
        assertTrue(cache.containsKey("second key"));
        assertTrue(cache.containsKey("third key"));
        assertFalse(cache.containsKey("fourth key"));
        assertFalse(cache.containsKey("fifth key"));
    }
View Full Code Here

        assertFalse(cache.containsKey("fourth key"));
        assertFalse(cache.containsKey("fifth key"));
    }

    public void testContainsValue() throws CacheAcquireException {
        Cache cache = initialize();

        assertTrue(cache.containsValue("first value"));
        assertTrue(cache.containsValue("second value"));
        assertTrue(cache.containsValue("third value"));
        assertFalse(cache.containsValue("fourth value"));
        assertFalse(cache.containsValue("fifth value"));
    }
View Full Code Here

        assertFalse(cache.containsValue("fourth value"));
        assertFalse(cache.containsValue("fifth value"));
    }

    public void testClear() throws CacheAcquireException {
        Cache cache = initialize();

        cache.clear();

        assertFalse(cache.containsKey("first key"));
        assertFalse(cache.containsKey("second key"));
        assertFalse(cache.containsKey("third key"));
        assertFalse(cache.containsKey("fourth key"));
        assertFalse(cache.containsKey("fifth key"));
    }
View Full Code Here

        assertFalse(cache.containsKey("fourth key"));
        assertFalse(cache.containsKey("fifth key"));
    }

    public void testSize() throws CacheAcquireException {
        Cache cache = initialize();

        assertEquals(3, cache.size());
        cache.clear();
        assertEquals(0, cache.size());
    }
View Full Code Here

        cache.clear();
        assertEquals(0, cache.size());
    }

    public void testIsEmpty() throws CacheAcquireException {
        Cache cache = initialize();

        assertFalse(cache.isEmpty());
        cache.clear();
        assertTrue(cache.isEmpty());
    }
View Full Code Here

TOP

Related Classes of org.castor.cache.Cache

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.