private void set(Class<?> clazz, Object propertyValue, PropertyMatchResolution matchRes) throws IllegalAccessException { if (Object.class.equals(clazz) || clazz == null) { return; } Field[] fields = clazz.getDeclaredFields(); for (Field field : fields) { if (matchRes.matches(field, propertyValue)) { setValue(field, propertyValue); } } // check parent class fields set(clazz.getSuperclass(), propertyValue, matchRes); }
private void setInvokers() throws IllegalAccessException { setInvokers(_testInstance.getClass()); }
private void setInvokers(Class<?> clazz) throws IllegalAccessException { if (Object.class.equals(clazz) || clazz == null) { return; } Field[] fields = clazz.getDeclaredFields(); for (Field field : fields) { if (field.getType() == Invoker.class) { ServiceOperation serviceOp = field.getAnnotation(ServiceOperation.class); if (serviceOp == null) { Assert.fail("Invoker property '" + field.getName() + "' on test class '" + _testInstance.getClass().getName() + "' needs to be annotated with a @ServiceOperation."); } Invoker invoker = _testKit.newInvoker(serviceOp.value()); if (invoker == null) { Assert.fail("Invoker property '" + field.getName() + "' on test class '" + _testInstance.getClass().getName() + "' contains an a @ServiceOperation defining an unknown Service Operation value '" + serviceOp.value() + "'."); } setValue(field, invoker); } } setInvokers(clazz.getSuperclass()); } }
@Override protected Object createTest() throws Exception { _testInstance = super.createTest(); _testKit = new SwitchYardTestKit(_testInstance); for (TestMixIn mixIn : _testKit.getMixIns()) { set(mixIn, PropertyMatchResolution.EQUALS); } try { _testKit.start(); } catch (Throwable t) { LOG.error("Error while test kit startup", t); _testKit.cleanup(); throw new Exception(t); } set(_testKit, PropertyMatchResolution.EQUALS); set(_testKit.getDeployment(), PropertyMatchResolution.ASSIGNABLE); set(_testKit.getConfigModel(), PropertyMatchResolution.ASSIGNABLE); set(_testKit.getServiceDomain(), PropertyMatchResolution.ASSIGNABLE); set(_testKit.getServiceDomain().getTransformerRegistry(), PropertyMatchResolution.ASSIGNABLE); set(_testKit.getServiceDomain().getProperty(SwitchYardCamelContext.CAMEL_CONTEXT_PROPERTY), PropertyMatchResolution.ASSIGNABLE); setInvokers(); return _testInstance; }
private void set(Object propertyValue, PropertyMatchResolution matchRes) throws IllegalAccessException { // check whole class hierarchy recursive set(_testInstance.getClass(), propertyValue, matchRes); }
private void setInvokers(Class<?> clazz) throws IllegalAccessException { if (Object.class.equals(clazz) || clazz == null) { return; } Field[] fields = clazz.getDeclaredFields(); for (Field field : fields) { if (field.getType() == Invoker.class) { ServiceOperation serviceOp = field.getAnnotation(ServiceOperation.class); if (serviceOp == null) { Assert.fail("Invoker property '" + field.getName() + "' on test class '" + _testInstance.getClass().getName() + "' needs to be annotated with a @ServiceOperation."); } Invoker invoker = _testKit.newInvoker(serviceOp.value()); if (invoker == null) { Assert.fail("Invoker property '" + field.getName() + "' on test class '" + _testInstance.getClass().getName() + "' contains an a @ServiceOperation defining an unknown Service Operation value '" + serviceOp.value() + "'."); } setValue(field, invoker); } } setInvokers(clazz.getSuperclass()); } }
set(mixIn, PropertyMatchResolution.EQUALS); set(_testKit, PropertyMatchResolution.EQUALS); set(_testKit.getDeployment(), PropertyMatchResolution.ASSIGNABLE); set(_testKit.getConfigModel(), PropertyMatchResolution.ASSIGNABLE); set(_testKit.getServiceDomain(), PropertyMatchResolution.ASSIGNABLE); set(_testKit.getServiceDomain().getTransformerRegistry(), PropertyMatchResolution.ASSIGNABLE); set(_testKit.getServiceDomain().getProperty(SwitchYardCamelContext.CAMEL_CONTEXT_PROPERTY), PropertyMatchResolution.ASSIGNABLE); setInvokers();
private void set(Object propertyValue, PropertyMatchResolution matchRes) throws IllegalAccessException { // check whole class hierarchy recursive set(_testInstance.getClass(), propertyValue, matchRes); }
private void set(Class<?> clazz, Object propertyValue, PropertyMatchResolution matchRes) throws IllegalAccessException { if (Object.class.equals(clazz) || clazz == null) { return; } Field[] fields = clazz.getDeclaredFields(); for (Field field : fields) { if (matchRes.matches(field, propertyValue)) { setValue(field, propertyValue); } } // check parent class fields set(clazz.getSuperclass(), propertyValue, matchRes); }
private void setInvokers() throws IllegalAccessException { setInvokers(_testInstance.getClass()); }