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"));
}
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());
}
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());
}
}
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));
}
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());
}
}
Aggregations