Merge branch '2.7.x' into 3.0.x
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,7 +25,7 @@ public class DevToolsTestApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new SpringApplicationBuilder(DevToolsTestApplication.class).listeners(new WebServerPortFileWriter(args[0]))
|
||||
.run(args);
|
||||
.run(args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -66,9 +66,9 @@ abstract class AbstractDevToolsIntegrationTests {
|
||||
|
||||
protected int awaitServerPort() throws Exception {
|
||||
int port = Awaitility.waitAtMost(Duration.ofMinutes(3))
|
||||
.until(() -> new ApplicationState(this.serverPortFile, this.launchedApplication),
|
||||
ApplicationState::hasServerPort)
|
||||
.getServerPort();
|
||||
.until(() -> new ApplicationState(this.serverPortFile, this.launchedApplication),
|
||||
ApplicationState::hasServerPort)
|
||||
.getServerPort();
|
||||
this.serverPortFile.delete();
|
||||
this.launchedApplication.restartRemote(port);
|
||||
Thread.sleep(1000);
|
||||
@@ -98,12 +98,15 @@ abstract class AbstractDevToolsIntegrationTests {
|
||||
}
|
||||
|
||||
protected void build() throws Exception {
|
||||
DynamicType.Builder<Object> builder = new ByteBuddy().subclass(Object.class).name(this.name)
|
||||
.annotateType(AnnotationDescription.Builder.ofType(RestController.class).build());
|
||||
DynamicType.Builder<Object> builder = new ByteBuddy().subclass(Object.class)
|
||||
.name(this.name)
|
||||
.annotateType(AnnotationDescription.Builder.ofType(RestController.class).build());
|
||||
for (String mapping : this.mappings) {
|
||||
builder = builder.defineMethod(mapping, String.class, Visibility.PUBLIC)
|
||||
.intercept(FixedValue.value(mapping)).annotateMethod(AnnotationDescription.Builder
|
||||
.ofType(RequestMapping.class).defineArray("value", mapping).build());
|
||||
.intercept(FixedValue.value(mapping))
|
||||
.annotateMethod(AnnotationDescription.Builder.ofType(RequestMapping.class)
|
||||
.defineArray("value", mapping)
|
||||
.build());
|
||||
}
|
||||
builder.make().saveIn(this.classesDirectory);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,9 +40,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class DevToolsIntegrationTests extends AbstractDevToolsIntegrationTests {
|
||||
|
||||
private final TestRestTemplate template = new TestRestTemplate(new RestTemplateBuilder()
|
||||
.requestFactory(() -> new HttpComponentsClientHttpRequestFactory(HttpClients.custom()
|
||||
.setRetryStrategy(new DefaultHttpRequestRetryStrategy(10, TimeValue.of(1, TimeUnit.SECONDS)))
|
||||
.build())));
|
||||
.requestFactory(() -> new HttpComponentsClientHttpRequestFactory(HttpClients.custom()
|
||||
.setRetryStrategy(new DefaultHttpRequestRetryStrategy(10, TimeValue.of(1, TimeUnit.SECONDS)))
|
||||
.build())));
|
||||
|
||||
@ParameterizedTest(name = "{0}")
|
||||
@MethodSource("parameters")
|
||||
@@ -51,7 +51,7 @@ class DevToolsIntegrationTests extends AbstractDevToolsIntegrationTests {
|
||||
String urlBase = "http://localhost:" + awaitServerPort();
|
||||
assertThat(this.template.getForObject(urlBase + "/one", String.class)).isEqualTo("one");
|
||||
assertThat(this.template.getForEntity(urlBase + "/two", String.class).getStatusCode())
|
||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||
controller("com.example.ControllerOne").withRequestMapping("one").withRequestMapping("two").build();
|
||||
urlBase = "http://localhost:" + awaitServerPort();
|
||||
assertThat(this.template.getForObject(urlBase + "/one", String.class)).isEqualTo("one");
|
||||
@@ -67,7 +67,7 @@ class DevToolsIntegrationTests extends AbstractDevToolsIntegrationTests {
|
||||
controller("com.example.ControllerOne").build();
|
||||
urlBase = "http://localhost:" + awaitServerPort();
|
||||
assertThat(this.template.getForEntity(urlBase + "/one", String.class).getStatusCode())
|
||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "{0}")
|
||||
@@ -77,7 +77,7 @@ class DevToolsIntegrationTests extends AbstractDevToolsIntegrationTests {
|
||||
String urlBase = "http://localhost:" + awaitServerPort();
|
||||
assertThat(this.template.getForObject(urlBase + "/one", String.class)).isEqualTo("one");
|
||||
assertThat(this.template.getForEntity(urlBase + "/two", String.class).getStatusCode())
|
||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||
controller("com.example.ControllerTwo").withRequestMapping("two").build();
|
||||
urlBase = "http://localhost:" + awaitServerPort();
|
||||
assertThat(this.template.getForObject(urlBase + "/one", String.class)).isEqualTo("one");
|
||||
@@ -92,7 +92,7 @@ class DevToolsIntegrationTests extends AbstractDevToolsIntegrationTests {
|
||||
String urlBase = "http://localhost:" + awaitServerPort();
|
||||
assertThat(this.template.getForObject(urlBase + "/one", String.class)).isEqualTo("one");
|
||||
assertThat(this.template.getForEntity(urlBase + "/two", String.class).getStatusCode())
|
||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||
controller("com.example.ControllerTwo").withRequestMapping("two").build();
|
||||
urlBase = "http://localhost:" + awaitServerPort();
|
||||
assertThat(this.template.getForObject(urlBase + "/one", String.class)).isEqualTo("one");
|
||||
@@ -110,7 +110,7 @@ class DevToolsIntegrationTests extends AbstractDevToolsIntegrationTests {
|
||||
String urlBase = "http://localhost:" + awaitServerPort();
|
||||
assertThat(this.template.getForObject(urlBase + "/one", String.class)).isEqualTo("one");
|
||||
assertThat(this.template.getForEntity(urlBase + "/two", String.class).getStatusCode())
|
||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||
controller("com.example.ControllerTwo").withRequestMapping("two").build();
|
||||
urlBase = "http://localhost:" + awaitServerPort();
|
||||
assertThat(this.template.getForObject(urlBase + "/one", String.class)).isEqualTo("one");
|
||||
@@ -129,10 +129,10 @@ class DevToolsIntegrationTests extends AbstractDevToolsIntegrationTests {
|
||||
String urlBase = "http://localhost:" + awaitServerPort();
|
||||
assertThat(this.template.getForObject(urlBase + "/one", String.class)).isEqualTo("one");
|
||||
assertThat(new File(this.launchedApplication.getClassesDirectory(), "com/example/ControllerOne.class").delete())
|
||||
.isTrue();
|
||||
.isTrue();
|
||||
urlBase = "http://localhost:" + awaitServerPort();
|
||||
assertThat(this.template.getForEntity(urlBase + "/one", String.class).getStatusCode())
|
||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||
|
||||
}
|
||||
|
||||
@@ -143,16 +143,16 @@ class DevToolsIntegrationTests extends AbstractDevToolsIntegrationTests {
|
||||
String urlBase = "http://localhost:" + awaitServerPort();
|
||||
assertThat(this.template.getForObject(urlBase + "/one", String.class)).isEqualTo("one");
|
||||
assertThat(this.template.getForEntity(urlBase + "/two", String.class).getStatusCode())
|
||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||
controller("com.example.ControllerTwo").withRequestMapping("two").build();
|
||||
urlBase = "http://localhost:" + awaitServerPort();
|
||||
assertThat(this.template.getForObject(urlBase + "/one", String.class)).isEqualTo("one");
|
||||
assertThat(this.template.getForObject(urlBase + "/two", String.class)).isEqualTo("two");
|
||||
assertThat(new File(this.launchedApplication.getClassesDirectory(), "com/example/ControllerTwo.class").delete())
|
||||
.isTrue();
|
||||
.isTrue();
|
||||
urlBase = "http://localhost:" + awaitServerPort();
|
||||
assertThat(this.template.getForEntity(urlBase + "/two", String.class).getStatusCode())
|
||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
static Object[] parameters() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,7 +40,7 @@ class DevToolsWithLazyInitializationIntegrationTests extends AbstractDevToolsInt
|
||||
String urlBase = "http://localhost:" + awaitServerPort();
|
||||
assertThat(template.getForObject(urlBase + "/one", String.class)).isEqualTo("one");
|
||||
assertThat(template.getForEntity(urlBase + "/two", String.class).getStatusCode())
|
||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||
controller("com.example.ControllerOne").withRequestMapping("one").withRequestMapping("two").build();
|
||||
urlBase = "http://localhost:" + awaitServerPort();
|
||||
assertThat(template.getForObject(urlBase + "/one", String.class)).isEqualTo("one");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -59,7 +59,8 @@ class JvmLauncher implements BeforeTestExecutionCallback {
|
||||
File standardOut = new File(this.outputDirectory, name + ".out");
|
||||
File standardError = new File(this.outputDirectory, name + ".err");
|
||||
Process process = new ProcessBuilder(StringUtils.toStringArray(command)).redirectError(standardError)
|
||||
.redirectOutput(standardOut).start();
|
||||
.redirectOutput(standardOut)
|
||||
.start();
|
||||
return new LaunchedJvm(process, standardOut, standardError);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -102,15 +102,15 @@ abstract class RemoteApplicationLauncher extends AbstractApplicationLauncher {
|
||||
|
||||
private int awaitServerPort(LaunchedJvm jvm, File serverPortFile) {
|
||||
return Awaitility.waitAtMost(Duration.ofMinutes(3))
|
||||
.until(() -> new ApplicationState(serverPortFile, jvm), ApplicationState::hasServerPort)
|
||||
.getServerPort();
|
||||
.until(() -> new ApplicationState(serverPortFile, jvm), ApplicationState::hasServerPort)
|
||||
.getServerPort();
|
||||
}
|
||||
|
||||
private void awaitRemoteSpringApplication(LaunchedJvm launchedJvm) {
|
||||
FileContents contents = new FileContents(launchedJvm.getStandardOut());
|
||||
try {
|
||||
Awaitility.waitAtMost(Duration.ofMinutes(3)).until(contents::get,
|
||||
containsString("Started RemoteSpringApplication"));
|
||||
Awaitility.waitAtMost(Duration.ofMinutes(3))
|
||||
.until(contents::get, containsString("Started RemoteSpringApplication"));
|
||||
}
|
||||
catch (ConditionTimeoutException ex) {
|
||||
if (!launchedJvm.getProcess().isAlive()) {
|
||||
|
||||
Reference in New Issue
Block a user