Skip to content

Commit

Permalink
add assertion for defaultValue
Browse files Browse the repository at this point in the history
Assert that an injected property that is not configured in any config
source will use the defaultValue from the annotation.

Signed-off-by: Jeff Mesnil <jmesnil@gmail.com>
  • Loading branch information
jmesnil committed Apr 19, 2017
1 parent 0556992 commit e13f399
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public void can_inject_simple_values_when_defined() {
assertThat(bean.longProperty, is(equalTo(10L)));
assertThat(bean.floatProperty, is(floatCloseTo(10.5f, 0.1f)));
assertThat(bean.doubleProperty, is(closeTo(11.5, 0.1)));
assertThat(bean.doublePropertyWithDefaultValue, is(closeTo(3.1415, 0.1)));
}

@Test
Expand Down Expand Up @@ -131,6 +132,12 @@ public static class SimpleValuesBean {
@ConfigProperty(name="my.double.property")
private Double doubleProperty;

// the property is not configured in any ConfigSource but its defaultValue will
// be used to set the field.
@Inject
@ConfigProperty(name="my.not.configured.double.property", defaultValue = "3.1415")
private Double doublePropertyWithDefaultValue;

}

@Dependent
Expand Down

0 comments on commit e13f399

Please sign in to comment.