Search in sources :

Example 6 with StubTextProvider

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

the class XWorkBasicConverterTest method testDateWithLocalePoland.

public void testDateWithLocalePoland() {
    Map<String, String> map = new HashMap<>();
    ValueStack stack = new StubValueStack();
    stack.push(new StubTextProvider(map));
    Locale locale = new Locale("pl", "PL");
    ActionContext context = ActionContext.of(new HashMap<>()).withLocale(locale).withValueStack(stack);
    String reference = "2009-01-09";
    Object convertedObject = basicConverter.convertValue(context.getContextMap(), null, null, null, reference, Date.class);
    assertNotNull(convertedObject);
    compareDates(locale, convertedObject);
}
Also used : StubValueStack(com.opensymphony.xwork2.StubValueStack) StubTextProvider(com.opensymphony.xwork2.StubTextProvider) StubValueStack(com.opensymphony.xwork2.StubValueStack) ValueStack(com.opensymphony.xwork2.util.ValueStack) ActionContext(com.opensymphony.xwork2.ActionContext)

Example 7 with StubTextProvider

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

the class XWorkBasicConverterTest method testDateWithLocaleUK.

public void testDateWithLocaleUK() {
    Map<String, String> map = new HashMap<>();
    ValueStack stack = new StubValueStack();
    stack.push(new StubTextProvider(map));
    Locale locale = new Locale("en", "US");
    ActionContext context = ActionContext.of(new HashMap<>()).withLocale(locale).withValueStack(stack);
    String reference = "01/09/2009";
    Object convertedObject = basicConverter.convertValue(context.getContextMap(), null, null, null, reference, Date.class);
    assertNotNull(convertedObject);
    compareDates(locale, convertedObject);
}
Also used : StubValueStack(com.opensymphony.xwork2.StubValueStack) StubTextProvider(com.opensymphony.xwork2.StubTextProvider) StubValueStack(com.opensymphony.xwork2.StubValueStack) ValueStack(com.opensymphony.xwork2.util.ValueStack) ActionContext(com.opensymphony.xwork2.ActionContext)

Aggregations

StubTextProvider (com.opensymphony.xwork2.StubTextProvider)7 StubValueStack (com.opensymphony.xwork2.StubValueStack)7 ValueStack (com.opensymphony.xwork2.util.ValueStack)7 ActionContext (com.opensymphony.xwork2.ActionContext)6 HashMap (java.util.HashMap)3 Locale (java.util.Locale)2 Foo (com.opensymphony.xwork2.util.Foo)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 StrutsException (org.apache.struts2.StrutsException)1 TypeConversionException (org.apache.struts2.conversion.TypeConversionException)1