Reputation: 2297
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?
Upvotes: 0
Views: 158
Reputation: 19626
The KarafTestSupport class contains some examples for providing configs:
KarafDistributionOption.replaceConfigurationFile("etc/org.ops4j.pax.logging.cfg", getConfigFile("/etc/org.ops4j.pax.logging.cfg"))
This is suitable for bigger configs that you provide in src/test/resources.
KarafDistributionOption.editConfigurationFilePut("etc/org.apache.karaf.shell.cfg", "sshPort", sshPort)
Using this you can replace individual properties in configs.
Pax exam also provides a way to provision configs that is independent of karaf:
ConfigurationAdminOptions.newConfiguration(TEST_PID)
.put(TEST_KEY, TEST_PROPERTY)
.asOption(),
This approach does not change config files and instead directly creates the config in ConfigurationAdmin.
Upvotes: 0