use of org.apache.camel.util.jndi.ExampleBean in project camel by apache.
the class IntrospectionSupportTest method testIsSetter.
public void testIsSetter() throws Exception {
ExampleBean bean = new ExampleBean();
Method name = bean.getClass().getMethod("setName", String.class);
assertEquals(false, IntrospectionSupport.isGetter(name));
assertEquals(true, IntrospectionSupport.isSetter(name));
Method price = bean.getClass().getMethod("setPrice", double.class);
assertEquals(false, IntrospectionSupport.isGetter(price));
assertEquals(true, IntrospectionSupport.isSetter(price));
}
use of org.apache.camel.util.jndi.ExampleBean in project camel by apache.
the class IntrospectionSupportTest method testGetPropertiesSkipNull.
public void testGetPropertiesSkipNull() throws Exception {
ExampleBean bean = new ExampleBean();
bean.setName("Claus");
bean.setPrice(10.0);
bean.setId(null);
Map<String, Object> map = new HashMap<String, Object>();
IntrospectionSupport.getProperties(bean, map, null, false);
assertEquals(2, map.size());
assertEquals("Claus", map.get("name"));
String price = map.get("price").toString();
assertTrue(price.startsWith("10"));
}
use of org.apache.camel.util.jndi.ExampleBean in project camel by apache.
the class IntrospectionSupportTest method testGetPropertyLocaleIndependent.
public void testGetPropertyLocaleIndependent() throws Exception {
Locale oldLocale = Locale.getDefault();
Locale.setDefault(new Locale("tr", "TR"));
try {
ExampleBean bean = new ExampleBean();
bean.setName("Claus");
bean.setPrice(10.0);
bean.setId("1");
Object name = IntrospectionSupport.getProperty(bean, "name");
Object id = IntrospectionSupport.getProperty(bean, "id");
Object price = IntrospectionSupport.getProperty(bean, "price");
assertEquals("Claus", name);
assertEquals(10.0, price);
assertEquals("1", id);
} finally {
Locale.setDefault(oldLocale);
}
}
use of org.apache.camel.util.jndi.ExampleBean in project camel by apache.
the class IntrospectionSupportTest method testGetProperty.
public void testGetProperty() throws Exception {
ExampleBean bean = new ExampleBean();
bean.setId("123");
bean.setName("Claus");
bean.setPrice(10.0);
Object name = IntrospectionSupport.getProperty(bean, "name");
assertEquals("Claus", name);
}
use of org.apache.camel.util.jndi.ExampleBean in project camel by apache.
the class IntrospectionSupportTest method testGetPropertiesOptionPrefix.
public void testGetPropertiesOptionPrefix() throws Exception {
ExampleBean bean = new ExampleBean();
bean.setName("Claus");
bean.setPrice(10.0);
bean.setId("123");
Map<String, Object> map = new HashMap<String, Object>();
IntrospectionSupport.getProperties(bean, map, "bean.");
assertEquals(3, map.size());
assertEquals("Claus", map.get("bean.name"));
String price = map.get("bean.price").toString();
assertTrue(price.startsWith("10"));
assertEquals("123", map.get("bean.id"));
}
Aggregations