forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ArC: fix treatment of injection points with @nAmed without value
The specification is clear that field injection points with `@Named` without value should use `@Named(fieldName)` as the qualifier. Other such injection points lead to a definition error.
- Loading branch information
Showing
3 changed files
with
85 additions
and
3 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
43 changes: 43 additions & 0 deletions
43
...ects/arc/tests/src/test/java/io/quarkus/arc/test/name/InvalidNamedInjectionPointTest.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,43 @@ | ||
package io.quarkus.arc.test.name; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertInstanceOf; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import javax.enterprise.context.Dependent; | ||
import javax.enterprise.inject.spi.DefinitionException; | ||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.arc.test.ArcTestContainer; | ||
|
||
public class InvalidNamedInjectionPointTest { | ||
|
||
@RegisterExtension | ||
public ArcTestContainer container = ArcTestContainer.builder() | ||
.beanClasses(Foo.class, Consumer.class) | ||
.shouldFail() | ||
.build(); | ||
|
||
@Test | ||
public void test() { | ||
assertNotNull(container.getFailure()); | ||
assertInstanceOf(DefinitionException.class, container.getFailure()); | ||
assertTrue(container.getFailure().getMessage().contains("@Named without value may not be used on method parameter")); | ||
} | ||
|
||
@Named("foo") | ||
@Dependent | ||
static class Foo { | ||
} | ||
|
||
@Dependent | ||
static class Consumer { | ||
@Inject | ||
Consumer(@Named Foo foo) { | ||
} | ||
} | ||
} |
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