History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: APF-1048
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Matt Raible
Reporter: Max Weber
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
AppFuse

Missing calls in BasePageTestCase

Created: 13/Apr/08 01:48 PM   Updated: 02/May/08 08:49 PM
Component/s: Web - JSF
Affects Version/s: 2.0.1
Fix Version/s: 2.0.2

File Attachments: 1. Text File APF-1048.patch (0.7 kb)



 Description  « Hide
The BasePageTestCase class have to invoke the corresponding methods of the superclass in the onSetUp()- and onTearDown()-method. Otherwise for example the onSetUpInTransaction()-method will not be called.

 All   Comments   Change History   FishEye      Sort Order:
Matt Raible - 13/Apr/08 02:30 PM
Please describe steps to reproduce the error this causes and how your suggested fix solves the problem.

Thanks,

Matt

Max Weber - 15/Apr/08 03:11 AM
You need the above-named fix, if you want do some integration testing of your JSF managed beans and don't want to use DBUnit to prepare your fixtures in the database. In this case the functionality of the Spring Testing Framework could be used. Here a short example to demonstrate such a situation:

public class CustomerFormTest extends BasePageTestCase {
private Customer customer;
private CustomerForm customerForm;

// In this case JSF managed beans are configured in a Spring application context
public void setCustomerForm(CustomerForm customerForm) {
this.customerForm = customerForm;
}

@Override
protected void onSetUp() throws Exception {
customer = new Customer();
customer.setId(new Long(4711));
customer.setName("John Q. Public");
super.onSetUp();
}

@Override
protected void onSetUpInTransaction() throws Exception {
jdbcTemplate.execute("INSERT INTO CUSTOMER(ID,NAME) " +
" VALUES(" + customer.getId().toString() + "," +
"'" + customer.getName() + "')");
super.onSetUpInTransaction();
}

public void testShouldLoadACustomerByAnIdRequestParameter() {
request.addParameter("id", customer.getId().toString());
assertEquals("edit", customerForm.edit());
assertEquals(customer, customerForm.getCustomer());
}
}

The fixture is prepared in the onSetUpInTransaction-method. When the test ends the onTeardown-method in the AbstractTransactionalSpringContextTests is called, which rollbacks the database transaction. Without the aboved-named fix the onSetUpInTransaction-method in the superclass AbstractTransactionalSpringContextTests will never be called. Furthermore the onTearDown-method of the superclass should be called to rollback the started database transaction.
 
Best regards,

Max

Matt Raible - 01/May/08 02:14 AM
Please confirm the attached patch is what you'd like to see.