|
|
|
@ -16,13 +16,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.jetty.autoconfigure; |
|
|
|
package org.springframework.boot.jetty.autoconfigure; |
|
|
|
|
|
|
|
|
|
|
|
import java.time.Duration; |
|
|
|
import org.eclipse.jetty.util.thread.VirtualThreadPool; |
|
|
|
import java.util.concurrent.Executor; |
|
|
|
|
|
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.awaitility.Awaitility; |
|
|
|
|
|
|
|
import org.eclipse.jetty.util.thread.QueuedThreadPool; |
|
|
|
|
|
|
|
import org.hamcrest.Matchers; |
|
|
|
|
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
import org.junit.jupiter.api.condition.EnabledForJreRange; |
|
|
|
import org.junit.jupiter.api.condition.EnabledForJreRange; |
|
|
|
import org.junit.jupiter.api.condition.JRE; |
|
|
|
import org.junit.jupiter.api.condition.JRE; |
|
|
|
@ -50,14 +44,9 @@ class JettyVirtualThreadsWebServerFactoryCustomizerTests { |
|
|
|
ConfigurableJettyWebServerFactory factory = mock(ConfigurableJettyWebServerFactory.class); |
|
|
|
ConfigurableJettyWebServerFactory factory = mock(ConfigurableJettyWebServerFactory.class); |
|
|
|
customizer.customize(factory); |
|
|
|
customizer.customize(factory); |
|
|
|
then(factory).should().setThreadPool(assertArg((threadPool) -> { |
|
|
|
then(factory).should().setThreadPool(assertArg((threadPool) -> { |
|
|
|
assertThat(threadPool).isInstanceOf(QueuedThreadPool.class); |
|
|
|
assertThat(threadPool).isInstanceOf(VirtualThreadPool.class); |
|
|
|
QueuedThreadPool queuedThreadPool = (QueuedThreadPool) threadPool; |
|
|
|
VirtualThreadPool virtualThreadPool = (VirtualThreadPool) threadPool; |
|
|
|
Executor executor = queuedThreadPool.getVirtualThreadsExecutor(); |
|
|
|
assertThat(virtualThreadPool.getName()).isEqualTo("jetty-"); |
|
|
|
assertThat(executor).isNotNull(); |
|
|
|
|
|
|
|
AtomicReference<String> threadName = new AtomicReference<>(); |
|
|
|
|
|
|
|
executor.execute(() -> threadName.set(Thread.currentThread().getName())); |
|
|
|
|
|
|
|
Awaitility.await().atMost(Duration.ofSeconds(1)).untilAtomic(threadName, Matchers.notNullValue()); |
|
|
|
|
|
|
|
assertThat(threadName.get()).startsWith("jetty-"); |
|
|
|
|
|
|
|
})); |
|
|
|
})); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|