|
18 | 18 |
|
19 | 19 | import java.io.File;
|
20 | 20 | import java.io.IOException;
|
| 21 | +import java.lang.reflect.Constructor; |
21 | 22 | import java.net.URI;
|
22 | 23 | import java.nio.file.Files;
|
23 | 24 | import java.nio.file.Path;
|
|
41 | 42 | import org.junit.jupiter.api.extension.ParameterResolver;
|
42 | 43 | import org.junit.jupiter.api.extension.TestTemplateInvocationContext;
|
43 | 44 | import org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider;
|
44 |
| -import org.junit.platform.commons.util.ReflectionUtils; |
45 | 45 |
|
| 46 | +import org.springframework.beans.BeanUtils; |
46 | 47 | import org.springframework.boot.testsupport.BuildOutput;
|
47 | 48 | import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
48 | 49 | import org.springframework.util.FileSystemUtils;
|
| 50 | +import org.springframework.util.ReflectionUtils; |
49 | 51 | import org.springframework.util.StringUtils;
|
50 | 52 | import org.springframework.web.client.NoOpResponseErrorHandler;
|
51 | 53 | import org.springframework.web.client.RestTemplate;
|
@@ -119,10 +121,17 @@ private AbstractApplicationLauncher getAbstractApplicationLauncher(Application a
|
119 | 121 | if (cachedLauncher != null) {
|
120 | 122 | return cachedLauncher;
|
121 | 123 | }
|
122 |
| - AbstractApplicationLauncher launcher = ReflectionUtils.newInstance(launcherClass, application, |
123 |
| - new File(buildOutput.getRootLocation(), "app-launcher-" + UUID.randomUUID())); |
124 |
| - this.launcherCache.put(cacheKey, launcher); |
125 |
| - return launcher; |
| 124 | + try { |
| 125 | + Constructor<? extends AbstractApplicationLauncher> constructor = ReflectionUtils |
| 126 | + .accessibleConstructor(launcherClass, Application.class, File.class); |
| 127 | + AbstractApplicationLauncher launcher = BeanUtils.instantiateClass(constructor, application, |
| 128 | + new File(buildOutput.getRootLocation(), "app-launcher-" + UUID.randomUUID())); |
| 129 | + this.launcherCache.put(cacheKey, launcher); |
| 130 | + return launcher; |
| 131 | + } |
| 132 | + catch (NoSuchMethodException ex) { |
| 133 | + throw new IllegalStateException("Launcher class %s does not have an (Application, File) constructor"); |
| 134 | + } |
126 | 135 | }
|
127 | 136 |
|
128 | 137 | private Application getApplication(EmbeddedServletContainerTest annotation, String container) {
|
|
0 commit comments