@Test public void testConvertValue() throws Exception { Bundle bundle = mock(Bundle.class); BundleDelegatingClassLoader classLoader = new BundleDelegatingClassLoader(bundle, getClass().getClassLoader()); TypeConverter typeConverter = mock(TypeConverter.class); when(typeConverter.convertTo(Integer.class, "1")).thenReturn(1); when(typeConverter.convertTo(Long.class, "2")).thenReturn(null); CamelContext camelContext = mock(CamelContext.class); when(camelContext.getApplicationContextClassLoader()).thenReturn(classLoader); when(camelContext.getTypeConverter()).thenReturn(typeConverter); OsgiComponent component = new OsgiComponent(); component.setCamelContext(camelContext); assertThat((Integer) component.convertValue("1", Integer.class), equalTo(1)); assertThat((String) component.convertValue("2", Long.class), equalTo("2")); verify(typeConverter).convertTo(same(Integer.class), eq("1")); verify(typeConverter).convertTo(same(Long.class), eq("2")); }
protected Object convertValue(Object value, Class<?> clazz) { TypeConverter converter = getCamelContext().getTypeConverter(); Object answer = converter.convertTo(clazz, value); return answer != null ? answer : value; }
OsgiComponent extends DefaultComponent { protected Object convertValue(Object value, Class<?> clazz) { TypeConverter converter = getCamelContext().getTypeConverter(); Object answer = converter.convertTo(clazz, value); return answer != null ? answer : value; } }
OsgiComponent extends DefaultComponent { protected Object convertValue(Object value, Class<?> clazz) { TypeConverter converter = getCamelContext().getTypeConverter(); Object answer = converter.convertTo(clazz, value); return answer != null ? answer : value; }  }
OsgiComponent extends DefaultComponent { protected Object convertValue(Object value, Class<?> clazz) { TypeConverter converter = getCamelContext().getTypeConverter(); Object answer = converter.convertTo(clazz, value); return answer != null ? answer : value; }   }
OsgiComponent extends DefaultComponent { protected Object convertValue(Object value, Class<?> clazz) { TypeConverter converter = getCamelContext().getTypeConverter(); Object answer = converter.convertTo(clazz, value); return answer != null ? answer : value; }    }