其实我刚开始写一个测试用例...请帮我写一个测试用例代码..
@RequestMapping(value = { "/", "/home" }, method = RequestMethod.GET)
public String homePage(Model uiModel) {
logger.info("Home Page!");
uiModel.addAttribute("greeting", getPrincipal().toLowerCase());
return "home";
}
private String getPrincipal(){
String userName = null;
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
if (principal instanceof UserDetails) {
userName = ((UserDetails)principal).getUsername();
} else {
userName = principal.toString();
}
return userName;
}