Search in sources :

Example 6 with ExampleBean

use of org.apache.camel.util.jndi.ExampleBean in project camel by apache.

the class IntrospectionSupportTest method testGetProperties.

public void testGetProperties() throws Exception {
    ExampleBean bean = new ExampleBean();
    bean.setName("Claus");
    bean.setPrice(10.0);
    Map<String, Object> map = new HashMap<String, Object>();
    IntrospectionSupport.getProperties(bean, map, null);
    assertEquals(3, map.size());
    assertEquals("Claus", map.get("name"));
    String price = map.get("price").toString();
    assertTrue(price.startsWith("10"));
    assertEquals(null, map.get("id"));
}
Also used : LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) ExampleBean(org.apache.camel.util.jndi.ExampleBean)

Example 7 with ExampleBean

use of org.apache.camel.util.jndi.ExampleBean in project camel by apache.

the class IntrospectionSupportTest method testOverloadSetterChooseBeanSetter.

public void testOverloadSetterChooseBeanSetter() throws Exception {
    MyOverloadedBean overloadedBean = new MyOverloadedBean();
    ExampleBean bean = new ExampleBean();
    bean.setName("Claus");
    IntrospectionSupport.setProperty(context.getTypeConverter(), overloadedBean, "bean", bean);
    assertEquals("Claus", overloadedBean.getName());
}
Also used : ExampleBean(org.apache.camel.util.jndi.ExampleBean)

Example 8 with ExampleBean

use of org.apache.camel.util.jndi.ExampleBean in project camel by apache.

the class IntrospectionSupportTest method testGetPropertyGetter.

public void testGetPropertyGetter() throws Exception {
    ExampleBean bean = new ExampleBean();
    bean.setName("Claus");
    bean.setPrice(10.0);
    Method name = IntrospectionSupport.getPropertyGetter(ExampleBean.class, "name");
    assertEquals("getName", name.getName());
    try {
        IntrospectionSupport.getPropertyGetter(ExampleBean.class, "xxx");
        fail("Should have thrown exception");
    } catch (NoSuchMethodException e) {
        assertEquals("org.apache.camel.util.jndi.ExampleBean.getXxx()", e.getMessage());
    }
}
Also used : ExampleBean(org.apache.camel.util.jndi.ExampleBean) Method(java.lang.reflect.Method)

Example 9 with ExampleBean

use of org.apache.camel.util.jndi.ExampleBean in project camel by apache.

the class IntrospectionSupportTest method testIsGetter.

public void testIsGetter() throws Exception {
    ExampleBean bean = new ExampleBean();
    Method name = bean.getClass().getMethod("getName", (Class<?>[]) null);
    assertEquals(true, IntrospectionSupport.isGetter(name));
    assertEquals(false, IntrospectionSupport.isSetter(name));
    Method price = bean.getClass().getMethod("getPrice", (Class<?>[]) null);
    assertEquals(true, IntrospectionSupport.isGetter(price));
    assertEquals(false, IntrospectionSupport.isSetter(price));
}
Also used : ExampleBean(org.apache.camel.util.jndi.ExampleBean) Method(java.lang.reflect.Method)

Example 10 with ExampleBean

use of org.apache.camel.util.jndi.ExampleBean in project camel by apache.

the class IntrospectionSupportTest method testGetPropertySetter.

public void testGetPropertySetter() throws Exception {
    ExampleBean bean = new ExampleBean();
    bean.setName("Claus");
    bean.setPrice(10.0);
    Method name = IntrospectionSupport.getPropertySetter(ExampleBean.class, "name");
    assertEquals("setName", name.getName());
    try {
        IntrospectionSupport.getPropertySetter(ExampleBean.class, "xxx");
        fail("Should have thrown exception");
    } catch (NoSuchMethodException e) {
        assertEquals("org.apache.camel.util.jndi.ExampleBean.setXxx", e.getMessage());
    }
}
Also used : ExampleBean(org.apache.camel.util.jndi.ExampleBean) Method(java.lang.reflect.Method)

Aggregations

ExampleBean (org.apache.camel.util.jndi.ExampleBean)11 Method (java.lang.reflect.Method)4 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 Locale (java.util.Locale)1