-
Notifications
You must be signed in to change notification settings - Fork 429
OAK-12298: SystemPropertySupplier: allow to signal that property is not present (implies default value) #3003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
a5f2749
2763720
d228309
d575560
1ab1bb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
| package org.apache.jackrabbit.oak.commons.properties; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertNull; | ||
| import static org.junit.Assert.assertTrue; | ||
|
|
||
| import org.apache.jackrabbit.oak.commons.junit.LogCustomizer; | ||
|
|
@@ -137,4 +138,38 @@ public void testUnsupportedType() { | |
| } catch (IllegalArgumentException expected) { | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testCheckNullDefault() { | ||
| try { | ||
| assertNull(SystemPropertySupplier.create("foo", Boolean.class). | ||
| usingSystemPropertyReader((n) -> null).get()); | ||
| } catch (IllegalArgumentException expected) { | ||
|
Comment on lines
+144
to
+147
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would re-write this test to use
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After your previous comment will be addressed, which I support, this test will drop anyway. |
||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testCheckNoDefaultNotSet() { | ||
| assertNull(SystemPropertySupplier.create("foo", Boolean.class). | ||
| usingSystemPropertyReader((n) -> null).get()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testCheckNoDefaultSet() { | ||
| int value = SystemPropertySupplier.create("foo", Integer.class). | ||
| usingSystemPropertyReader((n) -> "4217").get(); | ||
| assertEquals(4217, value); | ||
| } | ||
|
|
||
| @Test | ||
| public void testCheckNoDefaultSetInvalid() { | ||
| assertNull(SystemPropertySupplier.create("foo", Integer.class). | ||
| usingSystemPropertyReader((n) -> "abcd").get()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testCheckNoDefaultValidatorRejects() { | ||
| assertNull(SystemPropertySupplier.create("foo", String.class). | ||
| usingSystemPropertyReader((n) -> "abcd").validateWith(x-> false) .get()); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #2995, we are removing this exception, so I would avoid changing this method.