Hi Steinar, for my Pax Exam Karaf tests, I am using a builder-style class I wrote called KarafConfigurator for building the list of configuration options.
It has methods for replacing bundled config files with user supplied versions. Here's an example using startup.properties: public KarafConfigurator replaceStartupProperties(final URL newStartupProperties) throws URISyntaxException { return replaceConfigurationFile(STARTUP_PROPERTIES_FILE_PATH, newStartupProperties); } public KarafConfigurator replaceConfigurationFile(final String path, final URL newConfigurationFileUrl) throws URISyntaxException { final File newConfigurationFile = new File(newConfigurationFileUrl.toURI()); return replaceConfigurationFile(path, newConfigurationFile); } public KarafConfigurator replaceConfigurationFile(final String path, final File newConfigurationFile) { final Option optionReplaceConfFile = KarafDistributionOption.replaceConfigurationFile(path, newConfigurationFile); options.add(optionReplaceConfFile); return this; } STARTUP_PROPERTIES_FILE_PATH denotes the path inside the Karaf distro to the startup.properties-file. It's defined as: private static final String STARTUP_PROPERTIES_FILE_PATH = "etc/startup.properties"; Notice it's doesn't start with "/" The user of KarafConfigurator-class would simply call the replaceStartupProperties()-method. A URL to a replacement-file in src/test/resources can be obtained simply: final Class<?> clz = getClass(); final URL resourceUrl = clz.getResource("/startup.properties"); Here it's assumed the file is the user wants to use as a replacement is called "startup.properties" and is located in src/test/resources (assuming Maven) - Eric L On Sun, May 23, 2021 at 11:42 AM Steinar Bang <s...@dod.no> wrote: > >>>>> Steinar Bang <s...@dod.no>: > > >> A simple workaround is to include your own users.properties in the > pax-exam option. > > > Thanks! I will look into this. > > I tried this: > @Configuration > public Option[] config() { > final MavenArtifactUrlReference authserviceFeatureRepo = maven() > .groupId("no.priv.bang.authservice") > .artifactId("karaf") > .version("LATEST") > .type("xml") > .classifier("features"); > File dummyUsersProperties = new > File(getClass().getClassLoader().getResource("dummy.users.properties").getFile()); > Option[] options = new Option[] { > features(authserviceFeatureRepo), > replaceConfigurationFile("/etc/users.properties", > dummyUsersProperties) > }; > return Stream.of(super.config(), > options).flatMap(Stream::of).toArray(Option[]::new); > } > > But the test still fails almost immediately with > org.ops4j.pax.exam.TestContainerException: java.lang.RuntimeException: > Config resource /etc/users.properties not found > > I've tried "users.properties" and "etc/users.properties" as the > configurationFilePath argument to replaceConfigurationFile(), but it > didn't make any difference. > >