Avoid blocking on a Mono indefinitely

Closes gh-15535
This commit is contained in:
Andy Wilkinson
2018-12-20 15:24:53 +00:00
parent 6403ec6e1b
commit 0741c90489
17 changed files with 139 additions and 91 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 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.
@@ -16,6 +16,8 @@
package org.springframework.boot.test.autoconfigure.data.mongo;
import java.time.Duration;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -44,10 +46,11 @@ public class DataMongoTestReactiveIntegrationTests {
public void testRepository() {
ExampleDocument exampleDocument = new ExampleDocument();
exampleDocument.setText("Look, new @DataMongoTest!");
exampleDocument = this.exampleRepository.save(exampleDocument).block();
exampleDocument = this.exampleRepository.save(exampleDocument)
.block(Duration.ofSeconds(30));
assertThat(exampleDocument.getId()).isNotNull();
assertThat(this.mongoTemplate.collectionExists("exampleDocuments").block())
.isTrue();
assertThat(this.mongoTemplate.collectionExists("exampleDocuments")
.block(Duration.ofSeconds(30))).isTrue();
}
}