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"));

	}
}