Hi, With the removal of the TextProviderFactory and it’s replacement with beans, I can’t figure out how to properly setup our test environment (when testing Controllers that are autowired by spring. How do I inject a custom resourceBundle into the ActionContext or stack? I used to be able to create my own textProvider, but this no longer works. I’ve seen code like the following in the struts2 tests, but localizedTextProvider is null here:
LocalizedTextProvider localizedTextProvider = container.getInstance(LocalizedTextProvider.class); I think if I can get the localizedTextProvider properly installed into the container, I’d be fine, but I can’t see how to do that. Here’s our setup code that worked with Struts 2.5.10: T controller = applicationContext.getBean(controllerClass); if (controller instanceof AbstractAuthenticatableAction) { TdarActionSupport tas = (TdarActionSupport) controller; tas.setServletRequest(getServletRequest()); tas.setServletResponse(getServletResponse()); // set the context } Map<String, Object> contextMap = new HashMap<String, Object>(); contextMap.put(StrutsStatics.HTTP_REQUEST, getServletRequest()); ActionContext context = new ActionContext(contextMap); context.setLocale(Locale.getDefault()); ConfigurationManager configurationManager = new ConfigurationManager(); OgnlValueStackFactory factory = new OgnlValueStackFactory(); // FIXME: needs to be a better way to handle this TextProviderFactory textProviderFactory = new TextProviderFactory(); factory.setTextProvider(textProviderFactory.createInstance(getResourceBundle(), (LocaleProvider) controller)); configurationManager.addContainerProvider(new XWorkConfigurationProvider()); configurationManager.getConfiguration().getContainer().inject(factory); if (controller instanceof ActionSupport) { ((ActionSupport) controller).setContainer(configurationManager.getConfiguration().getContainer()); } ValueStack stack = factory.createValueStack(); context.setValueStack(stack); ActionContext.setContext(context); -- _________________________________________________________ Adam Brin Director of Technology, Digital Antiquity 480.965.1278 --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org