atom feed6 messages in com.googlegroups.alfresco-technical-discussionRe: [alfresco-tech] Delete user does ...
FromSent OnAttachments
Mano SwertsDec 7, 2012 6:22 am 
Gabriele ColumbroDec 7, 2012 9:34 am 
Mano SwertsDec 11, 2012 1:23 am 
Mano SwertsDec 11, 2012 11:33 pm 
Mano SwertsJan 15, 2013 11:08 pm 
Gabriele ColumbroJan 17, 2013 2:41 am 
Subject:Re: [alfresco-tech] Delete user does not work consistently in Maven SDK tests
From:Mano Swerts ("
Date:Jan 15, 2013 11:08:36 pm

Hi all,

Does nobody have the same issue? Is there somebody looking into this?

Kind regards,

Hi Gabriele,

The problem occurs with the deletion of other nodes as well. So probably you are right that it has to do with the transaction in the teardown not being committed. Do you have any clue how the transactions are implemented in the SDK? We already tried to set the Spring @Transactional and @Rollback annotations, but without any success. We also tried to manually start and commit a transaction using the Alfresco TransactionService, but also without result.

Hi Gabriele,

The deletion fails silently. It could be a transactional issue, but we do no manage transactions manually. The @AfterClass is always called and the deletes are called as well. We do a check whether the person still exists after the delete and it returns false. So it should be deleted, but apparently when we run the build a second time they do not seem to be deleted. So it seems to be a transaction that has not been committed, but like I said before, we do not handle transactions ourselves.

What I noticed however, is that the teardown only fails in the last test of the build. The teardown for all tests run fine, except for the last one. I verified that this behaviour is consistent.

Kind regards,

On Friday, December 7, 2012 6:34:15 PM UTC+1, Gabriele Columbro wrote:


cc-ing the Maven Alfresco List as the question might be more appropriate there.

Do you get any exception when the deletion fail or it fails silently? Could it be somehow related to the transaction not being committed? Is the @AfterClass method always called?

Sorry for the quite simple questions, but I have no clue right now on why it shouldn't work.



On 7 December 2012 06:22, Mano Swerts <> wrote:

Hi all,

We are using the new Alfresco Maven SDK, but we are running into problems creating and removing test users for our tests.

Take the following example:

public class AlfrescoTest { protected static PersonService personService;

@BeforeClass public static void initAppContext() { ApplicationContextHelper.setUseLazyLoading(false); ApplicationContextHelper.setNoAutoStart(true);

applicationContext = ApplicationContextHelper.getApplicationContext(new String[] { "classpath:alfresco/application-context.xml" }); personService = (PersonService) applicationContext.getBean("PersonService"); AuthenticationUtil.setFullyAuthenticatedUser("admin"); personService.deletePerson("John"); // always works, but not the place to do it createUser("John"); } @Test public void aSimpleTest() { // ... } @AfterClass public static void teardown() { AuthenticationUtil.setFullyAuthenticatedUser("admin"); personService.deletePerson("John"); // mostly doesn't work } private static void createUser(String userName) { Map<QName, Serializable> properties = new HashMap<>(); properties.put(ContentModel.PROP_USERNAME, userName); personService.createPerson(properties); } }

As you can see in the code, we want to create some test users in the @BeforeClass of our test. This works fine. Then we want to delete these users at the end of the tests, so in the @AfterClass. This does not work reliably. Most of the time the users aren't deleted. When we delete them in the @BeforeClass it always works, but that's not the place we want to clear our users.

Does anybody have a clue why this isn't working?

Any help is greatly appreciated.