|
3 | 3 | import java.io.IOException; |
4 | 4 | import java.io.InputStream; |
5 | 5 | import java.io.UncheckedIOException; |
| 6 | +import java.lang.reflect.Constructor; |
6 | 7 | import java.nio.charset.StandardCharsets; |
7 | 8 | import java.nio.file.Files; |
8 | 9 | import java.nio.file.OpenOption; |
|
38 | 39 | import org.junit.jupiter.api.extension.BeforeAllCallback; |
39 | 40 | import org.junit.jupiter.api.extension.BeforeEachCallback; |
40 | 41 | import org.junit.jupiter.api.extension.ExtensionContext; |
41 | | -import org.junit.jupiter.api.extension.TestInstanceFactory; |
42 | | -import org.junit.jupiter.api.extension.TestInstanceFactoryContext; |
43 | | -import org.junit.jupiter.api.extension.TestInstantiationException; |
| 42 | +import org.junit.jupiter.api.extension.InvocationInterceptor; |
| 43 | +import org.junit.jupiter.api.extension.ReflectiveInvocationContext; |
44 | 44 |
|
45 | 45 | import io.quarkus.bootstrap.BootstrapAppModelFactory; |
46 | 46 | import io.quarkus.bootstrap.BootstrapException; |
|
88 | 88 | * </ul> |
89 | 89 | */ |
90 | 90 | public class QuarkusDevModeTest |
91 | | - implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback, TestInstanceFactory { |
| 91 | + implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback, InvocationInterceptor { |
92 | 92 |
|
93 | 93 | private static final Logger rootLogger; |
94 | 94 | public static final OpenOption[] OPEN_OPTIONS = { StandardOpenOption.SYNC, StandardOpenOption.CREATE, |
@@ -224,15 +224,13 @@ public QuarkusDevModeTest setBuildSystemProperty(String name, String value) { |
224 | 224 | return this; |
225 | 225 | } |
226 | 226 |
|
227 | | - public Object createTestInstance(TestInstanceFactoryContext factoryContext, ExtensionContext extensionContext) |
228 | | - throws TestInstantiationException { |
229 | | - try { |
230 | | - Object actualTestInstance = factoryContext.getTestClass().getDeclaredConstructor().newInstance(); |
231 | | - TestHTTPResourceManager.inject(actualTestInstance); |
232 | | - return actualTestInstance; |
233 | | - } catch (Exception e) { |
234 | | - throw new TestInstantiationException("Unable to create test proxy", e); |
235 | | - } |
| 227 | + @Override |
| 228 | + public <T> T interceptTestClassConstructor(Invocation<T> invocation, |
| 229 | + ReflectiveInvocationContext<Constructor<T>> invocationContext, |
| 230 | + ExtensionContext extensionContext) throws Throwable { |
| 231 | + T actualTestInstance = invocation.proceed(); |
| 232 | + TestHTTPResourceManager.inject(actualTestInstance); |
| 233 | + return actualTestInstance; |
236 | 234 | } |
237 | 235 |
|
238 | 236 | @Override |
|
0 commit comments