0

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.

sstan
  • 35,425
  • 6
  • 48
  • 66
santosh
  • 435
  • 1
  • 7
  • 24
  • this question might help you http://stackoverflow.com/questions/19302196/transaction-marked-as-rollback-only-how-do-i-find-the-cause – Mohamed Nabli Jun 17 '16 at 13:49
  • I tried @Transactional(noRollbackFor = Exception.class) in test class but still getting exception. – santosh Jun 17 '16 at 13:53

0 Answers0