Search in sources :

Example 6 with TestBean

use of com.opensymphony.xwork2.TestBean in project commons-beanutils by apache.

the class Jira358TestCase method testPropertyUtils_getIndexedProperty_List.

/**
 * Test {@link PropertyUtils#getIndexedProperty(Object, String, int)}
 */
public void testPropertyUtils_getIndexedProperty_List() throws Exception {
    final TestBean bean = new TestBean();
    try {
        PropertyUtils.getIndexedProperty(bean, "listIndexed", bean.getListIndexed().size());
        fail("Expected IndexOutOfBoundsException");
    } catch (final IndexOutOfBoundsException e) {
    // expected result
    }
}
Also used : TestBean(org.apache.commons.beanutils2.TestBean)

Example 7 with TestBean

use of com.opensymphony.xwork2.TestBean in project commons-beanutils by apache.

the class LocaleBeanUtilsTestCase method testSetNestedPropertySimple.

/**
 * Test setting a nested simple property
 */
public void testSetNestedPropertySimple() {
    final TestBean bean = new TestBean();
    bean.getNested().setIntProperty(5);
    assertEquals("Initial value 5", 5, bean.getNested().getIntProperty());
    try {
        LocaleBeanUtils.setProperty(bean, "nested.intProperty", "123", null);
    } catch (final Throwable t) {
        log.error(t);
        fail("Threw " + t);
    }
    assertEquals("Check Set Value", 123, bean.getNested().getIntProperty());
}
Also used : TestBean(org.apache.commons.beanutils2.TestBean)

Example 8 with TestBean

use of com.opensymphony.xwork2.TestBean in project commons-beanutils by apache.

the class LocaleBeanUtilsTestCase method testSetNestedPropertyIndexed.

/**
 * Test setting a nested indexed property
 */
public void testSetNestedPropertyIndexed() {
    final TestBean bean = new TestBean();
    bean.getNested().setIntIndexed(1, 51);
    assertEquals("Initial value[1] 51", 51, bean.getNested().getIntIndexed(1));
    try {
        LocaleBeanUtils.setProperty(bean, "nested.intIndexed[1]", "123", null);
    } catch (final Throwable t) {
        log.error(t);
        fail("Threw " + t);
    }
    assertEquals("Check Set Value", 123, bean.getNested().getIntIndexed(1));
}
Also used : TestBean(org.apache.commons.beanutils2.TestBean)

Example 9 with TestBean

use of com.opensymphony.xwork2.TestBean in project commons-beanutils by apache.

the class Jira358TestCase method testPropertyUtils_getIndexedProperty_Array.

/**
 * Test {@link PropertyUtils#getIndexedProperty(Object, String, int)}
 */
public void testPropertyUtils_getIndexedProperty_Array() throws Exception {
    final TestBean bean = new TestBean();
    try {
        PropertyUtils.getIndexedProperty(bean, "intArray", bean.getIntArray().length);
        fail("Expected ArrayIndexOutOfBoundsException");
    } catch (final ArrayIndexOutOfBoundsException e) {
    // expected result
    }
}
Also used : TestBean(org.apache.commons.beanutils2.TestBean)

Example 10 with TestBean

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

the class SpringObjectFactoryTest method testShouldAutowireObjectsObtainedFromTheObjectFactoryByFullClassName.

public void testShouldAutowireObjectsObtainedFromTheObjectFactoryByFullClassName() throws Exception {
    sac.getBeanFactory().registerSingleton("bean", new TestBean());
    TestBean bean = (TestBean) sac.getBean("bean");
    SimpleAction action = (SimpleAction) objectFactory.buildBean(SimpleAction.class.getName(), null);
    assertEquals(bean, action.getBean());
}
Also used : TestBean(com.opensymphony.xwork2.TestBean) SimpleAction(com.opensymphony.xwork2.SimpleAction)

Aggregations

TestBean (com.opensymphony.xwork2.TestBean)11 SimpleAction (com.opensymphony.xwork2.SimpleAction)5 TestBean (org.apache.commons.beanutils2.TestBean)4 ActionInvocation (com.opensymphony.xwork2.ActionInvocation)3 ActionConfig (com.opensymphony.xwork2.config.entities.ActionConfig)3 List (java.util.List)3 ActionProxy (com.opensymphony.xwork2.ActionProxy)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 ModelDrivenAction (com.opensymphony.xwork2.ModelDrivenAction)1 Configuration (com.opensymphony.xwork2.config.Configuration)1 ConfigurationException (com.opensymphony.xwork2.config.ConfigurationException)1 MockConfiguration (com.opensymphony.xwork2.config.impl.MockConfiguration)1 Container (com.opensymphony.xwork2.inject.Container)1 ContainerBuilder (com.opensymphony.xwork2.inject.ContainerBuilder)1 Scope (com.opensymphony.xwork2.inject.Scope)1 TestBean2 (com.opensymphony.xwork2.test.TestBean2)1 LocatableProperties (com.opensymphony.xwork2.util.location.LocatableProperties)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1