I have a java class which has a static member created using Facade (Singleton).
Class A implements InterfaceA { private static DataStore db = DataStoreFacade.getInstance("BDB"); //singleton instance public void save(final String key, final String val) { db.save(key,val); } };
Here Class A is used as a member variable for webservice (stateless bean).
I can't test this code using EasyMock because there is no way to override the DataStore instance.
There are two options.
Have a constructor taking the instance of DataStore which will set to db member variable. The problem is I don't want webservice class to know which datastore instance has been created.
Provide an additional protected Set Method to override the db object. This is what I have used where I create a Easy Mock object of DataStore and override the member variable. Is it the correct design.
What are the other possibilities?