0
我在Spring应用程序演员对象测试
public static String getCurrentUserStudentId() {
return ((LdapPerson) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getID();
}
这个工程上的应用程序运行,但是当我运行一个测试调用这个方法,它给
org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken cannot be cast to fi.utu.security.ldap.userdetails.LdapPerson
以下方法我不熟悉Spring Security给这些可能相关的文件,但问我。我希望有人能告诉我该怎么做。
我认为只在测试类内部进行修改会很好。你能给我一个设置测试策略的代码示例吗?我不确定你的意思。 – mjgirl
通过代码调用'setContext()'和'setStrategyName()' –