-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ArC bean resolution - handle qualifier default values correctly
- Loading branch information
Showing
6 changed files
with
86 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...projects/arc/tests/src/test/java/io/quarkus/arc/test/qualifiers/defaultvalues/Animal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.quarkus.arc.test.qualifiers.defaultvalues; | ||
|
||
public interface Animal { | ||
|
||
int noOfLeg(); | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
...arc/tests/src/test/java/io/quarkus/arc/test/qualifiers/defaultvalues/AnimalQualifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.quarkus.arc.test.qualifiers.defaultvalues; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
import javax.inject.Qualifier; | ||
|
||
@Qualifier | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.TYPE }) | ||
public @interface AnimalQualifier { | ||
|
||
String value() default ""; | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...nt-projects/arc/tests/src/test/java/io/quarkus/arc/test/qualifiers/defaultvalues/Cat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package io.quarkus.arc.test.qualifiers.defaultvalues; | ||
|
||
import javax.enterprise.context.Dependent; | ||
|
||
@Dependent | ||
@AnimalQualifier("cat") | ||
public class Cat implements Animal { | ||
|
||
@Override | ||
public int noOfLeg() { | ||
return 4; | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...nt-projects/arc/tests/src/test/java/io/quarkus/arc/test/qualifiers/defaultvalues/Owl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package io.quarkus.arc.test.qualifiers.defaultvalues; | ||
|
||
import javax.enterprise.context.Dependent; | ||
|
||
@Dependent | ||
@AnimalQualifier | ||
public class Owl implements Animal { | ||
|
||
@Override | ||
public int noOfLeg() { | ||
return 2; | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
...rc/test/java/io/quarkus/arc/test/qualifiers/defaultvalues/QualifierDefaultValuesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.quarkus.arc.test.qualifiers.defaultvalues; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import io.quarkus.arc.Arc; | ||
import io.quarkus.arc.test.ArcTestContainer; | ||
import javax.enterprise.context.Dependent; | ||
import javax.inject.Inject; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
public class QualifierDefaultValuesTest { | ||
|
||
@RegisterExtension | ||
public ArcTestContainer container = new ArcTestContainer(Consumer.class, Animal.class, AnimalQualifier.class, Cat.class, | ||
Owl.class); | ||
|
||
@Test | ||
public void testDefaultValues() { | ||
Consumer consumer = Arc.container().instance(Consumer.class).get(); | ||
assertEquals(2, consumer.animal.noOfLeg()); | ||
} | ||
|
||
@Dependent | ||
public static class Consumer { | ||
|
||
@Inject | ||
@AnimalQualifier | ||
Animal animal; | ||
|
||
} | ||
|
||
} |