• Welcome to KonaKart Community Forum. Please login or sign up.
 

Mocking and testing KonaKart

Started by Ted, November 05, 2009, 10:46:41 am

Previous topic - Next topic

Ted

Since I'm not using the Struts/JSP application delivered with Konakart I have to test several interactions from Wicket with the KonaKart API by means of JUnit and e.g. Easymock.

Now I was wondering: konakart.properties allows to change the default manager classes for something other. Can I do this programmatically during tests?

In konakart.properties I want to leave e.g.

#konakart.manager.CustomerMgr = com.konakart.bl.CustomerMgr

in place, but is there a way to set another class (adhering to CustomerMgrIf ?) to use as customer manager?

E.g. in my own code


public void storeUser(CustomerIf customer) throws KKException{
appEng.getCustomerMgr().editCustomer(customer);
}


I'd like to have 'getCustomerMgr()' return my own customer manager if my test requires that. I'd rather not adjust konakart.properties for that if I can avoid that. Setting custom managers as each test requires would have my preference.

trevor

From what I can tell, you are mixing up the client engine with the server engine.

All of the managers in the server engine adhere to an interface and are pluggable. However this isn't the case for the client engine. The names of the pluggable managers of the server engine are read from the properties file at startup time so I think that your only chance is to edit the properties file in code that sets up your test and then run it.

Ted

Quote from: trevor on November 06, 2009, 04:30:58 pm
From what I can tell, you are mixing up the client engine with the server engine.


Ah, yes I did.

Quote from: trevor on November 06, 2009, 04:30:58 pmAll of the managers in the server engine adhere to an interface and are pluggable. However this isn't the case for the client engine. The names of the pluggable managers of the server engine are read from the properties file at startup time so I think that your only chance is to edit the properties file in code that sets up your test and then run it.


Ok, so no programmmatic method of changing the class to be constructed after having read the property file then - for the server engine. Thx.