Search in sources :

Example 56 with Bar

use of com.opensymphony.xwork2.util.Bar in project struts by apache.

the class PropertyTest method testDefaultShouldBeOutputIfPropertyIsNull.

public void testDefaultShouldBeOutputIfPropertyIsNull() {
    final ValueStack stack = ActionContext.getContext().getValueStack();
    stack.push(new FooBar(null, "bar-value"));
    final Property property = new Property(stack);
    property.setDefault("default");
    property.setValue("foo");
    assertPropertyOutput("default", property);
}
Also used : ValueStack(com.opensymphony.xwork2.util.ValueStack)

Example 57 with Bar

use of com.opensymphony.xwork2.util.Bar in project struts by apache.

the class PropertyTest method testNormalBehaviour.

public void testNormalBehaviour() {
    final ValueStack stack = ActionContext.getContext().getValueStack();
    stack.push(new FooBar("foo-value", "bar-value"));
    final Property property = new Property(stack);
    property.setDefault("default");
    property.setValue("foo");
    assertPropertyOutput("foo-value", property);
}
Also used : ValueStack(com.opensymphony.xwork2.util.ValueStack)

Example 58 with Bar

use of com.opensymphony.xwork2.util.Bar in project struts by apache.

the class UIBeanTest method testGetThemeFromContext.

public void testGetThemeFromContext() {
    ValueStack stack = ActionContext.getContext().getValueStack();
    MockHttpServletRequest req = new MockHttpServletRequest();
    MockHttpServletResponse res = new MockHttpServletResponse();
    Map<String, Object> context = Collections.singletonMap("theme", "bar");
    ActionContext.getContext().put("attr", context);
    TextField txtFld = new TextField(stack, req, res);
    assertEquals("bar", txtFld.getTheme());
}
Also used : ValueStack(com.opensymphony.xwork2.util.ValueStack) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse)

Example 59 with Bar

use of com.opensymphony.xwork2.util.Bar in project struts by apache.

the class CoopInterceptorTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    container.inject(interceptor);
    interceptor.setExemptedPaths("/foo,/bar");
    ServletActionContext.setRequest(request);
    ServletActionContext.setResponse(response);
    ActionContext context = ServletActionContext.getActionContext();
    mai.setInvocationContext(context);
}
Also used : ActionContext(com.opensymphony.xwork2.ActionContext) ServletActionContext(org.apache.struts2.ServletActionContext)

Example 60 with Bar

use of com.opensymphony.xwork2.util.Bar in project struts by apache.

the class PropertiesConfigurationProviderTest method testRegister_DifferentLocale.

public void testRegister_DifferentLocale() {
    ContainerBuilder builder = new ContainerBuilder();
    builder.constant("foo", "bar");
    builder.constant("struts.locale", "de_DE");
    PropertiesConfigurationProvider prov = new PropertiesConfigurationProvider();
    prov.register(builder, new LocatableProperties());
    Container container = builder.create(true);
    String localeStr = container.getInstance(String.class, StrutsConstants.STRUTS_LOCALE);
    Locale locale = LocaleUtils.toLocale(localeStr);
    assertNotNull(locale);
    assertEquals("DE", locale.getCountry());
    assertEquals("de", locale.getLanguage());
}
Also used : Locale(java.util.Locale) Container(com.opensymphony.xwork2.inject.Container) ContainerBuilder(com.opensymphony.xwork2.inject.ContainerBuilder) LocatableProperties(com.opensymphony.xwork2.util.location.LocatableProperties)

Aggregations

HashMap (java.util.HashMap)17 Bar (com.opensymphony.xwork2.util.Bar)14 Foo (com.opensymphony.xwork2.util.Foo)13 ValueStack (com.opensymphony.xwork2.util.ValueStack)12 ActionProxy (com.opensymphony.xwork2.ActionProxy)9 ActionConfig (com.opensymphony.xwork2.config.entities.ActionConfig)9 ConfigurationProvider (com.opensymphony.xwork2.config.ConfigurationProvider)7 ValidationAware (com.opensymphony.xwork2.interceptor.ValidationAware)7 List (java.util.List)6 Map (java.util.Map)6 ConversionData (com.opensymphony.xwork2.conversion.impl.ConversionData)5 Mock (com.mockobjects.dynamic.Mock)4 ActionContext (com.opensymphony.xwork2.ActionContext)4 PackageConfig (com.opensymphony.xwork2.config.entities.PackageConfig)4 ResultConfig (com.opensymphony.xwork2.config.entities.ResultConfig)3 ContainerBuilder (com.opensymphony.xwork2.inject.ContainerBuilder)3 MockResult (com.opensymphony.xwork2.mock.MockResult)3 ModelDrivenAction2 (com.opensymphony.xwork2.test.ModelDrivenAction2)3 LocatableProperties (com.opensymphony.xwork2.util.location.LocatableProperties)3 ActionSupport (com.opensymphony.xwork2.ActionSupport)2