⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mycachemanagertest.java

📁 OBPM是一个开源
💻 JAVA
字号:
package cn.myapps.util.cache;

import java.io.IOException;
import java.util.Iterator;

import cn.myapps.base.action.ParamsTable;
import cn.myapps.core.department.ejb.DepartmentProcessBean;

import junit.framework.TestCase;

public class MyCacheManagerTest extends TestCase {

	public static void main(String[] args) {
		junit.textui.TestRunner.run(MyCacheManagerTest.class);
	}

	protected void setUp() throws Exception {
		super.setUp();
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}

	/*
	 * Test method for 'cn.myapps.util.cache.MyCacheManager.getInstance()'
	 */
	public void testGetInstance() throws ClassNotFoundException,
			InstantiationException, IllegalAccessException, IOException {
		ICacheProvider provider = MyCacheManager.getProviderInstance();
		CacheConfig cconf = CacheConfig.getInstance();

		for (Iterator iter = cconf.getMethodCacheConfigs().values().iterator(); iter
				.hasNext();) {
			MethodCacheConfig mcc = (MethodCacheConfig) iter.next();
			assertNotNull(provider.getCache(mcc.getSignature()));
		}

	}

	public void testCache() throws ClassNotFoundException,
			InstantiationException, IllegalAccessException, IOException, InterruptedException {
		ICacheProvider provider = MyCacheManager.getProviderInstance();
		CacheConfig cconf = CacheConfig.getInstance();

		for (Iterator iter = cconf.getMethodCacheConfigs().values().iterator(); iter
				.hasNext();) {
			MethodCacheConfig mcc = (MethodCacheConfig) iter.next();
			IMyCache mycache = provider.getCache(mcc.getSignature());
			assertNotNull(mycache);

			mycache.put("hello", "hellovalue");
//			wait(5000);
			Object obj = ((IMyElement)mycache.get("hello")).getValue();
			assertNotNull(obj);
			assertEquals("hellovalue",obj);
		}

	}

	public void testBuildCacheKeyString() throws IOException,
			SecurityException, NoSuchMethodException {
		// System.out.println(""+MyCacheManager.buildCacheKeyString(DepartmentProcessBean.class.getMethod("doSimpleQuery",new
		// Class[]{ParamsTable.class})));
		assertEquals(
				"cn.myapps.core.department.ejb.DepartmentProcessBean.doSimpleQuery(cn.myapps.base.action.ParamsTable)",
				MyCacheManager.buildCacheKeyString(DepartmentProcessBean.class
						.getMethod("doSimpleQuery",
								new Class[] { ParamsTable.class })));
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -