This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Testing and the fly likes EasyMock- How to populate a ResultSet ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "EasyMock- How to populate a ResultSet ?" Watch "EasyMock- How to populate a ResultSet ?" New topic
Author

EasyMock- How to populate a ResultSet ?

Tiya Khambadkone
Ranch Hand

Joined: Sep 15, 2011
Posts: 52
EasyMock- How to populate a ResultSet for more than 1 row ?

This is how I am populating for a single row.

mockControl.expectAndReturn(mockRS.getString(1), "EmployeeId", 1);
mockControl.expectAndReturn(mockRS.getString(2), "EmployeeName", 1);
mockRS.next();

I tried this logic for 2nd row :
mockControl.expectAndReturn(mockRS.getString(1), "EmployeeId", 2);
mockControl.expectAndReturn(mockRS.getString(2), "EmployeeName", 2);
mockRS.next();

When inside the class-under-test,
while(rs.next())

excutes only once .

So, How to populate a ResultSet for more than 1 row ?
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31571
    
185

Where in the test are you specifying that mockRs.next() should return true?


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
 
subject: EasyMock- How to populate a ResultSet ?