本文整理汇总了Java中org.springframework.test.web.reactive.server.WebTestClient类的典型用法代码示例。如果您正苦于以下问题:Java WebTestClient类的具体用法?Java WebTestClient怎么用?Java WebTestClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WebTestClient类属于org.springframework.test.web.reactive.server包,在下文中一共展示了WebTestClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.springframework.test.web.reactive.server.WebTestClient; //导入依赖的package包/类
@Before
public void init() {
webClient = WebTestClient
.bindToController(new CustomerController(repo))
.controllerAdvice(CustomerServiceExceptionHandler.class) // Doesn't seem to work hence the HTTP 500 instead of HTTP 400 in some tests
.build();
}
示例2: main
import org.springframework.test.web.reactive.server.WebTestClient; //导入依赖的package包/类
public static void main(String[] args) {
Stream<ByteBuffer> chunkedData = Stream.generate(() -> ByteBuffer.wrap((UUID.randomUUID().toString() + "\n").getBytes())).limit(10);
WebTestClient client = WebTestClient.bindToServer().baseUrl("http://localhost:8080").build();
client.post()
.uri("/blocks")
.header("X-Block-Id", UUID.randomUUID().toString())
.body(Flux.fromStream(chunkedData), ByteBuffer.class)
.exchange()
.expectStatus().is2xxSuccessful();
}
示例3: hystrixStreamWorks
import org.springframework.test.web.reactive.server.WebTestClient; //导入依赖的package包/类
@Test
public void hystrixStreamWorks() {
String url = "http://localhost:" + port;
// you have to hit a Hystrix circuit breaker before the stream sends anything
WebTestClient testClient = WebTestClient.bindToServer().baseUrl(url).build();
testClient.get().uri("/").exchange().expectStatus().isOk();
WebClient client = WebClient.create(url);
Flux<String> result = client.get().uri(BASE_PATH + "/hystrix.stream")
.accept(MediaType.TEXT_EVENT_STREAM)
.exchange()
.flatMapMany(res -> res.bodyToFlux(Map.class))
.take(5)
.filter(map -> "HystrixCommand".equals(map.get("type")))
.map(map -> (String)map.get("type"));
StepVerifier.create(result)
.expectNext("HystrixCommand")
.thenCancel()
.verify();
}
示例4: setUp
import org.springframework.test.web.reactive.server.WebTestClient; //导入依赖的package包/类
@Before
public void setUp() {
instance = new SpringApplicationBuilder().sources(AdminApplicationTest.TestAdminApplication.class)
.web(WebApplicationType.REACTIVE)
.run("--server.port=0", "--eureka.client.enabled=false");
localPort = instance.getEnvironment().getProperty("local.server.port", Integer.class, 0);
this.client = WebTestClient.bindToServer().baseUrl("http://localhost:" + localPort).build();
this.register_as_test = "{ \"name\": \"test\", \"healthUrl\": \"http://localhost:" +
localPort +
"/application/health\" }";
this.register_as_twice = "{ \"name\": \"twice\", \"healthUrl\": \"http://localhost:" +
localPort +
"/application/health\" }";
}
示例5: setup
import org.springframework.test.web.reactive.server.WebTestClient; //导入依赖的package包/类
@Before
public void setup() {
this.rest = WebTestClient
.bindToApplicationContext(this.context)
.configureClient()
.build();
}
示例6: setup
import org.springframework.test.web.reactive.server.WebTestClient; //导入依赖的package包/类
@Before
public void setup() {
this.rest = WebTestClient
.bindToServer()
.responseTimeout(Duration.ofDays(1))
.baseUrl("http://localhost:" + this.port)
.build();
}
示例7: setup
import org.springframework.test.web.reactive.server.WebTestClient; //导入依赖的package包/类
@Before
public void setup() {
this.rest = WebTestClient
.bindToController(this.ctrl)
.configureClient()
.build();
}
示例8: setup
import org.springframework.test.web.reactive.server.WebTestClient; //导入依赖的package包/类
@Before
public void setup() {
client = WebTestClient
.bindToApplicationContext(context)
.configureClient()
.baseUrl("http://localhost:8080/")
.build();
}
示例9: setup
import org.springframework.test.web.reactive.server.WebTestClient; //导入依赖的package包/类
@Before
public void setup() {
this.client = WebTestClient
.bindToApplicationContext(this.context)
.configureClient()
.baseUrl("https://api.example.com")
.filter(documentationConfiguration(restDocumentation))
.build();
}
示例10: setup
import org.springframework.test.web.reactive.server.WebTestClient; //导入依赖的package包/类
@Before
public void setup() {
this.rest = WebTestClient
.bindToServer()
.responseTimeout(Duration.ofDays(1))
.baseUrl("http://localhost:9000")
.filter(basicAuthentication())
.build();
}
示例11: setup
import org.springframework.test.web.reactive.server.WebTestClient; //导入依赖的package包/类
@Before
public void setup() {
this.rest = WebTestClient
.bindToServer()
.responseTimeout(Duration.ofDays(1))
.baseUrl("http://localhost:8080")
.build();
}
示例12: setup
import org.springframework.test.web.reactive.server.WebTestClient; //导入依赖的package包/类
@Before
public void setup() {
this.rest = WebTestClient
.bindToApplicationContext(this.context)
.apply(springSecurity())
.configureClient()
.filter(basicAuthentication())
.build();
}
示例13: setup
import org.springframework.test.web.reactive.server.WebTestClient; //导入依赖的package包/类
@Before
public void setup() {
this.rest = WebTestClient
.bindToServer()
.responseTimeout(Duration.ofSeconds(10))
.baseUrl("http://localhost:" + this.port)
.filter(basicAuthentication())
.build();
}
示例14: setup
import org.springframework.test.web.reactive.server.WebTestClient; //导入依赖的package包/类
@Before
public void setup() {
this.rest = WebTestClient
.bindToServer()
.responseTimeout(Duration.ofMinutes(1))
.baseUrl("http://localhost:" + this.port)
.build();
}
示例15: setUp
import org.springframework.test.web.reactive.server.WebTestClient; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
// make sure db is empty before each test
configurationRepository.deleteAll().subscribe();
ratingRepository.deleteAll().subscribe();
// create WebTestClient
this.webTestClient = WebTestClient.bindToController(new ConfigurationReactiveController(configurationRepository)).build();
// create one entry
configurationRepository.save(DocBuilder.getSimpleConfigurationDoc()).subscribe();
ratingRepository.save(DocBuilder.getSimpleRatingDoc()).subscribe();
}