Package org.castor.cache

Examples of org.castor.cache.Cache


        Logger logger = Logger.getLogger(OsCacheFactory.class);
        Level level = logger.getLevel();

        OsCacheFactory cf = new OsCacheFactory();
        try {
            Cache c = cf.getCache(DistributedOsCacheMock.class.getName(), null);
            assertTrue(c instanceof OsCache);
        } catch (CacheAcquireException ex) {
            fail("Failed to get instance of OsCache from factroy");
        }
View Full Code Here


    }

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

    }

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

    }

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

    public void testBasics() throws CacheAcquireException {
        assertEquals("count-limited", CountLimited.TYPE);
        assertEquals("capacity", CountLimited.PARAM_CAPACITY);
        assertEquals(30, CountLimited.DEFAULT_CAPACITY);

        Cache cache = new CountLimited();
        assertTrue(cache instanceof CountLimited);

        assertEquals("count-limited", cache.getType());
        assertEquals(30, ((CountLimited) cache).getCapacity());
        assertEquals(Cache.DEFAULT_NAME, cache.getName());
       
        Properties params = new Properties();
        params.put(Cache.PARAM_NAME, "dummy1");
        cache.initialize(params);
        assertEquals(30, ((CountLimited) cache).getCapacity());
        assertEquals("dummy1", cache.getName());
       
        params.clear();
        params.put(Cache.PARAM_NAME, "dummy2");
        params.put(CountLimited.PARAM_CAPACITY, "-10");
        cache.initialize(params);
        assertEquals(30, ((CountLimited) cache).getCapacity());
        assertEquals("dummy2", cache.getName());
       
        params.clear();
        params.put(Cache.PARAM_NAME, "dummy3");
        params.put(CountLimited.PARAM_CAPACITY, "0");
        cache.initialize(params);
        assertEquals(30, ((CountLimited) cache).getCapacity());
        assertEquals("dummy3", cache.getName());
       
        params.clear();
        params.put(Cache.PARAM_NAME, "dummy4");
        params.put(CountLimited.PARAM_CAPACITY, "10");
        cache.initialize(params);
        assertEquals(10, ((CountLimited) cache).getCapacity());
        assertEquals("dummy4", cache.getName());
       
        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() {
        Cache cache = new CountLimited();

        try {
            Properties params = new Properties();
            params.put(Cache.PARAM_NAME, "dummy");
            params.put(CountLimited.PARAM_CAPACITY, new Integer(10));
            cache.initialize(params);
        } catch (CacheAcquireException ex) {
            fail("Unexpected CacheAcquireException at initialization.");
        }
       
        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() {
        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() {
        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() {
        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() {
        Cache cache = initialize();

        assertEquals(3, cache.size());
        cache.clear();
        assertEquals(0, cache.size());
    }
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.