Reputation: 8172
I'm using Spring webflux via Spring boot 2.0.0.M3. Below is the dependencies of my project,
dependencies {
compile 'org.springframework.boot:spring-boot-starter-actuator',
'org.springframework.cloud:spring-cloud-starter-config',
'org.springframework.cloud:spring-cloud-sleuth-stream',
'org.springframework.cloud:spring-cloud-starter-sleuth',
'org.springframework.cloud:spring-cloud-starter-stream-rabbit',
'org.springframework.boot:spring-boot-starter-data-mongodb-reactive',
'org.springframework.boot:spring-boot-starter-data-redis-reactive',
'org.springframework.boot:spring-boot-starter-integration',
"org.springframework.integration:spring-integration-amqp",
"org.springframework.integration:spring-integration-mongodb",
'org.springframework.retry:spring-retry',
'org.springframework.boot:spring-boot-starter-webflux',
'org.springframework.boot:spring-boot-starter-reactor-netty',
'com.fasterxml.jackson.datatype:jackson-datatype-joda',
'joda-time:joda-time:2.9.9',
'org.javamoney:moneta:1.0',
'com.squareup.okhttp3:okhttp:3.8.1',
'org.apache.commons:commons-lang3:3.5'
compileOnly 'org.projectlombok:lombok:1.16.18'
testCompile 'org.springframework.boot:spring-boot-starter-test',
'io.projectreactor:reactor-test',
'org.apache.qpid:qpid-broker:6.1.2',
'de.flapdoodle.embed:de.flapdoodle.embed.mongo'
}
The app is running well via ./gradlew bootRun
or running main app directly.
However I failed to start integration test due to below error.
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
I'm wondering why WebTestClient still tries to use embedded tomcat even though we are using webflux that uses reactive-netty by default.
Is it something misconfiguration or bug of spring boot test?
Below is code snippet of my test case,
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class NoteHandlerTest {
@Autowired
private WebTestClient webClient;
@Test
public void testNoteNotFound() throws Exception {
this.webClient.get().uri("/note/request/{id}", "nosuchid").accept(MediaType.APPLICATION_JSON_UTF8)
.exchange().expectStatus().isNotFound();
}
}
Upvotes: 0
Views: 1761
Reputation: 8172
The error of launching tomcat was caused by test dependency org.apache.qpid:qpid-broker:6.1.2
, which depends on javax.serlvet-api:3.1
break the tomcat's startup.
Excluding below useless modules to make tomcat launching again,
configurations {
all*.exclude module: 'qpid-broker-plugins-management-http'
all*.exclude module: 'qpid-broker-plugins-websocket'
}
Upvotes: 1