Skip to content

Commit

Permalink
Merge pull request #19398 from radcortez/fix-19387
Browse files Browse the repository at this point in the history
Added test for @ConfigMapping constructor injection
  • Loading branch information
gsmet authored Aug 17, 2021
2 parents 6ccbef7 + e4d3633 commit 9828fa8
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.OptionalInt;
import java.util.stream.Stream;

import javax.enterprise.context.Dependent;
import javax.inject.Inject;

import org.eclipse.microprofile.config.Config;
Expand Down Expand Up @@ -350,4 +351,25 @@ void hierarchy() {
assertEquals("bar", extendsBase.foo());
}

@Dependent
public static class ConstructorInjection {
private String myProp;

@Inject
public ConstructorInjection(@ConfigMapping(prefix = "config") MyConfigMapping myConfigMapping) {
this.myProp = myConfigMapping.myProp();
}

public String getMyProp() {
return myProp;
}
}

@Inject
ConstructorInjection constructorInjection;

@Test
void constructorInjection() {
assertEquals("1234", constructorInjection.getMyProp());
}
}

0 comments on commit 9828fa8

Please sign in to comment.