Search in sources :

Example 26 with Bar

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

the class OgnlValueStackTest method testSetReallyDeepBarAsString.

public void testSetReallyDeepBarAsString() {
    Foo foo = new Foo();
    Foo foo2 = new Foo();
    foo.setChild(foo2);
    Foo foo3 = new Foo();
    foo2.setChild(foo3);
    OgnlValueStack vs = createValueStack();
    vs.push(foo);
    vs.setValue("child.child.bar", "bar:123");
    assertEquals("bar", foo.getChild().getChild().getBar().getTitle());
    assertEquals(123, foo.getChild().getChild().getBar().getSomethingElse());
}
Also used : Foo(com.opensymphony.xwork2.util.Foo)

Example 27 with Bar

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

the class OgnlValueStackTest method testFooBarAsString.

public void testFooBarAsString() {
    OgnlValueStack vs = createValueStack();
    Foo foo = new Foo();
    Bar bar = new Bar();
    bar.setTitle("blah");
    bar.setSomethingElse(123);
    foo.setBar(bar);
    vs.push(foo);
    assertEquals("blah:123", vs.findValue("bar", String.class));
}
Also used : Foo(com.opensymphony.xwork2.util.Foo)

Example 28 with Bar

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

the class OgnlValueStackTest method testSetDeepBarAsString.

public void testSetDeepBarAsString() {
    Foo foo = new Foo();
    Foo foo2 = new Foo();
    foo.setChild(foo2);
    OgnlValueStack vs = createValueStack();
    vs.push(foo);
    vs.setValue("child.bar", "bar:123");
    assertEquals("bar", foo.getChild().getBar().getTitle());
    assertEquals(123, foo.getChild().getBar().getSomethingElse());
}
Also used : Foo(com.opensymphony.xwork2.util.Foo)

Example 29 with Bar

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

the class OgnlValueStackTest method testPetSoarBug.

public void testPetSoarBug() {
    Cat cat = new Cat();
    cat.setFoo(new Foo());
    Bar bar = new Bar();
    bar.setTitle("bar");
    bar.setSomethingElse(123);
    cat.getFoo().setBar(bar);
    OgnlValueStack vs = createValueStack();
    vs.push(cat);
    assertEquals("bar:123", vs.findValue("foo.bar", String.class));
}
Also used : Foo(com.opensymphony.xwork2.util.Foo)

Example 30 with Bar

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

the class SetPropertiesTest method testOgnlUtilEmptyStringAsLong.

public void testOgnlUtilEmptyStringAsLong() {
    Bar bar = new Bar();
    Map context = Ognl.createDefaultContext(bar, new SecurityMemberAccess(false, true));
    context.put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);
    bar.setId(null);
    HashMap props = new HashMap();
    props.put("id", "");
    ognlUtil.setProperties(props, bar, context);
    assertNull(bar.getId());
    assertEquals(0, bar.getFieldErrors().size());
    props.put("id", new String[] { "" });
    bar.setId(null);
    ognlUtil.setProperties(props, bar, context);
    assertNull(bar.getId());
    assertEquals(0, bar.getFieldErrors().size());
}
Also used : Bar(com.opensymphony.xwork2.util.Bar)

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