CitrusDslAnnotations { public static void injectTestRunner(final Object target, final TestRunner runner) { ReflectionUtils.doWithFields(target.getClass(), field -> { Class<?> type = field.getType(); if (TestRunner.class.isAssignableFrom(type)) { log.debug(String.format("Injecting test runner instance on test class field '%s'", field.getName())); ReflectionUtils.setField(field, target, runner); } else { throw new CitrusRuntimeException("Not able to provide a Citrus resource injection for type " + type); } }, field -> { if (field.isAnnotationPresent(CitrusResource.class) && TestRunner.class.isAssignableFrom(field.getType())) { if (!field.isAccessible()) { ReflectionUtils.makeAccessible(field); } return true; } return false; }); } private  CitrusDslAnnotations(); static void injectTestDesigner(final Object target, final TestDesigner designer); static void injectTestRunner(final Object target, final TestRunner runner);  }
@Test public void testInjectTestRunner() throws Exception { TestRunnerClient client = new TestRunnerClient(); Assert.assertNull(client.getRunner()); CitrusDslAnnotations.injectTestRunner(client, runner); Assert.assertEquals(client.getRunner(), runner); Assert.assertEquals(client.otherAnnotatedResource, "foo"); Assert.assertNull(client.otherRunner); }