Search in sources :

Example 6 with LocalizedTextProvider

use of com.opensymphony.xwork2.LocalizedTextProvider in project struts by apache.

the class StrutsBeanSelectionProviderTest method testRegister.

public void testRegister() {
    LocalizedTextProvider localizedTextProvider = container.getInstance(LocalizedTextProvider.class);
    assertEquals("The form has already been processed or no token was supplied, please try again.", localizedTextProvider.findDefaultText("struts.messages.invalid.token", Locale.getDefault()));
    loadConfigurationProviders(new StubConfigurationProvider() {

        @Override
        public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
            props.setProperty(StrutsConstants.STRUTS_CUSTOM_I18N_RESOURCES, "testmessages,testmessages2");
            props.setProperty(StrutsConstants.STRUTS_LOCALE, "US");
        }
    });
    localizedTextProvider = container.getInstance(LocalizedTextProvider.class);
    assertEquals("Replaced message for token tag", localizedTextProvider.findDefaultText("struts.messages.invalid.token", Locale.getDefault()));
}
Also used : ContainerBuilder(com.opensymphony.xwork2.inject.ContainerBuilder) StubConfigurationProvider(com.opensymphony.xwork2.test.StubConfigurationProvider) LocatableProperties(com.opensymphony.xwork2.util.location.LocatableProperties) ConfigurationException(com.opensymphony.xwork2.config.ConfigurationException) LocalizedTextProvider(com.opensymphony.xwork2.LocalizedTextProvider)

Aggregations

LocalizedTextProvider (com.opensymphony.xwork2.LocalizedTextProvider)5 ConfigurationException (com.opensymphony.xwork2.config.ConfigurationException)1 XmlConfigurationProvider (com.opensymphony.xwork2.config.providers.XmlConfigurationProvider)1 ContainerBuilder (com.opensymphony.xwork2.inject.ContainerBuilder)1 StubConfigurationProvider (com.opensymphony.xwork2.test.StubConfigurationProvider)1 StrutsLocalizedTextProvider (com.opensymphony.xwork2.util.StrutsLocalizedTextProvider)1 LocatableProperties (com.opensymphony.xwork2.util.location.LocatableProperties)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 ResourceBundle (java.util.ResourceBundle)1 StrutsXmlConfigurationProvider (org.apache.struts2.config.StrutsXmlConfigurationProvider)1