CacheUtilTest.java 1.61 KB
Newer Older
Kim Gyeongeun committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
package jp.agentec.sinaburocast.common.util;

import junit.framework.TestSuite;
import net.sf.ehcache.Cache;
import net.sf.ehcache.Element;

import org.seasar.dao.unit.S2DaoTestCase;

public class CacheUtilTest extends S2DaoTestCase {
	public CacheUtilTest(String string) {
		super(string);
	}

	public static TestSuite suite() {
		TestSuite suite = new TestSuite("CacheUtilTest");
		suite.addTest(new CacheUtilTest("testGetCache"));
		return suite;
	}


	/**
	 * @throws java.lang.Exception
	 */
	@Override
	public void setUp() throws Exception {
		super.setUp();
        include("app.dicon");
	}

	/**
	 * @throws java.lang.Exception
	 */
	@Override
	public void tearDown() throws Exception {
		super.tearDown();
	}

	public void testGetCache() {
		Cache cache = jp.agentec.sinaburocast.common.util.CacheUtil.getCache();

		cache.put(new Element("aaa","bbb"));
		cache.put(new Element(123456, true));
		cache.put(new Element(3123456, false));


		System.out.println(cache.get("aaa").getValue());
		assertEquals("bbb", cache.get("aaa").getValue());
		assertEquals(true, cache.get(123456).getValue());
		assertEquals(false, cache.get(3123456).getValue());
		assertNull(cache.get("hoge"));

		cache = jp.agentec.sinaburocast.common.util.CacheUtil.getCache("contentExist");

		cache.put(new Element("aaa","bbb"));
		cache.put(new Element(123456, true));
		cache.put(new Element(3123456, false));


		System.out.println(cache.get("aaa").getValue());
		assertEquals("bbb", cache.get("aaa").getObjectValue());
		assertEquals(true, cache.get(123456).getValue());
		assertEquals(false, cache.get(3123456).getValue());
		assertNull(cache.get("hoge"));

	}
}