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

📄 securitycheckert.java

📁 动态实现基于角色的权限管理Acegi+hibernate
💻 JAVA
字号:
package sample.test.auth;

import java.util.Collection;
import java.util.Iterator;

import junit.framework.Assert;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import sample.auth.SecurityChecker;
import sample.mappings.function.Function;
import sample.mappings.role.Role;
import sample.test.AbstractTest;

public class SecurityCheckerT extends AbstractTest{


	
	//private SecurityChecker sc = context.getBean("");
	
	
	public void testGetSecureFunction(){
		Function function = ((SecurityChecker)context.getBean("securityChecker")).getSecureFunction("sample.service.DepartmentService.getAllDepartment");
		Assert.assertNotNull(function.getName());
	    Assert.assertNotNull(function.getRoles());
		
		
		   Iterator it = function.getRoles().iterator();
		   while(it.hasNext()){
			   
			   Role role = (Role)it.next();
			   
			   Assert.assertNotNull(role.getName());
			   
			   System.out.println(role.getName());
		   }
	}
	
	
	  public void testGetSecureObjectRoles(){
		  Function function = ((SecurityChecker)context.getBean("securityChecker")).getSecureFunction("sample.service.DepartmentService.getAllDepartment");
		   Collection c = ((SecurityChecker)context.getBean("securityChecker")).getSecureObjectRoles(function);
		   Assert.assertEquals(c.size(),5);
		   Iterator it = c.iterator();
		   while(it.hasNext()){
			   Role role = (Role)it.next();
			   Assert.assertNotNull(role.getName());
		   }
	   }

}

⌨️ 快捷键说明

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