public void testPerformExecute() throws Exception { UserEditSetupAction action = new UserEditSetupAction(); ActionHelper sah = new ActionHelper(); sah.setUpAction(action); sah.getRequest().setRequestURL("foo"); User user = sah.getUser(); user.setTitle("Test title"); // Lets add some roles Iterator it = UserFactory.IMPLIEDROLES.iterator(); user.addPermanentRole(RoleFactory.ORG_ADMIN); while (it.hasNext()) { Role cr = (Role) it.next(); user.getOrg().addRole(cr); user.addPermanentRole(cr); } setupExpectations(sah.getForm(), sah.getUser()); // Below we test to make sure that some of // the strings in the form are localized TestUtils.enableLocalizationDebugMode(); try { sah.executeAction(); // verify the dyna form got the right values we expected. sah.getForm().verify(); assertEquals(sah.getUser().getLastLoggedIn(), sah.getRequest().getAttribute("lastLoggedIn")); // Verify some more intensive stuff assertNotNull(sah.getRequest().getAttribute("adminRoles")); assertNotNull(sah.getRequest().getAttribute("regularRoles")); List<UserRoleStatusBean> regularRoles = (List<UserRoleStatusBean>) sah.getRequest().getAttribute("regularRoles"); assertEquals(5, regularRoles.size()); UserRoleStatusBean lv = regularRoles.get(0); assertTrue(TestUtils.isLocalized(lv.getName())); assertEquals(true, lv.isDisabled()); assertNotNull(sah.getRequest().getAttribute("disabledRoles")); assertTrue(sah.getRequest().getAttribute("user") instanceof User); // If we have pam setup where we're testing, make sure displaypam was set String pamAuthService = Config.get().getString(ConfigDefaults.WEB_PAM_AUTH_SERVICE); if (pamAuthService != null && pamAuthService.trim().length() > 0) { assertNotNull(sah.getRequest().getAttribute("displaypam")); } } finally { TestUtils.disableLocalizationDebugMode(); } }