Annotation Type TestReference


@Target(FIELD) @Retention(RUNTIME) public @interface TestReference
Annotation used to inject services in test classes. Similar to the Felix @Reference annotation, but we need RetentionPolicy.RUNTIME so we cannot use that one. FYI {#link TeleporterRule} is another way of executing server-side tests, including OSGi service injection.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The local name of the reference.
    The name of the service interface.
    LDAP-style filter for targeting a specific reference implementation
  • Element Details

    • name

      String name
      The local name of the reference. Default value is the name of the field to which the annotation applies.
      Returns:
      the local name of the reference ("" by default)
      Default:
      ""
    • target

      String target
      LDAP-style filter for targeting a specific reference implementation
      Returns:
      the local name of the reference ("" by default)
      Default:
      ""
    • referenceInterface

      Class<?> referenceInterface
      The name of the service interface. This name is used by the Service Component Runtime to access the service on behalf of the component. The default value for is the type of the field to which the annotation applies.
      Returns:
      the service interface
      Default:
      org.apache.sling.junit.annotations.AutoDetect.class