forked from junit-team/junit5
-
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.
Implement legacy for ParameterResolver and InvocationInterceptor
Issue: junit-team#3445
- Loading branch information
1 parent
2744efb
commit b92393c
Showing
15 changed files
with
142 additions
and
87 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
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
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
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
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
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
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
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
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
47 changes: 47 additions & 0 deletions
47
...ter-engine/src/main/java/org/junit/jupiter/engine/execution/ExtensionContextSupplier.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,47 @@ | ||
/* | ||
* Copyright 2015-2024 the original author or authors. | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License v2.0 which | ||
* accompanies this distribution and is available at | ||
* | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
*/ | ||
|
||
package org.junit.jupiter.engine.execution; | ||
|
||
import static org.apiguardian.api.API.Status.INTERNAL; | ||
|
||
import org.apiguardian.api.API; | ||
import org.junit.jupiter.api.extension.EnableTestScopedConstructorContext; | ||
import org.junit.jupiter.api.extension.Extension; | ||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
import org.junit.platform.commons.util.AnnotationUtils; | ||
|
||
/** | ||
* Container of two instances of {@link ExtensionContext} to simplify the legacy for | ||
* <a href="https://github.com/junit-team/junit5/issues/3445">#3445 (Introduction of Test-scoped ExtensionContext)</a>. | ||
* | ||
* @since 5.12 | ||
*/ | ||
@API(status = INTERNAL, since = "5.12") | ||
public final class ExtensionContextSupplier { | ||
|
||
private final ExtensionContext currentExtensionContext; | ||
private final ExtensionContext legacyExtensionContext; | ||
|
||
public ExtensionContextSupplier(ExtensionContext currentExtensionContext, ExtensionContext legacyExtensionContext) { | ||
this.currentExtensionContext = currentExtensionContext; | ||
this.legacyExtensionContext = legacyExtensionContext; | ||
} | ||
|
||
public ExtensionContext get(Extension extension) { | ||
if (currentExtensionContext == legacyExtensionContext | ||
|| AnnotationUtils.isAnnotated(extension.getClass(), EnableTestScopedConstructorContext.class)) { | ||
return currentExtensionContext; | ||
} | ||
else { | ||
return legacyExtensionContext; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.