You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use both archaius & Jukito in our platform, and found that this commit broke our tests.
The symptom is that if you use a Config in one test, then all subsequent tests won't have their Config updated:
This test will pass:
@RunWith(JukitoRunner.class)
@UseModules(Module.class)
public class HangingReferenceTest {
public static class Module extends AbstractModule {
@Override
protected void configure() {
install(new ArchaiusModule() {
@Override
protected void configureArchaius() {
Map<String, String> configurationValues = new HashMap<>();
configurationValues.put("value1", "one");
bindDefaultConfig().toInstance(MapConfig.from(configurationValues));
}
});
}
}
@Inject
Provider<Config> configProvider;
@Test
public void testConfig() {
assertThat(configProvider.get().getString("value1"), is("one"));
}
}
But this test will fail, and if you look through the values of the Config, it just has "value1":
@RunWith(JukitoRunner.class)
@UseModules(Module.class)
public class HangingReference2Test {
public static class Module extends AbstractModule {
@Override
protected void configure() {
install(new ArchaiusModule() {
@Override
protected void configureArchaius() {
Map<String, String> configurationValues = new HashMap<>();
configurationValues.put("value2", "two");
bindDefaultConfig().toInstance(MapConfig.from(configurationValues));
}
});
}
}
@Inject
Provider<Config> configProvider;
@Test
public void testConfig() {
assertThat(configProvider.get().getString("value2"), is("two"));
}
}
The 'fix' (more on why that's in quotes in a sec), is to change ConfigurationInjectingListener so that the injected Config is injected via a Provider:
public class ConfigurationInjectingListener implements ProvisionListener {
private static final Logger LOG = LoggerFactory.getLogger(ConfigurationInjectingListener.class);
@Inject
private Provider<Config> config;
...
I've been taking Jukito apart this afternoon and narrowed the problem with it down to the way inspects the bindings to identify missing bindings. I'm still not completely sure what's going on, but I'll keep digging.
However, the fact that it's happening with Jukito means it might also happen with others, so wanted to pass this back to you.
The problem I'm having is that I don't feel comfortable just submitting a PR with the above change and no UT. But I can't reproduce it without either adding a test-dependency to Jukito or more-or-less pulling a chunk of Jukito into the test classes.
So... Some sort of steer would be appreciated.
Ta.
The text was updated successfully, but these errors were encountered:
Hi,
We use both archaius & Jukito in our platform, and found that this commit broke our tests.
The symptom is that if you use a
Config
in one test, then all subsequent tests won't have theirConfig
updated:This test will pass:
But this test will fail, and if you look through the values of the
Config
, it just has "value1":The 'fix' (more on why that's in quotes in a sec), is to change
ConfigurationInjectingListener
so that the injectedConfig
is injected via aProvider
:I've been taking Jukito apart this afternoon and narrowed the problem with it down to the way inspects the bindings to identify missing bindings. I'm still not completely sure what's going on, but I'll keep digging.
However, the fact that it's happening with Jukito means it might also happen with others, so wanted to pass this back to you.
The problem I'm having is that I don't feel comfortable just submitting a PR with the above change and no UT. But I can't reproduce it without either adding a test-dependency to Jukito or more-or-less pulling a chunk of Jukito into the test classes.
So... Some sort of steer would be appreciated.
Ta.
The text was updated successfully, but these errors were encountered: