private void processTestReference()

in src/main/java/org/apache/sling/junit/impl/AnnotationsProcessor.java [81:103]


    private void processTestReference(Object testObject, Field f) throws Exception {
        if(bundleContext == null) {
            final String msg = "Null BundleContext in processTestReference(), not activated?";
            log.error(msg);
            throw new IllegalArgumentException(msg);
        }
        final Class<?> serviceType = f.getType();
        Annotation[] testReferences = f.getDeclaredAnnotations();
        if(Objects.nonNull(testReferences) && testReferences.length != 0){
            TestReference testReference = (TestReference) testReferences[0];

            final Object service = getService(serviceType, testReference.target(), testObject);
            if(service != null) {
                f.setAccessible(true);
                f.set(testObject, service);
                log.debug("Injected service {} into field {}",
                        serviceType.getName(), f.getName());
            } else {
                log.warn("Service {} not found for field {}",
                        serviceType.getName(), f.getName());
            }
        }
    }