Package org.osgi.test.common.annotation
Annotation Type InjectService
@Inherited
@Target({FIELD,PARAMETER})
@Retention(RUNTIME)
@ExtendWith(ServiceExtension.class)
@Documented
public @interface InjectService
Inject OSGi services into test classes and methods.
Example:
// For JUnit5
@ExtendWith(ServiceExtension.class)
class MyTests {
// For JUnit4
@Rule
ServiceRule sr = new ServiceRule();
@InjectService
Foo foo;
@Test
public void test() {
// use foo
}
}
-
Nested Class Summary
Nested Classes -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionintIndicate the number of services that are required to arrive within the specified bytimeout()before starting the test.Filter string used to target more specific services using theString.formatpattern.String[]Optional arguments to the format string provided byfilter().Class<?>Indicate to take the serviceClass from not from the parameter.longIndicate require services must arrive within the specified timeout. -
Field Summary
Fields
-
Field Details
-
DEFAULT_TIMEOUT
static final long DEFAULT_TIMEOUT- See Also:
-
-
Element Details
-
filter
String filterFilter string used to target more specific services using theString.formatpattern. Must use valid OSGi filter syntax.- Returns:
- The filter string.
- Default:
- ""
-
filterArguments
String[] filterArgumentsOptional arguments to the format string provided byfilter().- Returns:
- The filter arguments.
- Default:
- {}
-
cardinality
int cardinalityIndicate the number of services that are required to arrive within the specified bytimeout()before starting the test.- Returns:
- The cardinality.
- Default:
- 1
-
timeout
long timeoutIndicate require services must arrive within the specified timeout.- Returns:
- The timeout.
- Default:
- 200L
-
service
Class<?> serviceIndicate to take the serviceClass from not from the parameter. Use `org.osgi.test.common.annotation.InjectService.AnyService` and the ParameterType or FieldType `java.lang.Object` for any Service.- Returns:
- The service class.
- Default:
- org.osgi.test.common.annotation.InjectService.class
-