I have my ipojo component like
@Component(immediate = true)
@Provides
public class MyComponent {
public MyComponent (@Property(mandatory = true, name = "initialDelay", value = "60") Long initialDelay)
{
...
}
For integration testing using pax-exam i am using test like below using
@Test
public void installBundle() throws Exception
{
executeCommand("bundle:install mvn:com.my.osgi/MyComponent/2.0.2-SNAPSHOT", ADMIN_ROLES);
assertBundleInstalled("MyComponent ");
}
Now my question is how i can pass different values for "initialDelay" property so bundle test with my provided values?
The KarafTestSupport class contains some examples for providing configs:
This is suitable for bigger configs that you provide in src/test/resources.
Using this you can replace individual properties in configs.
Pax exam also provides a way to provision configs that is independent of karaf:
This approach does not change config files and instead directly creates the config in ConfigurationAdmin.
See https://github.com/ops4j/org.ops4j.pax.exam2/blob/master/itest/osgi/src/it/regression-multi/src/test/java/org/ops4j/pax/exam/regression/multi/cm/ConfigurationOptionTest.java#L61-L63