-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…lified class name (short name clashes)
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
blackbox-test-inject/src/main/java/org/example/myapp/config/DupShortNameFactory.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,25 @@ | ||
package org.example.myapp.config; | ||
|
||
import io.avaje.inject.Bean; | ||
import io.avaje.inject.Factory; | ||
|
||
@Factory | ||
public class DupShortNameFactory { | ||
|
||
@Bean | ||
MyDup one() { | ||
return new MyDup(); | ||
} | ||
|
||
/** | ||
* Requires fully qualified name as short name of MyDup clashes. | ||
*/ | ||
@Bean | ||
org.example.myapp.config.MyDup two() { | ||
return new org.example.myapp.config.MyDup(); | ||
} | ||
|
||
public static class MyDup { | ||
|
||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
blackbox-test-inject/src/main/java/org/example/myapp/config/MyDup.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,4 @@ | ||
package org.example.myapp.config; | ||
|
||
public class MyDup { | ||
} |
23 changes: 23 additions & 0 deletions
23
blackbox-test-inject/src/test/java/org/example/myapp/config/DupShortNameFactoryTest.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,23 @@ | ||
package org.example.myapp.config; | ||
|
||
import io.avaje.inject.BeanScope; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class DupShortNameFactoryTest { | ||
|
||
@Test | ||
void factoryBeanRequiringFullyQualifiedName() { | ||
try (BeanScope testScope = BeanScope.builder().build()) { | ||
// both have short name of MyDup | ||
var one = testScope.get(org.example.myapp.config.MyDup.class); | ||
var two = testScope.get(DupShortNameFactory.MyDup.class); | ||
|
||
assertNotNull(one); | ||
assertNotNull(two); | ||
assertThat(one).isNotSameAs(two); | ||
} | ||
} | ||
} |