Question

I am a newbie to webservices and I was thinking of using savepoint mechanism in the test automation using webServices. Below is a code snippet

Connection con = 
    DriverManager.getConnection("jdbc:derby://localhost:1527/testDb", 
                                "name","pass");
con.setAutoCommit(false);
Savepoint spt1 = con.setSavepoint("svpt1");
WebService.Post() method for various CRUD operations.....
con.rollback(spt1);
con.commit();

The operations in between setting the savepoint and rolling back to it are various CRUD operations using webServices, so that when the savepoint is rolled back, the dirty data created during the automation shall be wiped off. I am curious to know if it is a good practice to use savepoint mechanism here and if it is ok to use, then what would be the average time for creating + rolling back the savepoint?

No correct solution

OTHER TIPS

Unless I misunderstood the question, you can't rollback something that has been done in another transaction. So what you're doing here doesn't make much sense.

A savepoint and a rollback can be used to rollback the operations done since the save point with the connection that you rollback. Everything else is not concerned by the savepoint, and can't be undone.

Sounds like a perfect use case for DBUnit - it can recreate your entire database before each test execution.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top