new DefaultOption<Integer>(400, Predicates.<Integer>or(
range(50, MAX_VALUE), equalTo(-1)));
private final Option<Integer> postCutOffLength =
- new DefaultOption<Integer>(200, Predicates.<Integer>or(
- range(50, MAX_VALUE), equalTo(-1)));
+ new DefaultOption<Integer>(200, range(50, MAX_VALUE));
private final Option<Boolean> requireFullAccess =
new DefaultOption<Boolean>(false);
private final Option<Integer> positiveTrust =
}
private void loadPostCutOffLength(Configuration configuration) {
- preferences.setPostCutOffLength(
- configuration.getIntValue("Option/PostCutOffLength")
- .getValue(null));
+ try {
+ preferences.setPostCutOffLength(
+ configuration.getIntValue("Option/PostCutOffLength")
+ .getValue(null));
+ } catch (IllegalArgumentException iae1) {
+ /* previous versions allowed -1, ignore and use default. */
+ }
}
private void loadRequireFullAccess(Configuration configuration) {
import static net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired.WRITING;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
assertThat(preferences.getFcpFullAccessRequired(), is(WRITING));
}
+ @Test
+ public void configurationIsLoadedCorrectlyWithCutOffLengthMinusOne() {
+ setupConfiguration();
+ setupIntValue("PostCutOffLength", -1);
+ preferencesLoader.loadFrom(configuration);
+ assertThat(preferences.getPostCutOffLength(), not(is(-1)));
+ }
+
}
preferences.setPostCutOffLength(-15);
}
+ @Test(expected = IllegalArgumentException.class)
+ public void cutOffLengthOfMinusOneIsNotAllowed() {
+ preferences.setPostCutOffLength(-1);
+ }
+
@Test
public void preferencesReturnDefaultValueWhenPostCutOffLengthIsSetToNull() {
preferences.setPostCutOffLength(null);