Merge branch '2.7.x' into 3.0.x

This commit is contained in:
Phillip Webb
2023-02-21 23:15:40 -08:00
1890 changed files with 27173 additions and 21952 deletions

View File

@@ -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);
}
}

View File

@@ -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);
}

View File

@@ -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() {

View File

@@ -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");

View File

@@ -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);
}

View File

@@ -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()) {

View File

@@ -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.
@@ -73,7 +73,7 @@ public final class RemoteSpringApplication {
List<ApplicationListener<?>> listeners = new ArrayList<>();
listeners.add(new AnsiOutputApplicationListener());
listeners.add(EnvironmentPostProcessorApplicationListener
.with(EnvironmentPostProcessorsFactory.of(ConfigDataEnvironmentPostProcessor.class)));
.with(EnvironmentPostProcessorsFactory.of(ConfigDataEnvironmentPostProcessor.class)));
listeners.add(new LoggingApplicationListener());
listeners.add(new RemoteUrlPropertyExtractor());
return listeners;

View File

@@ -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.
@@ -189,8 +189,10 @@ public class DevToolsDataSourceAutoConfiguration {
BeanDefinition dataSourceDefinition = context.getRegistry().getBeanDefinition(dataSourceBeanNames[0]);
if (dataSourceDefinition instanceof AnnotatedBeanDefinition annotatedBeanDefinition
&& annotatedBeanDefinition.getFactoryMethodMetadata() != null
&& annotatedBeanDefinition.getFactoryMethodMetadata().getDeclaringClassName().startsWith(
DataSourceAutoConfiguration.class.getPackage().getName() + ".DataSourceConfiguration$")) {
&& annotatedBeanDefinition.getFactoryMethodMetadata()
.getDeclaringClassName()
.startsWith(DataSourceAutoConfiguration.class.getPackage().getName()
+ ".DataSourceConfiguration$")) {
return ConditionOutcome.match(message.foundExactly("auto-configured DataSource"));
}
return ConditionOutcome.noMatch(message.didNotFind("an auto-configured DataSource").atAll());

View File

@@ -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.
@@ -75,7 +75,8 @@ public class DevToolsR2dbcAutoConfiguration {
public void destroy() throws Exception {
if (shouldShutdown()) {
Mono.usingWhen(this.connectionFactory.create(), this::executeShutdown, this::closeConnection,
this::closeConnection, this::closeConnection).block();
this::closeConnection, this::closeConnection)
.block();
this.eventPublisher.publishEvent(new R2dbcDatabaseShutdownEvent(this.connectionFactory));
}
}
@@ -128,7 +129,7 @@ public class DevToolsR2dbcAutoConfiguration {
private boolean isAutoConfigured(AnnotatedBeanDefinition beanDefinition) {
MethodMetadata methodMetadata = beanDefinition.getFactoryMethodMetadata();
return methodMetadata != null && methodMetadata.getDeclaringClassName()
.startsWith(R2dbcAutoConfiguration.class.getPackage().getName());
.startsWith(R2dbcAutoConfiguration.class.getPackage().getName());
}
}

View File

@@ -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.
@@ -70,7 +70,8 @@ public class ClassPathChangedEvent extends ApplicationEvent {
@Override
public String toString() {
return new ToStringCreator(this).append("changeSet", this.changeSet)
.append("restartRequired", this.restartRequired).toString();
.append("restartRequired", this.restartRequired)
.toString();
}
/**

View File

@@ -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.
@@ -134,7 +134,7 @@ public class DevToolsHomePropertiesPostProcessor implements EnvironmentPostProce
private boolean canLoadFileExtension(PropertySourceLoader loader, String name) {
return Arrays.stream(loader.getFileExtensions())
.anyMatch((fileExtension) -> StringUtils.endsWithIgnoreCase(name, fileExtension));
.anyMatch((fileExtension) -> StringUtils.endsWithIgnoreCase(name, fileExtension));
}
protected File getHomeDirectory() {

View File

@@ -135,7 +135,7 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro
private static Map<String, Object> loadDefaultProperties() {
Properties properties = new Properties();
try (InputStream stream = DevToolsPropertyDefaultsPostProcessor.class
.getResourceAsStream("devtools-property-defaults.properties")) {
.getResourceAsStream("devtools-property-defaults.properties")) {
if (stream == null) {
throw new RuntimeException(
"Failed to load devtools-property-defaults.properties because it doesn't exist");

View File

@@ -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.
@@ -96,7 +96,8 @@ class Connection {
this.outputStream.writeHeaders("HTTP/1.1 101 Switching Protocols", "Upgrade: websocket", "Connection: Upgrade",
"Sec-WebSocket-Accept: " + accept);
new Frame("{\"command\":\"hello\",\"protocols\":[\"http://livereload.com/protocols/official-7\"],"
+ "\"serverName\":\"spring-boot\"}").write(this.outputStream);
+ "\"serverName\":\"spring-boot\"}")
.write(this.outputStream);
while (this.running) {
readWebSocketFrame();
}

View File

@@ -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.
@@ -95,7 +95,7 @@ public class RemoteClientConfiguration implements InitializingBean {
Proxy proxy = this.properties.getRemote().getProxy();
if (proxy.getHost() != null && proxy.getPort() != null) {
requestFactory
.setProxy(new java.net.Proxy(Type.HTTP, new InetSocketAddress(proxy.getHost(), proxy.getPort())));
.setProxy(new java.net.Proxy(Type.HTTP, new InetSocketAddress(proxy.getHost(), proxy.getPort())));
}
return new InterceptingClientHttpRequestFactory(requestFactory, interceptors);
}

View File

@@ -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.
@@ -106,7 +106,8 @@ final class ChangeableUrls implements Iterable<URL> {
return urlClassLoader.getURLs();
}
return Stream.of(ManagementFactory.getRuntimeMXBean().getClassPath().split(File.pathSeparator))
.map(ChangeableUrls::toURL).toArray(URL[]::new);
.map(ChangeableUrls::toURL)
.toArray(URL[]::new);
}
private static URL toURL(String classPathEntry) {

View File

@@ -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.
@@ -74,7 +74,7 @@ final class ClassLoaderFilesResourcePatternResolver implements ResourcePatternRe
ClassLoaderFiles classLoaderFiles) {
this.classLoaderFiles = classLoaderFiles;
this.patternResolverDelegate = getResourcePatternResolverFactory()
.getResourcePatternResolver(applicationContext, retrieveResourceLoader(applicationContext));
.getResourcePatternResolver(applicationContext, retrieveResourceLoader(applicationContext));
}
private ResourceLoader retrieveResourceLoader(ApplicationContext applicationContext) {

View File

@@ -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.
@@ -39,7 +39,8 @@ class RemoteUrlPropertyExtractorTests {
@AfterEach
void preventRunFailuresFromPollutingLoggerContext() {
((Logger) LoggerFactory.getLogger(RemoteUrlPropertyExtractorTests.class)).getLoggerContext()
.getTurboFilterList().clear();
.getTurboFilterList()
.clear();
}
@Test
@@ -50,14 +51,14 @@ class RemoteUrlPropertyExtractorTests {
@Test
void malformedUrl() {
assertThatIllegalStateException().isThrownBy(() -> doTest("::://wibble"))
.withMessageContaining("Malformed URL '::://wibble'");
.withMessageContaining("Malformed URL '::://wibble'");
}
@Test
void multipleUrls() {
assertThatIllegalStateException().isThrownBy(() -> doTest("http://localhost:8080", "http://localhost:9090"))
.withMessageContaining("Multiple URLs specified");
.withMessageContaining("Multiple URLs specified");
}
@Test

View File

@@ -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.
@@ -132,16 +132,17 @@ class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDat
jdbc.execute("SELECT 1 FROM SYSIBM.SYSDUMMY1");
HikariPoolMXBean pool = dataSource.getHikariPoolMXBean();
// Prevent a race between Hikari's initialization and Derby shutdown
Awaitility.await().atMost(Duration.ofSeconds(30)).until(pool::getIdleConnections,
(idle) -> idle == dataSource.getMinimumIdle());
Awaitility.await()
.atMost(Duration.ofSeconds(30))
.until(pool::getIdleConnections, (idle) -> idle == dataSource.getMinimumIdle());
context.close();
// Connect should fail as DB no longer exists
assertThatExceptionOfType(SQLException.class)
.isThrownBy(() -> new EmbeddedDriver().connect("jdbc:derby:memory:test", new Properties()))
.satisfies((ex) -> assertThat(ex.getSQLState()).isEqualTo("XJ004"));
.isThrownBy(() -> new EmbeddedDriver().connect("jdbc:derby:memory:test", new Properties()))
.satisfies((ex) -> assertThat(ex.getSQLState()).isEqualTo("XJ004"));
// Shut Derby down fully so that it closes its log file
assertThatExceptionOfType(SQLException.class)
.isThrownBy(() -> new EmbeddedDriver().connect("jdbc:derby:;shutdown=true", new Properties()));
.isThrownBy(() -> new EmbeddedDriver().connect("jdbc:derby:;shutdown=true", new Properties()));
}
}

View File

@@ -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.
@@ -153,7 +153,7 @@ class LocalDevToolsAutoConfigurationTests {
properties.put("spring.devtools.livereload.enabled", false);
this.context = getContext(() -> initializeAndRun(Config.class, properties));
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.context.getBean(OptionalLiveReloadServer.class));
.isThrownBy(() -> this.context.getBean(OptionalLiveReloadServer.class));
}
@Test
@@ -185,7 +185,7 @@ class LocalDevToolsAutoConfigurationTests {
properties.put("spring.devtools.restart.enabled", false);
this.context = getContext(() -> initializeAndRun(Config.class, properties));
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.context.getBean(ClassPathFileSystemWatcher.class));
.isThrownBy(() -> this.context.getBean(ClassPathFileSystemWatcher.class));
}
@Test
@@ -208,19 +208,20 @@ class LocalDevToolsAutoConfigurationTests {
Object watcher = ReflectionTestUtils.getField(classPathWatcher, "fileSystemWatcher");
@SuppressWarnings("unchecked")
Map<File, Object> directories = (Map<File, Object>) ReflectionTestUtils.getField(watcher, "directories");
assertThat(directories).hasSize(2).containsKey(new File("src/main/java").getAbsoluteFile())
.containsKey(new File("src/test/java").getAbsoluteFile());
assertThat(directories).hasSize(2)
.containsKey(new File("src/main/java").getAbsoluteFile())
.containsKey(new File("src/test/java").getAbsoluteFile());
}
@Test
void devToolsSwitchesJspServletToDevelopmentMode() throws Exception {
this.context = getContext(() -> initializeAndRun(Config.class));
TomcatWebServer tomcatContainer = (TomcatWebServer) ((ServletWebServerApplicationContext) this.context)
.getWebServer();
.getWebServer();
Container context = tomcatContainer.getTomcat().getHost().findChildren()[0];
StandardWrapper jspServletWrapper = (StandardWrapper) context.findChild("jsp");
EmbeddedServletOptions options = (EmbeddedServletOptions) ReflectionTestUtils
.getField(jspServletWrapper.getServlet(), "options");
.getField(jspServletWrapper.getServlet(), "options");
assertThat(options.getDevelopment()).isTrue();
}

View File

@@ -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.
@@ -94,7 +94,7 @@ class RemoteDevToolsAutoConfigurationTests {
void disabledIfRemoteSecretIsMissing() throws Exception {
this.context = getContext(() -> loadContext("a:b"));
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.context.getBean(DispatcherFilter.class));
.isThrownBy(() -> this.context.getBean(DispatcherFilter.class));
}
@Test
@@ -151,10 +151,14 @@ class RemoteDevToolsAutoConfigurationTests {
void securityConfigurationShouldAllowAccess() throws Exception {
this.context = getContext(() -> loadContext("spring.devtools.remote.secret:supersecret"));
DispatcherFilter filter = this.context.getBean(DispatcherFilter.class);
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context).apply(springSecurity()).addFilter(filter)
.build();
mockMvc.perform(MockMvcRequestBuilders.get(DEFAULT_CONTEXT_PATH + "/restart").header(DEFAULT_SECRET_HEADER_NAME,
"supersecret")).andExpect(status().isOk());
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
.apply(springSecurity())
.addFilter(filter)
.build();
mockMvc
.perform(MockMvcRequestBuilders.get(DEFAULT_CONTEXT_PATH + "/restart")
.header(DEFAULT_SECRET_HEADER_NAME, "supersecret"))
.andExpect(status().isOk());
assertRestartInvoked(true);
assertThat(this.context.containsBean("devtoolsSecurityFilterChain")).isTrue();
}
@@ -164,11 +168,14 @@ class RemoteDevToolsAutoConfigurationTests {
this.context = getContext(() -> loadContext("spring.devtools.remote.secret:supersecret",
"server.servlet.context-path:/test", "spring.devtools.remote.context-path:/custom"));
DispatcherFilter filter = this.context.getBean(DispatcherFilter.class);
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context).apply(springSecurity()).addFilter(filter)
.build();
mockMvc.perform(
MockMvcRequestBuilders.get("/test/custom/restart").header(DEFAULT_SECRET_HEADER_NAME, "supersecret"))
.andExpect(status().isOk());
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
.apply(springSecurity())
.addFilter(filter)
.build();
mockMvc
.perform(MockMvcRequestBuilders.get("/test/custom/restart")
.header(DEFAULT_SECRET_HEADER_NAME, "supersecret"))
.andExpect(status().isOk());
assertRestartInvoked(true);
}
@@ -177,8 +184,10 @@ class RemoteDevToolsAutoConfigurationTests {
this.context = getContext(() -> loadContext("spring.devtools.remote.secret:supersecret"));
DispatcherFilter filter = this.context.getBean(DispatcherFilter.class);
Filter securityFilterChain = this.context.getBean(BeanIds.SPRING_SECURITY_FILTER_CHAIN, Filter.class);
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context).addFilter(securityFilterChain)
.addFilter(filter).build();
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
.addFilter(securityFilterChain)
.addFilter(filter)
.build();
mockMvc.perform(MockMvcRequestBuilders.get("/my-path")).andExpect(status().isUnauthorized());
}
@@ -187,7 +196,7 @@ class RemoteDevToolsAutoConfigurationTests {
this.context = getContext(() -> loadContext("spring.devtools.remote.secret:supersecret",
"spring.devtools.remote.restart.enabled:false"));
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.context.getBean("remoteRestartHandlerMapper"));
.isThrownBy(() -> this.context.getBean("remoteRestartHandlerMapper"));
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -37,7 +37,7 @@ class TriggerFileFilterTests {
@Test
void nameMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new TriggerFileFilter(null))
.withMessageContaining("Name must not be null");
.withMessageContaining("Name must not be null");
}
@Test

View File

@@ -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.
@@ -38,7 +38,7 @@ class ClassPathChangedEventTests {
@Test
void changeSetMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new ClassPathChangedEvent(this.source, null, false))
.withMessageContaining("ChangeSet must not be null");
.withMessageContaining("ChangeSet must not be null");
}
@Test

View File

@@ -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.
@@ -63,15 +63,15 @@ class ClassPathFileChangeListenerTests {
@Test
void eventPublisherMustNotBeNull() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new ClassPathFileChangeListener(null, this.restartStrategy, this.fileSystemWatcher))
.withMessageContaining("EventPublisher must not be null");
.isThrownBy(() -> new ClassPathFileChangeListener(null, this.restartStrategy, this.fileSystemWatcher))
.withMessageContaining("EventPublisher must not be null");
}
@Test
void restartStrategyMustNotBeNull() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new ClassPathFileChangeListener(this.eventPublisher, null, this.fileSystemWatcher))
.withMessageContaining("RestartStrategy must not be null");
.isThrownBy(() -> new ClassPathFileChangeListener(this.eventPublisher, null, this.fileSystemWatcher))
.withMessageContaining("RestartStrategy must not be null");
}
@Test

View File

@@ -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.
@@ -53,9 +53,9 @@ class ClassPathFileSystemWatcherTests {
@Test
void urlsMustNotBeNull() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new ClassPathFileSystemWatcher(mock(FileSystemWatcherFactory.class),
mock(ClassPathRestartStrategy.class), (URL[]) null))
.withMessageContaining("Urls must not be null");
.isThrownBy(() -> new ClassPathFileSystemWatcher(mock(FileSystemWatcherFactory.class),
mock(ClassPathRestartStrategy.class), (URL[]) null))
.withMessageContaining("Urls must not be null");
}
@Test
@@ -83,7 +83,7 @@ class ClassPathFileSystemWatcherTests {
}
assertThat(events).hasSize(1);
assertThat(events.get(0).getChangeSet().iterator().next()).extracting(ChangedFile::getFile)
.containsExactly(classFile);
.containsExactly(classFile);
context.close();
}

View File

@@ -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.
@@ -87,7 +87,7 @@ class DevToolPropertiesIntegrationTests {
application.setWebApplicationType(WebApplicationType.NONE);
this.context = getContext(application::run);
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.context.getBean(MyBean.class));
.isThrownBy(() -> this.context.getBean(MyBean.class));
}
@Test
@@ -109,10 +109,10 @@ class DevToolPropertiesIntegrationTests {
ConfigurableEnvironment environment = this.context.getEnvironment();
String includeStackTrace = environment.getProperty("server.error.include-stacktrace");
assertThat(includeStackTrace)
.isEqualTo(ErrorProperties.IncludeAttribute.ALWAYS.toString().toLowerCase(Locale.ENGLISH));
.isEqualTo(ErrorProperties.IncludeAttribute.ALWAYS.toString().toLowerCase(Locale.ENGLISH));
String includeMessage = environment.getProperty("server.error.include-message");
assertThat(includeMessage)
.isEqualTo(ErrorProperties.IncludeAttribute.ALWAYS.toString().toLowerCase(Locale.ENGLISH));
.isEqualTo(ErrorProperties.IncludeAttribute.ALWAYS.toString().toLowerCase(Locale.ENGLISH));
}
protected ConfigurableApplicationContext getContext(Supplier<ConfigurableApplicationContext> supplier)

View File

@@ -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.
@@ -39,22 +39,23 @@ class ChangedFileTests {
@Test
void sourceDirectoryMustNotBeNull() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new ChangedFile(null, new File(this.tempDir, "file"), Type.ADD))
.withMessageContaining("SourceDirectory must not be null");
.isThrownBy(() -> new ChangedFile(null, new File(this.tempDir, "file"), Type.ADD))
.withMessageContaining("SourceDirectory must not be null");
}
@Test
void fileMustNotBeNull() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new ChangedFile(new File(this.tempDir, "directory"), null, Type.ADD))
.withMessageContaining("File must not be null");
.isThrownBy(() -> new ChangedFile(new File(this.tempDir, "directory"), null, Type.ADD))
.withMessageContaining("File must not be null");
}
@Test
void typeMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(
() -> new ChangedFile(new File(this.tempDir, "file"), new File(this.tempDir, "directory"), null))
.withMessageContaining("Type must not be null");
assertThatIllegalArgumentException()
.isThrownBy(
() -> new ChangedFile(new File(this.tempDir, "file"), new File(this.tempDir, "directory"), null))
.withMessageContaining("Type must not be null");
}
@Test

View File

@@ -53,7 +53,7 @@ class DirectorySnapshotTests {
@Test
void directoryMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new DirectorySnapshot(null))
.withMessageContaining("Directory must not be null");
.withMessageContaining("Directory must not be null");
}
@Test
@@ -61,7 +61,7 @@ class DirectorySnapshotTests {
File file = new File(this.tempDir, "file");
file.createNewFile();
assertThatIllegalArgumentException().isThrownBy(() -> new DirectorySnapshot(file))
.withMessageContaining("Directory '" + file + "' must not be a file");
.withMessageContaining("Directory '" + file + "' must not be a file");
}
@Test
@@ -103,14 +103,14 @@ class DirectorySnapshotTests {
@Test
void getChangedFilesSnapshotMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> this.initialSnapshot.getChangedFiles(null, null))
.withMessageContaining("Snapshot must not be null");
.withMessageContaining("Snapshot must not be null");
}
@Test
void getChangedFilesSnapshotMustBeTheSameSourceDirectory() {
assertThatIllegalArgumentException().isThrownBy(
() -> this.initialSnapshot.getChangedFiles(new DirectorySnapshot(createTestDirectoryStructure()), null))
.withMessageContaining("Snapshot source directory must be '" + this.directory + "'");
.withMessageContaining("Snapshot source directory must be '" + this.directory + "'");
}
@Test

View File

@@ -47,7 +47,7 @@ class FileSnapshotTests {
@Test
void fileMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new FileSnapshot(null))
.withMessageContaining("File must not be null");
.withMessageContaining("File must not be null");
}
@Test
@@ -55,7 +55,7 @@ class FileSnapshotTests {
File file = new File(this.tempDir, "file");
file.mkdir();
assertThatIllegalArgumentException().isThrownBy(() -> new FileSnapshot(file))
.withMessageContaining("File must not be a directory");
.withMessageContaining("File must not be a directory");
}
@Test

View File

@@ -63,41 +63,41 @@ class FileSystemWatcherTests {
@Test
void pollIntervalMustBePositive() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new FileSystemWatcher(true, Duration.ofMillis(0), Duration.ofMillis(1)))
.withMessageContaining("PollInterval must be positive");
.isThrownBy(() -> new FileSystemWatcher(true, Duration.ofMillis(0), Duration.ofMillis(1)))
.withMessageContaining("PollInterval must be positive");
}
@Test
void quietPeriodMustBePositive() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new FileSystemWatcher(true, Duration.ofMillis(1), Duration.ofMillis(0)))
.withMessageContaining("QuietPeriod must be positive");
.isThrownBy(() -> new FileSystemWatcher(true, Duration.ofMillis(1), Duration.ofMillis(0)))
.withMessageContaining("QuietPeriod must be positive");
}
@Test
void pollIntervalMustBeGreaterThanQuietPeriod() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new FileSystemWatcher(true, Duration.ofMillis(1), Duration.ofMillis(1)))
.withMessageContaining("PollInterval must be greater than QuietPeriod");
.isThrownBy(() -> new FileSystemWatcher(true, Duration.ofMillis(1), Duration.ofMillis(1)))
.withMessageContaining("PollInterval must be greater than QuietPeriod");
}
@Test
void listenerMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> this.watcher.addListener(null))
.withMessageContaining("FileChangeListener must not be null");
.withMessageContaining("FileChangeListener must not be null");
}
@Test
void cannotAddListenerToStartedListener() {
this.watcher.start();
assertThatIllegalStateException().isThrownBy(() -> this.watcher.addListener(mock(FileChangeListener.class)))
.withMessageContaining("FileSystemWatcher already started");
.withMessageContaining("FileSystemWatcher already started");
}
@Test
void sourceDirectoryMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> this.watcher.addSourceDirectory(null))
.withMessageContaining("Directory must not be null");
.withMessageContaining("Directory must not be null");
}
@Test
@@ -106,14 +106,14 @@ class FileSystemWatcherTests {
assertThat(file.createNewFile()).isTrue();
assertThat(file).isFile();
assertThatIllegalArgumentException().isThrownBy(() -> this.watcher.addSourceDirectory(file))
.withMessageContaining("Directory '" + file + "' must not be a file");
.withMessageContaining("Directory '" + file + "' must not be a file");
}
@Test
void cannotAddSourceDirectoryToStartedListener() {
this.watcher.start();
assertThatIllegalStateException().isThrownBy(() -> this.watcher.addSourceDirectory(this.tempDir))
.withMessageContaining("FileSystemWatcher already started");
.withMessageContaining("FileSystemWatcher already started");
}
@Test
@@ -313,8 +313,10 @@ class FileSystemWatcherTests {
}
private Set<ChangedFile> getAllFileChanges(List<Set<ChangedFiles>> changes) {
return changes.stream().flatMap(Set<ChangedFiles>::stream)
.flatMap((changedFiles) -> changedFiles.getFiles().stream()).collect(Collectors.toSet());
return changes.stream()
.flatMap(Set<ChangedFiles>::stream)
.flatMap((changedFiles) -> changedFiles.getFiles().stream())
.collect(Collectors.toSet());
}
private File touch(File file) throws IOException {

View File

@@ -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.
@@ -68,7 +68,7 @@ class ConnectionInputStreamTests {
byte[] buffer = new byte[100];
ConnectionInputStream inputStream = new ConnectionInputStream(new ByteArrayInputStream(NO_BYTES));
assertThatIOException().isThrownBy(() -> inputStream.checkedRead(buffer, 0, buffer.length))
.withMessageContaining("End of stream");
.withMessageContaining("End of stream");
}
static class LimitedInputStream extends FilterInputStream {

View File

@@ -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.
@@ -36,13 +36,13 @@ class FrameTests {
@Test
void payloadMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new Frame((String) null))
.withMessageContaining("Payload must not be null");
.withMessageContaining("Payload must not be null");
}
@Test
void typeMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new Frame((Frame.Type) null))
.withMessageContaining("Type must not be null");
.withMessageContaining("Type must not be null");
}
@Test
@@ -88,14 +88,14 @@ class FrameTests {
void readFragmentedNotSupported() {
byte[] bytes = new byte[] { 0x0F };
assertThatIllegalStateException().isThrownBy(() -> Frame.read(newConnectionInputStream(bytes)))
.withMessageContaining("Fragmented frames are not supported");
.withMessageContaining("Fragmented frames are not supported");
}
@Test
void readLargeFramesNotSupported() {
byte[] bytes = new byte[] { (byte) 0x80, (byte) 0xFF };
assertThatIllegalStateException().isThrownBy(() -> Frame.read(newConnectionInputStream(bytes)))
.withMessageContaining("Large frames are not supported");
.withMessageContaining("Large frames are not supported");
}
@Test

View File

@@ -113,8 +113,8 @@ class LiveReloadServerTests {
void triggerReload() throws Exception {
LiveReloadWebSocketHandler handler = connect();
this.server.triggerReload();
List<String> messages = await().atMost(Duration.ofSeconds(10)).until(handler::getMessages,
(msgs) -> msgs.size() == 2);
List<String> messages = await().atMost(Duration.ofSeconds(10))
.until(handler::getMessages, (msgs) -> msgs.size() == 2);
assertThat(messages.get(0)).contains("http://livereload.com/protocols/official-7");
assertThat(messages.get(1)).contains("command\":\"reload\"");
}
@@ -123,8 +123,8 @@ class LiveReloadServerTests {
void triggerReloadWithUppercaseHeaders() throws Exception {
LiveReloadWebSocketHandler handler = connect(UppercaseWebSocketClient::new);
this.server.triggerReload();
List<String> messages = await().atMost(Duration.ofSeconds(10)).until(handler::getMessages,
(msgs) -> msgs.size() == 2);
List<String> messages = await().atMost(Duration.ofSeconds(10))
.until(handler::getMessages, (msgs) -> msgs.size() == 2);
assertThat(messages.get(0)).contains("http://livereload.com/protocols/official-7");
assertThat(messages.get(1)).contains("command\":\"reload\"");
}
@@ -152,8 +152,8 @@ class LiveReloadServerTests {
void serverClose() throws Exception {
LiveReloadWebSocketHandler handler = connect();
this.server.stop();
CloseStatus closeStatus = await().atMost(Duration.ofSeconds(10)).until(handler::getCloseStatus,
Objects::nonNull);
CloseStatus closeStatus = await().atMost(Duration.ofSeconds(10))
.until(handler::getCloseStatus, Objects::nonNull);
assertThat(closeStatus.getCode()).isEqualTo(1006);
}
@@ -303,8 +303,10 @@ class LiveReloadServerTests {
remoteAddress);
Stream<Extension> adaptedExtensions = extensions.stream().map(WebSocketToStandardExtensionAdapter::new);
ClientEndpointConfig endpointConfig = ClientEndpointConfig.Builder.create()
.configurator(new UppercaseWebSocketClientConfigurator(headers)).preferredSubprotocols(protocols)
.extensions(adaptedExtensions.toList()).build();
.configurator(new UppercaseWebSocketClientConfigurator(headers))
.preferredSubprotocols(protocols)
.extensions(adaptedExtensions.toList())
.build();
endpointConfig.getUserProperties().putAll(getUserProperties());
Endpoint endpoint = new StandardWebSocketHandlerAdapter(webSocketHandler, session);
Callable<WebSocketSession> connectTask = () -> {

View File

@@ -67,27 +67,27 @@ class ClassPathChangeUploaderTests {
@Test
void urlMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new ClassPathChangeUploader(null, this.requestFactory))
.withMessageContaining("URL must not be empty");
.withMessageContaining("URL must not be empty");
}
@Test
void urlMustNotBeEmpty() {
assertThatIllegalArgumentException().isThrownBy(() -> new ClassPathChangeUploader("", this.requestFactory))
.withMessageContaining("URL must not be empty");
.withMessageContaining("URL must not be empty");
}
@Test
void requestFactoryMustNotBeNull() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new ClassPathChangeUploader("http://localhost:8080", null))
.withMessageContaining("RequestFactory must not be null");
.isThrownBy(() -> new ClassPathChangeUploader("http://localhost:8080", null))
.withMessageContaining("RequestFactory must not be null");
}
@Test
void urlMustNotBeMalformed() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new ClassPathChangeUploader("htttttp:///ttest", this.requestFactory))
.withMessageContaining("Malformed URL 'htttttp:///ttest'");
.isThrownBy(() -> new ClassPathChangeUploader("htttttp:///ttest", this.requestFactory))
.withMessageContaining("Malformed URL 'htttttp:///ttest'");
}
@Test

View File

@@ -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.
@@ -76,29 +76,29 @@ class DelayedLiveReloadTriggerTests {
@Test
void liveReloadServerMustNotBeNull() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new DelayedLiveReloadTrigger(null, this.requestFactory, URL))
.withMessageContaining("LiveReloadServer must not be null");
.isThrownBy(() -> new DelayedLiveReloadTrigger(null, this.requestFactory, URL))
.withMessageContaining("LiveReloadServer must not be null");
}
@Test
void requestFactoryMustNotBeNull() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new DelayedLiveReloadTrigger(this.liveReloadServer, null, URL))
.withMessageContaining("RequestFactory must not be null");
.isThrownBy(() -> new DelayedLiveReloadTrigger(this.liveReloadServer, null, URL))
.withMessageContaining("RequestFactory must not be null");
}
@Test
void urlMustNotBeNull() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new DelayedLiveReloadTrigger(this.liveReloadServer, this.requestFactory, null))
.withMessageContaining("URL must not be empty");
.isThrownBy(() -> new DelayedLiveReloadTrigger(this.liveReloadServer, this.requestFactory, null))
.withMessageContaining("URL must not be empty");
}
@Test
void urlMustNotBeEmpty() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new DelayedLiveReloadTrigger(this.liveReloadServer, this.requestFactory, ""))
.withMessageContaining("URL must not be empty");
.isThrownBy(() -> new DelayedLiveReloadTrigger(this.liveReloadServer, this.requestFactory, ""))
.withMessageContaining("URL must not be empty");
}
@Test
@@ -108,7 +108,7 @@ class DelayedLiveReloadTriggerTests {
given(this.errorResponse.getStatusCode()).willReturn(HttpStatus.INTERNAL_SERVER_ERROR);
given(this.okResponse.getStatusCode()).willReturn(HttpStatus.OK);
given(this.requestFactory.createRequest(new URI(URL), HttpMethod.GET)).willThrow(new IOException())
.willReturn(this.errorRequest, this.okRequest);
.willReturn(this.errorRequest, this.okRequest);
long startTime = System.currentTimeMillis();
this.trigger.setTimings(10, 200, 30000);
this.trigger.run();

View File

@@ -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.
@@ -74,25 +74,25 @@ class HttpHeaderInterceptorTests {
@Test
void constructorNullHeaderName() {
assertThatIllegalArgumentException().isThrownBy(() -> new HttpHeaderInterceptor(null, this.value))
.withMessageContaining("Name must not be empty");
.withMessageContaining("Name must not be empty");
}
@Test
void constructorEmptyHeaderName() {
assertThatIllegalArgumentException().isThrownBy(() -> new HttpHeaderInterceptor("", this.value))
.withMessageContaining("Name must not be empty");
.withMessageContaining("Name must not be empty");
}
@Test
void constructorNullHeaderValue() {
assertThatIllegalArgumentException().isThrownBy(() -> new HttpHeaderInterceptor(this.name, null))
.withMessageContaining("Value must not be empty");
.withMessageContaining("Value must not be empty");
}
@Test
void constructorEmptyHeaderValue() {
assertThatIllegalArgumentException().isThrownBy(() -> new HttpHeaderInterceptor(this.name, ""))
.withMessageContaining("Value must not be empty");
.withMessageContaining("Value must not be empty");
}
@Test

View File

@@ -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.
@@ -98,7 +98,7 @@ class RemoteClientConfigurationTests {
@Test
void failIfNoSecret() {
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> configure("http://localhost", false))
.withMessageContaining("required to secure your connection");
.withMessageContaining("required to secure your connection");
}
@Test
@@ -115,14 +115,14 @@ class RemoteClientConfigurationTests {
void liveReloadDisabled() {
configure("spring.devtools.livereload.enabled:false");
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.context.getBean(OptionalLiveReloadServer.class));
.isThrownBy(() -> this.context.getBean(OptionalLiveReloadServer.class));
}
@Test
void remoteRestartDisabled() {
configure("spring.devtools.remote.restart.enabled:false");
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.context.getBean(ClassPathFileSystemWatcher.class));
.isThrownBy(() -> this.context.getBean(ClassPathFileSystemWatcher.class));
}
private void configure(String... pairs) {

View File

@@ -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.
@@ -73,7 +73,7 @@ class DispatcherFilterTests {
@Test
void dispatcherMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new DispatcherFilter(null))
.withMessageContaining("Dispatcher must not be null");
.withMessageContaining("Dispatcher must not be null");
}
@Test

View File

@@ -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.
@@ -63,13 +63,13 @@ class DispatcherTests {
@Test
void accessManagerMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new Dispatcher(null, Collections.emptyList()))
.withMessageContaining("AccessManager must not be null");
.withMessageContaining("AccessManager must not be null");
}
@Test
void mappersMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new Dispatcher(this.accessManager, null))
.withMessageContaining("Mappers must not be null");
.withMessageContaining("Mappers must not be null");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -54,25 +54,25 @@ class HttpHeaderAccessManagerTests {
@Test
void headerNameMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new HttpHeaderAccessManager(null, SECRET))
.withMessageContaining("HeaderName must not be empty");
.withMessageContaining("HeaderName must not be empty");
}
@Test
void headerNameMustNotBeEmpty() {
assertThatIllegalArgumentException().isThrownBy(() -> new HttpHeaderAccessManager("", SECRET))
.withMessageContaining("HeaderName must not be empty");
.withMessageContaining("HeaderName must not be empty");
}
@Test
void expectedSecretMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new HttpHeaderAccessManager(HEADER, null))
.withMessageContaining("ExpectedSecret must not be empty");
.withMessageContaining("ExpectedSecret must not be empty");
}
@Test
void expectedSecretMustNotBeEmpty() {
assertThatIllegalArgumentException().isThrownBy(() -> new HttpHeaderAccessManager(HEADER, ""))
.withMessageContaining("ExpectedSecret must not be empty");
.withMessageContaining("ExpectedSecret must not be empty");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -56,7 +56,7 @@ class HttpStatusHandlerTests {
@Test
void statusMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new HttpStatusHandler(null))
.withMessageContaining("Status must not be null");
.withMessageContaining("Status must not be null");
}
@Test

View File

@@ -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,19 +40,19 @@ class UrlHandlerMapperTests {
@Test
void requestUriMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new UrlHandlerMapper(null, this.handler))
.withMessageContaining("URL must not be empty");
.withMessageContaining("URL must not be empty");
}
@Test
void requestUriMustNotBeEmpty() {
assertThatIllegalArgumentException().isThrownBy(() -> new UrlHandlerMapper("", this.handler))
.withMessageContaining("URL must not be empty");
.withMessageContaining("URL must not be empty");
}
@Test
void requestUrlMustStartWithSlash() {
assertThatIllegalArgumentException().isThrownBy(() -> new UrlHandlerMapper("tunnel", this.handler))
.withMessageContaining("URL must start with '/'");
.withMessageContaining("URL must start with '/'");
}
@Test

View File

@@ -114,8 +114,8 @@ class ChangeableUrlsTests {
File classpathJar = new File(this.tempDir, "classpath.jar");
Manifest manifest = new Manifest();
manifest.getMainAttributes().putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0");
manifest.getMainAttributes().putValue(Attributes.Name.CLASS_PATH.toString(),
StringUtils.arrayToDelimitedString(urls, " "));
manifest.getMainAttributes()
.putValue(Attributes.Name.CLASS_PATH.toString(), StringUtils.arrayToDelimitedString(urls, " "));
new JarOutputStream(new FileOutputStream(classpathJar), manifest).close();
return classpathJar;
}

View File

@@ -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.
@@ -46,7 +46,7 @@ class MainMethodTests {
@Test
void threadMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new MainMethod(null))
.withMessageContaining("Thread must not be null");
.withMessageContaining("Thread must not be null");
}
@Test
@@ -59,13 +59,13 @@ class MainMethodTests {
@Test
void missingArgsMainMethod() {
assertThatIllegalStateException().isThrownBy(() -> new TestThread(MissingArgs::main).test())
.withMessageContaining("Unable to find main method");
.withMessageContaining("Unable to find main method");
}
@Test
void nonStatic() {
assertThatIllegalStateException().isThrownBy(() -> new TestThread(() -> new NonStaticMain().main()).test())
.withMessageContaining("Unable to find main method");
.withMessageContaining("Unable to find main method");
}
static class TestThread extends Thread {

View File

@@ -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.
@@ -75,7 +75,7 @@ class RestarterTests {
void cantGetInstanceBeforeInitialize() {
Restarter.clearInstance();
assertThatIllegalStateException().isThrownBy(Restarter::getInstance)
.withMessageContaining("Restarter has not been initialized");
.withMessageContaining("Restarter has not been initialized");
}
@Test
@@ -102,7 +102,7 @@ class RestarterTests {
@Test
void addUrlsMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> Restarter.getInstance().addUrls(null))
.withMessageContaining("Urls must not be null");
.withMessageContaining("Urls must not be null");
}
@Test
@@ -119,7 +119,7 @@ class RestarterTests {
@Test
void addClassLoaderFilesMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> Restarter.getInstance().addClassLoaderFiles(null))
.withMessageContaining("ClassLoaderFiles must not be null");
.withMessageContaining("ClassLoaderFiles must not be null");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -35,25 +35,25 @@ class ClassLoaderFileTests {
@Test
void kindMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new ClassLoaderFile(null, null))
.withMessageContaining("Kind must not be null");
.withMessageContaining("Kind must not be null");
}
@Test
void addedContentsMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new ClassLoaderFile(Kind.ADDED, null))
.withMessageContaining("Contents must not be null");
.withMessageContaining("Contents must not be null");
}
@Test
void modifiedContentsMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new ClassLoaderFile(Kind.MODIFIED, null))
.withMessageContaining("Contents must not be null");
.withMessageContaining("Contents must not be null");
}
@Test
void deletedContentsMustBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new ClassLoaderFile(Kind.DELETED, new byte[10]))
.withMessageContaining("Contents must be null");
.withMessageContaining("Contents must be null");
}
@Test

View File

@@ -43,13 +43,13 @@ class ClassLoaderFilesTests {
@Test
void addFileNameMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> this.files.addFile(null, mock(ClassLoaderFile.class)))
.withMessageContaining("Name must not be null");
.withMessageContaining("Name must not be null");
}
@Test
void addFileFileMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> this.files.addFile("test", null))
.withMessageContaining("File must not be null");
.withMessageContaining("File must not be null");
}
@Test
@@ -153,7 +153,7 @@ class ClassLoaderFilesTests {
@Test
void classLoaderFilesMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new ClassLoaderFiles(null))
.withMessageContaining("ClassLoaderFiles must not be null");
.withMessageContaining("ClassLoaderFiles must not be null");
}
@Test

View File

@@ -104,14 +104,14 @@ class RestartClassLoaderTests {
@Test
void parentMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new RestartClassLoader(null, new URL[] {}))
.withMessageContaining("Parent must not be null");
.withMessageContaining("Parent must not be null");
}
@Test
void updatedFilesMustNotBeNull() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new RestartClassLoader(this.parentClassLoader, new URL[] {}, null))
.withMessageContaining("UpdatedFiles must not be null");
.isThrownBy(() -> new RestartClassLoader(this.parentClassLoader, new URL[] {}, null))
.withMessageContaining("UpdatedFiles must not be null");
}
@Test
@@ -189,7 +189,7 @@ class RestartClassLoaderTests {
String name = PACKAGE_PATH + "/Sample.class";
this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.DELETED, null));
assertThatExceptionOfType(ClassNotFoundException.class)
.isThrownBy(() -> Class.forName(PACKAGE + ".Sample", false, this.reloadClassLoader));
.isThrownBy(() -> Class.forName(PACKAGE + ".Sample", false, this.reloadClassLoader));
}
@Test
@@ -197,7 +197,7 @@ class RestartClassLoaderTests {
String name = PACKAGE_PATH + "/Sample.class";
this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.MODIFIED, new byte[10]));
assertThatExceptionOfType(ClassFormatError.class)
.isThrownBy(() -> Class.forName(PACKAGE + ".Sample", false, this.reloadClassLoader));
.isThrownBy(() -> Class.forName(PACKAGE + ".Sample", false, this.reloadClassLoader));
}
@Test
@@ -222,13 +222,14 @@ class RestartClassLoaderTests {
try (RestartClassLoader restartClassLoader = new RestartClassLoader(ExampleTransactional.class.getClassLoader(),
new URL[] { this.sampleJarFile.toURI().toURL() }, this.updatedFiles)) {
new ApplicationContextRunner().withClassLoader(restartClassLoader)
.withUserConfiguration(ProxyConfiguration.class).run((context) -> {
assertThat(context).hasNotFailed();
ExampleTransactional transactional = context.getBean(ExampleTransactional.class);
assertThat(AopUtils.isCglibProxy(transactional)).isTrue();
assertThat(transactional.getClass().getClassLoader())
.isEqualTo(ExampleTransactional.class.getClassLoader());
});
.withUserConfiguration(ProxyConfiguration.class)
.run((context) -> {
assertThat(context).hasNotFailed();
ExampleTransactional transactional = context.getBean(ExampleTransactional.class);
assertThat(AopUtils.isCglibProxy(transactional)).isTrue();
assertThat(transactional.getClass().getClassLoader())
.isEqualTo(ExampleTransactional.class.getClassLoader());
});
}
}

View File

@@ -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.
@@ -35,7 +35,7 @@ class HttpRestartServerHandlerTests {
@Test
void serverMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new HttpRestartServerHandler(null))
.withMessageContaining("Server must not be null");
.withMessageContaining("Server must not be null");
}
@Test

View File

@@ -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.
@@ -64,13 +64,13 @@ class HttpRestartServerTests {
@Test
void sourceDirectoryUrlFilterMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new HttpRestartServer((SourceDirectoryUrlFilter) null))
.withMessageContaining("SourceDirectoryUrlFilter must not be null");
.withMessageContaining("SourceDirectoryUrlFilter must not be null");
}
@Test
void restartServerMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new HttpRestartServer((RestartServer) null))
.withMessageContaining("RestartServer must not be null");
.withMessageContaining("RestartServer must not be null");
}
@Test

View File

@@ -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.
@@ -45,7 +45,7 @@ class RestartServerTests {
@Test
void sourceDirectoryUrlFilterMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new RestartServer((SourceDirectoryUrlFilter) null))
.withMessageContaining("SourceDirectoryUrlFilter must not be null");
.withMessageContaining("SourceDirectoryUrlFilter must not be null");
}
@Test

View File

@@ -73,26 +73,26 @@ class HttpTunnelConnectionTests {
@Test
void urlMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new HttpTunnelConnection(null, this.requestFactory))
.withMessageContaining("URL must not be empty");
.withMessageContaining("URL must not be empty");
}
@Test
void urlMustNotBeEmpty() {
assertThatIllegalArgumentException().isThrownBy(() -> new HttpTunnelConnection("", this.requestFactory))
.withMessageContaining("URL must not be empty");
.withMessageContaining("URL must not be empty");
}
@Test
void urlMustNotBeMalformed() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new HttpTunnelConnection("htttttp:///ttest", this.requestFactory))
.withMessageContaining("Malformed URL 'htttttp:///ttest'");
.isThrownBy(() -> new HttpTunnelConnection("htttttp:///ttest", this.requestFactory))
.withMessageContaining("Malformed URL 'htttttp:///ttest'");
}
@Test
void requestFactoryMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new HttpTunnelConnection(this.url, null))
.withMessageContaining("RequestFactory must not be null");
.withMessageContaining("RequestFactory must not be null");
}
@Test

View File

@@ -46,13 +46,13 @@ class TunnelClientTests {
@Test
void listenPortMustNotBeNegative() {
assertThatIllegalArgumentException().isThrownBy(() -> new TunnelClient(-5, this.tunnelConnection))
.withMessageContaining("ListenPort must be greater than or equal to 0");
.withMessageContaining("ListenPort must be greater than or equal to 0");
}
@Test
void tunnelConnectionMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new TunnelClient(1, null))
.withMessageContaining("TunnelConnection must not be null");
.withMessageContaining("TunnelConnection must not be null");
}
@Test
@@ -73,8 +73,9 @@ class TunnelClientTests {
TunnelClient client = new TunnelClient(0, this.tunnelConnection);
int port = client.start();
SocketChannel channel = SocketChannel.open(new InetSocketAddress(port));
Awaitility.await().atMost(Duration.ofSeconds(30)).until(this.tunnelConnection::getOpenedTimes,
(open) -> open == 1);
Awaitility.await()
.atMost(Duration.ofSeconds(30))
.until(this.tunnelConnection::getOpenedTimes, (open) -> open == 1);
channel.close();
client.getServerThread().stopAcceptingConnections();
client.getServerThread().join(2000);
@@ -87,8 +88,9 @@ class TunnelClientTests {
TunnelClient client = new TunnelClient(0, this.tunnelConnection);
int port = client.start();
SocketChannel channel = SocketChannel.open(new InetSocketAddress(port));
Awaitility.await().atMost(Duration.ofSeconds(30)).until(this.tunnelConnection::getOpenedTimes,
(times) -> times == 1);
Awaitility.await()
.atMost(Duration.ofSeconds(30))
.until(this.tunnelConnection::getOpenedTimes, (times) -> times == 1);
assertThat(this.tunnelConnection.isOpen()).isTrue();
client.stop();
assertThat(this.tunnelConnection.isOpen()).isFalse();

View File

@@ -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.
@@ -37,7 +37,7 @@ class HttpTunnelPayloadForwarderTests {
@Test
void targetChannelMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new HttpTunnelPayloadForwarder(null))
.withMessageContaining("TargetChannel must not be null");
.withMessageContaining("TargetChannel must not be null");
}
@Test

View File

@@ -51,13 +51,13 @@ class HttpTunnelPayloadTests {
@Test
void sequenceMustBePositive() {
assertThatIllegalArgumentException().isThrownBy(() -> new HttpTunnelPayload(0, ByteBuffer.allocate(1)))
.withMessageContaining("Sequence must be positive");
.withMessageContaining("Sequence must be positive");
}
@Test
void dataMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new HttpTunnelPayload(1, null))
.withMessageContaining("Data must not be null");
.withMessageContaining("Data must not be null");
}
@Test
@@ -98,7 +98,7 @@ class HttpTunnelPayloadTests {
servletRequest.setContent("hello".getBytes());
HttpInputMessage request = new ServletServerHttpRequest(servletRequest);
assertThatIllegalStateException().isThrownBy(() -> HttpTunnelPayload.get(request))
.withMessageContaining("Missing sequence header");
.withMessageContaining("Missing sequence header");
}
@Test

View File

@@ -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.
@@ -35,7 +35,7 @@ class HttpTunnelServerHandlerTests {
@Test
void serverMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new HttpTunnelServerHandler(null))
.withMessageContaining("Server must not be null");
.withMessageContaining("Server must not be null");
}
@Test

View File

@@ -99,7 +99,7 @@ class HttpTunnelServerTests {
@Test
void serverConnectionIsRequired() {
assertThatIllegalArgumentException().isThrownBy(() -> new HttpTunnelServer(null))
.withMessageContaining("ServerConnection must not be null");
.withMessageContaining("ServerConnection must not be null");
}
@Test
@@ -121,7 +121,7 @@ class HttpTunnelServerTests {
@Test
void longPollTimeoutMustBePositiveValue() {
assertThatIllegalArgumentException().isThrownBy(() -> this.server.setLongPollTimeout(0))
.withMessageContaining("LongPollTimeout must be a positive value");
.withMessageContaining("LongPollTimeout must be a positive value");
}
@Test
@@ -239,12 +239,14 @@ class HttpTunnelServerTests {
this.server.setLongPollTimeout(100);
MockHttpConnection h1 = new MockHttpConnection();
this.server.handle(h1);
Awaitility.await().atMost(Duration.ofSeconds(30)).until(h1.getServletResponse()::getStatus,
(status) -> status == 204);
Awaitility.await()
.atMost(Duration.ofSeconds(30))
.until(h1.getServletResponse()::getStatus, (status) -> status == 204);
MockHttpConnection h2 = new MockHttpConnection();
this.server.handle(h2);
Awaitility.await().atMost(Duration.ofSeconds(30)).until(h2.getServletResponse()::getStatus,
(status) -> status == 204);
Awaitility.await()
.atMost(Duration.ofSeconds(30))
.until(h2.getServletResponse()::getStatus, (status) -> status == 204);
this.serverChannel.disconnect();
this.server.getServerThread().join(JOIN_TIMEOUT);
}
@@ -264,7 +266,7 @@ class HttpTunnelServerTests {
@Test
void disconnectTimeoutMustBePositive() {
assertThatIllegalArgumentException().isThrownBy(() -> this.server.setDisconnectTimeout(0))
.withMessageContaining("DisconnectTimeout must be a positive value");
.withMessageContaining("DisconnectTimeout must be a positive value");
}
@Test

View File

@@ -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.
@@ -78,11 +78,12 @@ class SocketTargetServerConnectionTests {
try (ByteChannel channel = this.connection.open(10)) {
long startTime = System.currentTimeMillis();
assertThatExceptionOfType(SocketTimeoutException.class)
.isThrownBy(() -> channel.read(ByteBuffer.allocate(5))).satisfies((ex) -> {
long runTime = System.currentTimeMillis() - startTime;
assertThat(runTime).isGreaterThanOrEqualTo(10L);
assertThat(runTime).isLessThan(10000L);
});
.isThrownBy(() -> channel.read(ByteBuffer.allocate(5)))
.satisfies((ex) -> {
long runTime = System.currentTimeMillis() - startTime;
assertThat(runTime).isGreaterThanOrEqualTo(10L);
assertThat(runTime).isLessThan(10000L);
});
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -31,7 +31,7 @@ class StaticPortProviderTests {
@Test
void portMustBePositive() {
assertThatIllegalArgumentException().isThrownBy(() -> new StaticPortProvider(0))
.withMessageContaining("Port must be positive");
.withMessageContaining("Port must be positive");
}
@Test