* Initialize test environment
*/
protected void setUp() throws Exception {
Application.load(null);
StaticApplicationContext applicationContext = new StaticApplicationContext();
DefaultApplicationServices applicationServices = new DefaultApplicationServices(applicationContext);
DefaultApplicationLifecycleAdvisor advisor = new DefaultApplicationLifecycleAdvisor();
Application app = new Application(advisor);
advisor.setApplication(app);
Application.instance().setApplicationContext(applicationContext);
applicationServices.setApplicationContext(applicationContext);
ApplicationServicesLocator locator = new ApplicationServicesLocator(applicationServices);
ApplicationServicesLocator.load(locator);
// create dummy message source that always return an empty string
AbstractMessageSource source = new AbstractMessageSource() {
@Override
protected MessageFormat resolveCode(String s, Locale locale) {
return new MessageFormat("");
}
};
MessageSourceAccessor accessor = new MessageSourceAccessor(source);
applicationServices.setMessageSourceAccesor(accessor);
applicationServices.setMessageSource(source);
applicationContext.refresh();
// create formmodel to test on and initialize value models
model = FormModelHelper.createFormModel(new ValidatingObject());