当前位置: 首页>>代码示例>>Java>>正文


Java WebTestClient类代码示例

本文整理汇总了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();
}
 
开发者ID:dserradji,项目名称:reactive-customer-service,代码行数:8,代码来源:CustomerControllerWebTest.java

示例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();

}
 
开发者ID:papyrusglobal,项目名称:state-channels,代码行数:12,代码来源:LogsPublisher.java

示例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();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:23,代码来源:HystrixWebfluxEndpointTests.java

示例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\" }";
}
 
开发者ID:codecentric,项目名称:spring-boot-admin,代码行数:17,代码来源:InstancesControllerIntegrationTest.java

示例5: setup

import org.springframework.test.web.reactive.server.WebTestClient; //导入依赖的package包/类
@Before
public void setup() {
    this.rest = WebTestClient
        .bindToApplicationContext(this.context)
        .configureClient()
        .build();
}
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:8,代码来源:ApplicationTests.java

示例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();
}
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:9,代码来源:IntegrationTests.java

示例7: setup

import org.springframework.test.web.reactive.server.WebTestClient; //导入依赖的package包/类
@Before
public void setup() {
    this.rest = WebTestClient
        .bindToController(this.ctrl)
        .configureClient()
        .build();
}
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:8,代码来源:PostControllerTest.java

示例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();
}
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:9,代码来源:DemoApplicationTests.java

示例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();
}
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:10,代码来源:ApiDocumentation.java

示例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();
}
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:10,代码来源:IntegrationTests.java

示例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();
}
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:9,代码来源:IntegrationTests.java

示例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();
}
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:10,代码来源:ApplicationTests.java

示例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();
}
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:10,代码来源:IntegrationTests.java

示例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();
}
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:9,代码来源:ApplicationTests.java

示例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();
}
 
开发者ID:nkolytschew,项目名称:blog_post_examples,代码行数:14,代码来源:ConfigurationReactiveControllerTest.java


注:本文中的org.springframework.test.web.reactive.server.WebTestClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。