Code example for AbstractTransactionalTestNGSpringContextTests

0
 
/** 
 * Created By xiaoliangl on 9/3/14. 
 */ 
@ContextConfiguration(locations = {"classpath:/META-INF/spring/*-context.xml"}) 
public class TestAppMgrDao extends AbstractTransactionalTestNGSpringContextTests { 
   @Autowired 
   IAppManagerDAO appManagerDAO; 
 
   @Test(expectedExceptions = DataIntegrityViolationException.class) 
   @Transactional(propagation = Propagation.NEVER) //simulate two concurrent TXs: one user is inserting a APPManager, which another is doing the same. 
   public void testPrimaryKeyViolation() { 
      AppManagerEntity appManagerAddDefault = new AppManagerEntity(); 
      appManagerAddDefault.setName("fooAppMgr"); 
      appManagerAddDefault.setDescription("fooAppMgr"); 
      appManagerAddDefault.setType("fooAppMgr"); 
      appManagerAddDefault.setUrl(""); 
      appManagerAddDefault.setUsername(""); 
      appManagerAddDefault.setPassword(""); 
      appManagerAddDefault.setSslCertificate("");