org.springframework.http.client.reactive.JettyClientHttpConnector Java Examples

The following examples show how to use org.springframework.http.client.reactive.JettyClientHttpConnector. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpringWebFluxUnitTest.java    From tutorials with MIT License 6 votes vote down vote up
@Test
public void givenReactiveClient_whenRequested_shouldReturnResponse() throws Exception {
    
    HttpClient httpClient = new HttpClient();
    httpClient.start();

    ClientHttpConnector clientConnector = new JettyClientHttpConnector(httpClient);
    WebClient client = WebClient.builder()
        .clientConnector(clientConnector)
        .build();
    String responseContent = client.post()
        .uri(uri())
        .contentType(MediaType.TEXT_PLAIN)
        .body(BodyInserters.fromPublisher(Mono.just(CONTENT), String.class))
        .retrieve()
        .bodyToMono(String.class)
        .block();
    Assert.assertNotNull(responseContent);
    Assert.assertEquals(CONTENT, responseContent);
}
 
Example #2
Source File: WebClientLoggingIntegrationTest.java    From tutorials with MIT License 6 votes vote down vote up
@Test
public void givenJettyHttpClient_whenEndpointIsConsumed_thenRequestAndResponseBodyLogged() {
    SslContextFactory.Client sslContextFactory = new SslContextFactory.Client();
    org.eclipse.jetty.client.HttpClient httpClient = new org.eclipse.jetty.client.HttpClient(sslContextFactory) {
        @Override
        public Request newRequest(URI uri) {
            Request request = super.newRequest(uri);
            return enhance(request);
        }
    };

    WebClient
      .builder()
      .clientConnector(new JettyClientHttpConnector(httpClient))
      .build()
      .post()
      .uri(sampleUrl)
      .body(BodyInserters.fromObject(post))
      .retrieve()
      .bodyToMono(String.class)
      .block();

    verify(jettyAppender).doAppend(argThat(argument -> (((LoggingEvent) argument).getFormattedMessage()).contains(sampleResponseBody)));
}
 
Example #3
Source File: WebClientIntegrationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Parameterized.Parameters(name = "webClient [{0}]")
public static Object[][] arguments() {
	return new Object[][] {
			{new JettyClientHttpConnector()},
			{new ReactorClientHttpConnector()}
	};
}
 
Example #4
Source File: SseIntegrationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Parameterized.Parameters(name = "server [{0}] webClient [{1}]")
public static Object[][] arguments() {
	File base = new File(System.getProperty("java.io.tmpdir"));
	return new Object[][] {
			{new JettyHttpServer(), new ReactorClientHttpConnector()},
			{new JettyHttpServer(), new JettyClientHttpConnector()},
			{new ReactorHttpServer(), new ReactorClientHttpConnector()},
			{new ReactorHttpServer(), new JettyClientHttpConnector()},
			{new TomcatHttpServer(base.getAbsolutePath()), new ReactorClientHttpConnector()},
			{new TomcatHttpServer(base.getAbsolutePath()), new JettyClientHttpConnector()},
			{new UndertowHttpServer(), new ReactorClientHttpConnector()},
			{new UndertowHttpServer(), new JettyClientHttpConnector()}
	};
}
 
Example #5
Source File: WebClientIntegrationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Parameterized.Parameters(name = "webClient [{0}]")
public static Object[][] arguments() {
	return new Object[][] {
			{new JettyClientHttpConnector()},
			{new ReactorClientHttpConnector()}
	};
}
 
Example #6
Source File: SseIntegrationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Parameterized.Parameters(name = "server [{0}] webClient [{1}]")
public static Object[][] arguments() {
	File base = new File(System.getProperty("java.io.tmpdir"));
	return new Object[][] {
			{new JettyHttpServer(), new ReactorClientHttpConnector()},
			{new JettyHttpServer(), new JettyClientHttpConnector()},
			{new ReactorHttpServer(), new ReactorClientHttpConnector()},
			{new ReactorHttpServer(), new JettyClientHttpConnector()},
			{new TomcatHttpServer(base.getAbsolutePath()), new ReactorClientHttpConnector()},
			{new TomcatHttpServer(base.getAbsolutePath()), new JettyClientHttpConnector()},
			{new UndertowHttpServer(), new ReactorClientHttpConnector()},
			{new UndertowHttpServer(), new JettyClientHttpConnector()}
	};
}
 
Example #7
Source File: ClientHttpConnectorFactory.java    From spring-vault with Apache License 2.0 5 votes vote down vote up
static ClientHttpConnector usingJetty(ClientOptions options, SslConfiguration sslConfiguration) {

			try {
				return new JettyClientHttpConnector(configureClient(getHttpClient(sslConfiguration), options));
			}
			catch (GeneralSecurityException | IOException e) {
				throw new IllegalStateException(e);
			}
		}
 
Example #8
Source File: ClientConfig.java    From mutual-tls-ssl with Apache License 2.0 4 votes vote down vote up
@Bean
public WebClient webClientWithJetty(org.eclipse.jetty.client.HttpClient httpClient) {
    return WebClient.builder()
            .clientConnector(new JettyClientHttpConnector(httpClient))
            .build();
}