Not like this

  • Download Gist
BaseKarafDefaultFrameworkDuplicatedPropertyEntryFromFileTest.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
@Test
public void testConfiguration_shouldHaveWrittenTheLaterOne() throws Exception {
ServiceReference[] allServiceReferences = ctx.getAllServiceReferences(ConfigurationAdmin.class.getName(), null);
for (ServiceReference serviceReference : allServiceReferences) {
ConfigurationAdmin service = (ConfigurationAdmin) ctx.getService(serviceReference);
try {
org.osgi.service.cm.Configuration configuration = service.getConfiguration("tests");
assertEquals("myvalue2", configuration.getProperties().get("mykey"));
return;
} catch (Exception e) {
// continue
}
}
fail();
}

I like it when the code is both functional and self-critiquing.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.