Package org.activiti.spring.impl.test

Source Code of org.activiti.spring.impl.test.CleanTestExecutionListener

package org.activiti.spring.impl.test;

import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.springframework.test.context.TestContext;
import org.springframework.test.context.support.AbstractTestExecutionListener;

/**
* Removes all deployments at the end of a complete test class.
* <p>
* Use this as follows in a Spring test:
*
* @author jbarrez
* @RunWith(SpringJUnit4ClassRunner.class)
* @TestExecutionListeners(CleanTestExecutionListener.class)
* @ContextConfiguration("...")
*/
public class CleanTestExecutionListener extends AbstractTestExecutionListener {

    @Override
    public void afterTestClass(TestContext testContext) throws Exception {
        RepositoryService repositoryService = testContext.getApplicationContext().getBean(RepositoryService.class);
        for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
            repositoryService.deleteDeployment(deployment.getId(), true);
        }
    }

}
TOP

Related Classes of org.activiti.spring.impl.test.CleanTestExecutionListener

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.