I am trying to run test cases related to my resource class in which I have added @Transactional annotation on class.
The resource class have regular create, update, delete methods for operations on oracle database, but my test cases are failing.
Code is:-
Resource class:-
@Transactional
public class TestToSAVE {
@ApiOperation(value = "Create new information store definition", notes = "Create a new information store definition and return with its unique id", response = InformationStoreDefinition.class)
@POST
@Timed
public void create() {
//code for create object and save into database
}
Test case code:-
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = {TestConfiguration.class})
@Transactional(propagation= Propagation.REQUIRES_NEW,rollbackFor = TransactionException.class)
public class TestToSAVETest {
//code in test class
}
Exception:
org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Transaction marked as rollbackOnly
Please suggest how can I resolve this exception.