Skip to content

Commit f4ed6be

Browse files
committed
Initialise always as GlobalTestScope.Pair
1 parent 4fe5b9a commit f4ed6be

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

inject-test/src/main/java/io/avaje/inject/test/GlobalTestScope.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Pair obtain(ExtensionContext context) {
3434
}
3535

3636
private void initialise(ExtensionContext context) {
37-
globalBeanScope = TSBuild.initialise();
37+
globalBeanScope = TSBuild.initialise(false);
3838
log.log(TRACE, "register global test BeanScope with beans {0}", globalBeanScope);
3939
context.getRoot().getStore(ExtensionContext.Namespace.GLOBAL).put(InjectExtension.class.getCanonicalName(), this);
4040
}

inject-test/src/main/java/io/avaje/inject/test/TSBuild.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
final class TSBuild {
2222

2323
private static final ReentrantLock lock = new ReentrantLock();
24-
private static BeanScope SCOPE;
24+
private static GlobalTestScope.Pair SCOPE;
2525

2626
private final boolean shutdownHook;
2727

@@ -37,12 +37,11 @@ static BeanScope createTestBaseScope(boolean shutdownHook) {
3737
/**
3838
* Return the test BeanScope only creating once.
3939
*/
40-
@Nullable
41-
static BeanScope initialise(boolean shutdownHook) {
40+
static GlobalTestScope.Pair initialise(boolean shutdownHook) {
4241
lock.lock();
4342
try {
4443
if (SCOPE == null) {
45-
SCOPE = createTestBaseScope(shutdownHook);
44+
SCOPE = createScopes(shutdownHook);
4645
}
4746
return SCOPE;
4847
} finally {
@@ -54,8 +53,8 @@ static BeanScope initialise(boolean shutdownHook) {
5453
this.shutdownHook = shutdownHook;
5554
}
5655

57-
static GlobalTestScope.Pair initialise() {
58-
BeanScope testBaseScope = createTestBaseScope(false);
56+
private static GlobalTestScope.Pair createScopes(boolean shutdownHook) {
57+
BeanScope testBaseScope = createTestBaseScope(shutdownHook);
5958
BeanScope testAllScope = createTestAllScope(testBaseScope);
6059
return new GlobalTestScope.Pair(testAllScope, testBaseScope);
6160
}

inject-test/src/main/java/io/avaje/inject/test/TestBeanScope.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public abstract class TestBeanScope {
3838
* @return A new test BeanScope with the global "test scope" as its parent.
3939
*/
4040
public static BeanScopeBuilder builder() {
41-
BeanScope globalTestScope = init(true);
42-
return BeanScope.builder().parent(globalTestScope, false);
41+
BeanScope baseTestScope = init(true);
42+
return BeanScope.builder().parent(baseTestScope, false);
4343
}
4444

4545
/**
@@ -79,7 +79,7 @@ public static BeanScope create(boolean shutdownHook) {
7979

8080
@Nullable
8181
static BeanScope init(boolean shutdownHook) {
82-
return TSBuild.initialise(shutdownHook);
82+
return TSBuild.initialise(shutdownHook).baseScope();
8383
}
8484

8585
}

0 commit comments

Comments
 (0)