Package org.castor.cache

Examples of org.castor.cache.Cache


    }

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


    }

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

        assertNull(cache.get("fourth key"));
        assertNull(cache.get("fifth key"));
    }

    public void testPut() {
        Cache cache = initialize();

        assertEquals("third value", cache.put("third key", "alternate third value"));
        assertNull(cache.put("fourth key", "forth value"));

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

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

    public void testRemove() {
        Cache cache = initialize();

        assertEquals("third value", cache.remove("third key"));

        assertTrue(cache.containsKey("first key"));
        assertTrue(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 testPutAll() {
        Cache cache = initialize();

        HashMap map = new HashMap();
        map.put("fourth key", "forth value");
        map.put("fifth key", "fifth value");
       
        cache.putAll(map);
       
        assertTrue(cache.containsKey("first key"));
        assertTrue(cache.containsKey("second key"));
        assertTrue(cache.containsKey("third key"));
        assertTrue(cache.containsKey("fourth key"));
        assertTrue(cache.containsKey("fifth key"));
    }
View Full Code Here

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

    public void testKeySet() {
        Cache cache = initialize();

        Set set = cache.keySet();
       
        assertEquals(3, set.size());
        assertTrue(set.contains("first key"));
        assertTrue(set.contains("second key"));
        assertTrue(set.contains("third key"));
View Full Code Here

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

    public void testValues() {
        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() {
        Cache cache = initialize();

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

        assertTrue(map.containsKey("third key"));
        assertEquals("third value", map.get("third key"));
    }
   
    public void testExpire() {
        Cache cache = new CountLimited();

        try {
            Properties params = new Properties();
            params.put(Cache.PARAM_NAME, "dummy");
            params.put(CountLimited.PARAM_CAPACITY, "3");
            cache.initialize(params);
        } catch (CacheAcquireException ex) {
            fail("Unexpected CacheAcquireException at initialization.");
        }
       
        assertEquals(0, cache.size());

        assertNull(cache.put("a", "#a"));
        assertEquals(1, cache.size());
        assertTrue(cache.containsKey("a"));
       
        assertNull(cache.put("b", "#b"));
        assertEquals(2, cache.size());
        assertTrue(cache.containsKey("a"));
        assertTrue(cache.containsKey("b"));
       
        assertNull(cache.put("c", "#c"));
        assertEquals(3, cache.size());
        assertTrue(cache.containsKey("a"));
        assertTrue(cache.containsKey("b"));
        assertTrue(cache.containsKey("c"));
       
        assertNull(cache.put("d", "#d"));
        assertEquals(3, cache.size());
        assertTrue(cache.containsKey("b"));
        assertTrue(cache.containsKey("c"));
        assertTrue(cache.containsKey("d"));
       
        assertEquals("#c", cache.put("c", "#c1"));
        assertEquals(3, cache.size());
        assertTrue(cache.containsKey("b"));
        assertTrue(cache.containsKey("c"));
        assertTrue(cache.containsKey("d"));
       
        assertEquals("#c1", cache.put("c", "#c2"));
        assertEquals(3, cache.size());
        assertTrue(cache.containsKey("b"));
        assertTrue(cache.containsKey("c"));
        assertTrue(cache.containsKey("d"));
       
        assertEquals("#c2", cache.put("c", "#c3"));
        assertEquals(3, cache.size());
        assertTrue(cache.containsKey("b"));
        assertTrue(cache.containsKey("c"));
        assertTrue(cache.containsKey("d"));
       
        assertEquals("#b", cache.put("b", "#b"));
        assertEquals(3, cache.size());
        assertTrue(cache.containsKey("b"));
        assertTrue(cache.containsKey("c"));
        assertTrue(cache.containsKey("d"));
       
        assertNull(cache.put("e", "#e"));
        assertEquals(3, cache.size());
        assertTrue(cache.containsKey("c"));
        assertTrue(cache.containsKey("d"));
        assertTrue(cache.containsKey("e"));

        assertNull(cache.put("f", "#f"));
        assertEquals(3, cache.size());
        assertTrue(cache.containsKey("d"));
        assertTrue(cache.containsKey("e"));
        assertTrue(cache.containsKey("f"));

        assertEquals("#e", cache.remove("e"));
        assertEquals(2, cache.size());
        assertTrue(cache.containsKey("d"));
        assertTrue(cache.containsKey("f"));

        assertNull(cache.put("g", "#g"));
        assertEquals(2, cache.size());
        assertTrue(cache.containsKey("f"));
        assertTrue(cache.containsKey("g"));

        assertEquals("#f", cache.remove("f"));
        assertEquals(1, cache.size());
        assertTrue(cache.containsKey("g"));

        assertNull(cache.remove("b"));
        assertEquals(1, cache.size());
        assertTrue(cache.containsKey("g"));

        assertEquals("#g", cache.remove("g"));
        assertEquals(0, cache.size());

        assertNull(cache.remove("x"));
        assertEquals(0, cache.size());

        assertNull(cache.put("a", "#a"));
        assertEquals(1, cache.size());
        assertTrue(cache.containsKey("a"));
       
        assertNull(cache.put("b", "#b"));
        assertEquals(2, cache.size());
        assertTrue(cache.containsKey("a"));
        assertTrue(cache.containsKey("b"));
       
        assertNull(cache.put("c", "#c"));
        assertEquals(3, cache.size());
        assertTrue(cache.containsKey("a"));
        assertTrue(cache.containsKey("b"));
        assertTrue(cache.containsKey("c"));
       
        assertNull(cache.put("d", "#d"));
        assertEquals(3, cache.size());
        assertTrue(cache.containsKey("b"));
        assertTrue(cache.containsKey("c"));
        assertTrue(cache.containsKey("d"));
    }
View Full Code Here

        assertEquals("com.opensymphony.oscache.base.NeedsRefreshException",
                     OsCache.NEEDS_REFRESH_EXCEPTION);
    }

    public void testConstructor() {
        Cache c = new OsCache(null);
        assertTrue(c instanceof OsCache);
    }
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.