Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @TestPropertySource(properties = {"spring.profiles.active=mysql", "spring.datasource.username=root", "spring.datasource.password=HASLO"})
- @Transactional
- @RunWith(SpringRunner.class)
- @SpringBootTest
- public class OptimisticLockingTest {
- @PersistenceContext
- private EntityManager entityManager;
- @Autowired
- private JdbcTemplate jdbc;
- @Autowired
- private CarService carService;
- @Autowired
- private CarDao carDao;
- @Test(expected = OptimisticLockException.class)
- public void testOptimisticLocking(){
- Long id = 2L;
- CarTo carUpdateSuccessful = carDao.findById(id);
- carUpdateSuccessful.setColor("purple");
- jdbc.update("update t_car set version = 100 where id = 2");
- carService.updateCar(carUpdateSuccessful);
- entityManager.flush();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement