Merged V3.4-BUG-FIX to HEAD

28650: Merged DEV/TEMPORARY to V3.4-BUG-FIX
      28637: ALF-5601: WCM Reviewer should be able to modify 'Launch Date' of the review item.
         Set "wcmwf:launchDate" to read-only on "submitpendingTask".
   28697: Fix for ALF-2711 - Fix to handle incorrect (negative size!) content length headers sent by Adobe Flash when uploading files over 2GB.
   28702: Merged DEV to V3.4-BUG-FIX
      28693: ALF-9314: Unable to add to multi-valued properties via AVM Console
             The node property value of Collection type must be set within square braces
             as a comma separated values without spaces. E.g. [aaa,bbb,ccc] 
   28718: Merged PATCHES/V3.4.2 to V3.4-BUG-FIX
      28569: ALF-9253 / ALF-9166: 'A valid SecureContext was not provided in the RequestContext' exception on startup following upgrade to 3.4.1
      28618: ALF-8385 / ALF-9364: Merged DEV/TEMPORARY to PATCHES/V3.4.2
         28565: ALF-5887 Addition of RenameUser command line toolContext
            - PersonServiceImpl should not disable normal behaviour when handling duplicate Person NodeRefs as the userAuthorityCache does not get updated correctly
            - Tool (base class for Import, Export and RenameUser command line tools) should not automatically login if setLogin(false) has been called. 
   28719: Merged V3.4 to V3.4-BUG-FIX
      28648: ALF-9103: Remove obsolete (and mis-spelled) use-old-dm-alcs-context.xml.sample
      28701: Corrected library for - Fix for ALF-7860 - Regression: Close button doesn't work in Node Browser


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28721 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2011-06-30 11:36:51 +00:00
parent 404b096c44
commit eddc7efe0c
10 changed files with 915 additions and 94 deletions

View File

@@ -58,6 +58,7 @@ import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.cmr.security.PersonService.PersonInfo;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.tools.RenameUser;
import org.alfresco.util.ApplicationContextHelper;
import org.alfresco.util.EqualsHelper;
import org.alfresco.util.GUID;
@@ -79,11 +80,6 @@ public class PersonTest extends TestCase
private MutableAuthenticationDao authenticationDAO;
private UserTransaction testTX;
public PersonTest()
{
super();
}
public void setUp() throws Exception
{
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
@@ -1388,4 +1384,79 @@ public class PersonTest extends TestCase
personService.createPerson(properties);
personService.notifyPerson(userName, "abc");
}
public void testRenameUser() throws Exception
{
// Note: RenameUserTest contains unit tests.
// End the Spring-managed txn
testTX.commit();
final String username = AuthenticationUtil.getAdminUserName();
final String oldUsername = GUID.generate();
final String newUsername = oldUsername+GUID.generate();
// Create a person
final NodeRef person = transactionService.getRetryingTransactionHelper().doInTransaction(
new RetryingTransactionCallback<NodeRef>()
{
public NodeRef execute() throws Throwable
{
// Tidy up failed runs
if (personService.personExists(oldUsername))
{
personService.deletePerson(oldUsername);
}
if (personService.personExists(newUsername))
{
personService.deletePerson(newUsername);
}
// Generate a person node
Map<QName, Serializable> properties = createDefaultProperties(oldUsername, "firstName", "lastName", "email@orgId", "orgId", null);
NodeRef person = personService.createPerson(properties);
// Check the person exists
assertEquals(oldUsername, nodeService.getProperty(person, ContentModel.PROP_USERNAME));
assertEquals(person, personService.getPerson(oldUsername));
assertFalse("new user should not exist yet", personService.personExists(newUsername));
return person;
}
}, false, true);
// Run the RenameUser cmd line tool
// - override exit so we don't and assert normal exit
// - Don't ask for a password as we may not know it in a test
// - call start rather than main to get correct instance
RenameUser renameUser = new RenameUser()
{
@Override
protected void exit(int status)
{
assertEquals("Tool exit status should be normal", 0, status);
}
};
renameUser.setLogin(false);
renameUser.start(new String[] {"-user", username, oldUsername, newUsername});
// Check person has been renamed and the delete it.
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>()
{
public Void execute() throws Throwable
{
String newUserName = (String) nodeService.getProperty(person, ContentModel.PROP_USERNAME);
assertEquals(newUsername, newUserName);
// Check the person exists
assertEquals(newUsername, nodeService.getProperty(person, ContentModel.PROP_USERNAME));
assertEquals(person, personService.getPerson(newUsername));
assertFalse("old user should no longer exist", personService.personExists(oldUsername));
// Get rid of the test person
personService.deletePerson(newUsername);
return null;
}
}, false, true);
}
}