public void testOverrideConfig() throws Exception {
final String pid = getClass().getSimpleName() + "." + System.currentTimeMillis();
final Dictionary<String, Object> data = new Hashtable<String, Object>();
data.put("foo", "a");
final InstallableResource a = getInstallableResource("a/" + pid, data, InstallableResource.DEFAULT_PRIORITY - 1)[0];
data.put("foo", "b");
final InstallableResource b = getInstallableResource("b/" + pid, data, InstallableResource.DEFAULT_PRIORITY)[0];
data.put("foo", "c");
final InstallableResource c = getInstallableResource("c/" + pid, data, InstallableResource.DEFAULT_PRIORITY + 1)[0];
// c has more priority than b which has more than a
installer.updateResources(URL_SCHEME, new InstallableResource[] {b}, null);
assertConfigValue(pid, "foo", "b", TIMEOUT);
installer.updateResources(URL_SCHEME, new InstallableResource[] {c}, null);
assertConfigValue(pid, "foo", "c", TIMEOUT);
installer.updateResources(URL_SCHEME, new InstallableResource[] {a}, null);
// highest prio should be active (c)
assertConfigValue(pid, "foo", "c", TIMEOUT);
// removing c, second highest prio should be active (b)
installer.updateResources(URL_SCHEME, null, new String[] {c.getId()});
assertConfigValue(pid, "foo", "b", TIMEOUT);
// removing b, a should be active
installer.updateResources(URL_SCHEME, null, new String[] {b.getId()});
assertConfigValue(pid, "foo", "a", TIMEOUT);