[java] Fixing unit tests for Preferences that check setting frozen preferences
@@ -107,9 +107,10 @@ public void parsePreferences_multiline() {
public void cannotOverrideAFozenPrefence() {
StringReader reader = new StringReader("{\"frozen\": {\"frozen.pref\": true }, \"mutable\": {}}");
Preferences preferences = new Preferences(reader);
+ preferences.setPreference("frozen.pref", false);
- assertThatExceptionOfType(IllegalArgumentException.class)
- .isThrownBy(() -> preferences.setPreference("frozen.pref", false))
+ assertThatExceptionOfType(IllegalStateException.class)
+ .isThrownBy(preferences::checkForChangesInFrozenPreferences)
.withMessage("Preference frozen.pref may not be overridden: frozen value=true, requested value=false");
}
@@ -126,9 +127,10 @@ public void canOverrideAFrozenPreferenceWithTheFrozenValue() {
@Test
public void canOverrideMaxScriptRuntimeIfGreaterThanDefaultValueOrSetToInfinity() {
Preferences preferences = new Preferences(defaults);
+ preferences.setPreference("dom.max_script_run_time", 29);
- assertThatExceptionOfType(IllegalArgumentException.class)
- .isThrownBy(() -> preferences.setPreference("dom.max_script_run_time", 29))
+ assertThatExceptionOfType(IllegalStateException.class)
+ .isThrownBy(preferences::checkForChangesInFrozenPreferences)
.withMessage("dom.max_script_run_time must be == 0 || >= 30");
preferences.setPreference("dom.max_script_run_time", 31);
