Move WebClient to web.reactive.function.client

This commit is contained in:
Arjen Poutsma 2016-12-15 12:14:15 +01:00
parent dfcd5b9ed9
commit aa8f531526
22 changed files with 99 additions and 61 deletions

View File

@ -858,6 +858,7 @@ project("spring-web-reactive") {
testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}")
testCompile("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
testCompile("org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}")
testCompile("com.squareup.okhttp3:mockwebserver:${okhttp3Version}")
testRuntime("javax.el:javax.el-api:${elApiVersion}")
testRuntime("org.glassfish:javax.el:3.0.1-b08")
testRuntime("com.sun.xml.bind:jaxb-core:${jaxbVersion}")
@ -1466,6 +1467,22 @@ configure(project(':spring-core')) {
}
}
/*
* Copyright 2002-2016 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Support publication of artifacts versioned by topic branch.
* CI builds supply `-P BRANCH_NAME=<TOPIC>` to gradle at build time.

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.client.reactive;
package org.springframework.web.reactive.function.client;
import java.net.URI;
import java.nio.charset.Charset;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.client.reactive;
package org.springframework.web.reactive.function.client;
import java.util.List;
import java.util.Optional;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.client.reactive;
package org.springframework.web.reactive.function.client;
import java.net.URI;
import java.nio.charset.Charset;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.client.reactive;
package org.springframework.web.reactive.function.client;
import java.util.Collections;
import java.util.List;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.client.reactive;
package org.springframework.web.reactive.function.client;
import java.util.logging.Level;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.client.reactive;
package org.springframework.web.reactive.function.client;
import java.util.ArrayList;
import java.util.Collections;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.client.reactive;
package org.springframework.web.reactive.function.client;
import java.util.function.Function;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.client.reactive;
package org.springframework.web.reactive.function.client;
import java.nio.charset.StandardCharsets;
import java.util.Base64;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.client.reactive;
package org.springframework.web.reactive.function.client;
import reactor.core.publisher.Mono;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.client.reactive;
package org.springframework.web.reactive.function.client;
import reactor.core.publisher.Mono;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.client.reactive;
package org.springframework.web.reactive.function.client;
import org.springframework.core.NestedRuntimeException;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.client.reactive;
package org.springframework.web.reactive.function.client;
import java.util.function.Supplier;
import java.util.stream.Stream;

View File

@ -0,0 +1,22 @@
/*
* Copyright 2002-2016 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Provides a reactive {@link org.springframework.web.reactive.function.client.WebClient}
* that builds on top of the
* {@code org.springframework.http.client.reactive} reactive HTTP adapter layer.
*/
package org.springframework.web.reactive.function.client;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.http.server.reactive;
package org.springframework.web.reactive;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
@ -30,9 +30,13 @@ import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DataBufferFactory;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
import org.springframework.http.codec.BodyExtractors;
import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests;
import org.springframework.http.server.reactive.HttpHandler;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.util.Assert;
import org.springframework.web.client.reactive.ClientRequest;
import org.springframework.web.client.reactive.WebClient;
import org.springframework.web.reactive.function.client.ClientRequest;
import org.springframework.web.reactive.function.client.WebClient;
/**
* @author Sebastien Deleuze

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.client.reactive;
package org.springframework.web.reactive.function.client;
import java.net.URI;
import java.nio.ByteBuffer;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.client.reactive;
package org.springframework.web.reactive.function.client;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.client.reactive;
package org.springframework.web.reactive.function.client;
import org.junit.Test;
import reactor.core.publisher.Mono;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.client.reactive;
package org.springframework.web.reactive.function.client;
import java.time.Duration;
@ -24,6 +24,7 @@ import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
import org.hamcrest.Matchers;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import reactor.core.publisher.Flux;
@ -80,9 +81,9 @@ public class WebClientIntegrationTests {
.verify(Duration.ofSeconds(3));
RecordedRequest recordedRequest = server.takeRequest();
assertEquals(1, server.getRequestCount());
assertEquals("*/*", recordedRequest.getHeader(HttpHeaders.ACCEPT));
assertEquals("/greeting?name=Spring", recordedRequest.getPath());
Assert.assertEquals(1, server.getRequestCount());
Assert.assertEquals("*/*", recordedRequest.getHeader(HttpHeaders.ACCEPT));
Assert.assertEquals("/greeting?name=Spring", recordedRequest.getPath());
}
@Test
@ -104,10 +105,10 @@ public class WebClientIntegrationTests {
.verify(Duration.ofSeconds(3));
RecordedRequest recordedRequest = server.takeRequest();
assertEquals(1, server.getRequestCount());
assertEquals("testvalue", recordedRequest.getHeader("X-Test-Header"));
assertEquals("*/*", recordedRequest.getHeader(HttpHeaders.ACCEPT));
assertEquals("/greeting?name=Spring", recordedRequest.getPath());
Assert.assertEquals(1, server.getRequestCount());
Assert.assertEquals("testvalue", recordedRequest.getHeader("X-Test-Header"));
Assert.assertEquals("*/*", recordedRequest.getHeader(HttpHeaders.ACCEPT));
Assert.assertEquals("/greeting?name=Spring", recordedRequest.getPath());
}
@Test
@ -131,9 +132,9 @@ public class WebClientIntegrationTests {
.verify(Duration.ofSeconds(3));
RecordedRequest recordedRequest = server.takeRequest();
assertEquals(1, server.getRequestCount());
assertEquals("/json", recordedRequest.getPath());
assertEquals("application/json", recordedRequest.getHeader(HttpHeaders.ACCEPT));
Assert.assertEquals(1, server.getRequestCount());
Assert.assertEquals("/json", recordedRequest.getPath());
Assert.assertEquals("application/json", recordedRequest.getHeader(HttpHeaders.ACCEPT));
}
@Test
@ -156,9 +157,9 @@ public class WebClientIntegrationTests {
.verify(Duration.ofSeconds(3));
RecordedRequest recordedRequest = server.takeRequest();
assertEquals(1, server.getRequestCount());
assertEquals("/pojo", recordedRequest.getPath());
assertEquals("application/json", recordedRequest.getHeader(HttpHeaders.ACCEPT));
Assert.assertEquals(1, server.getRequestCount());
Assert.assertEquals("/pojo", recordedRequest.getPath());
Assert.assertEquals("application/json", recordedRequest.getHeader(HttpHeaders.ACCEPT));
}
@Test
@ -182,9 +183,9 @@ public class WebClientIntegrationTests {
.verify(Duration.ofSeconds(3));
RecordedRequest recordedRequest = server.takeRequest();
assertEquals(1, server.getRequestCount());
assertEquals("/pojos", recordedRequest.getPath());
assertEquals("application/json", recordedRequest.getHeader(HttpHeaders.ACCEPT));
Assert.assertEquals(1, server.getRequestCount());
Assert.assertEquals("/pojos", recordedRequest.getPath());
Assert.assertEquals("application/json", recordedRequest.getHeader(HttpHeaders.ACCEPT));
}
@Test
@ -210,12 +211,12 @@ public class WebClientIntegrationTests {
.verify(Duration.ofSeconds(3));
RecordedRequest recordedRequest = server.takeRequest();
assertEquals(1, server.getRequestCount());
assertEquals("/pojo/capitalize", recordedRequest.getPath());
assertEquals("{\"foo\":\"foofoo\",\"bar\":\"barbar\"}", recordedRequest.getBody().readUtf8());
assertEquals("chunked", recordedRequest.getHeader(HttpHeaders.TRANSFER_ENCODING));
assertEquals("application/json", recordedRequest.getHeader(HttpHeaders.ACCEPT));
assertEquals("application/json", recordedRequest.getHeader(HttpHeaders.CONTENT_TYPE));
Assert.assertEquals(1, server.getRequestCount());
Assert.assertEquals("/pojo/capitalize", recordedRequest.getPath());
Assert.assertEquals("{\"foo\":\"foofoo\",\"bar\":\"barbar\"}", recordedRequest.getBody().readUtf8());
Assert.assertEquals("chunked", recordedRequest.getHeader(HttpHeaders.TRANSFER_ENCODING));
Assert.assertEquals("application/json", recordedRequest.getHeader(HttpHeaders.ACCEPT));
Assert.assertEquals("application/json", recordedRequest.getHeader(HttpHeaders.CONTENT_TYPE));
}
@Test
@ -238,9 +239,9 @@ public class WebClientIntegrationTests {
.verify(Duration.ofSeconds(3));
RecordedRequest recordedRequest = server.takeRequest();
assertEquals(1, server.getRequestCount());
assertEquals("/test", recordedRequest.getPath());
assertEquals("testkey=testvalue", recordedRequest.getHeader(HttpHeaders.COOKIE));
Assert.assertEquals(1, server.getRequestCount());
Assert.assertEquals("/test", recordedRequest.getPath());
Assert.assertEquals("testkey=testvalue", recordedRequest.getHeader(HttpHeaders.COOKIE));
}
@Test
@ -262,9 +263,9 @@ public class WebClientIntegrationTests {
.verify(Duration.ofSeconds(3));
RecordedRequest recordedRequest = server.takeRequest();
assertEquals(1, server.getRequestCount());
assertEquals("*/*", recordedRequest.getHeader(HttpHeaders.ACCEPT));
assertEquals("/greeting?name=Spring", recordedRequest.getPath());
Assert.assertEquals(1, server.getRequestCount());
Assert.assertEquals("*/*", recordedRequest.getHeader(HttpHeaders.ACCEPT));
Assert.assertEquals("/greeting?name=Spring", recordedRequest.getPath());
}
@Test
@ -291,8 +292,8 @@ public class WebClientIntegrationTests {
.verify(Duration.ofSeconds(3));
RecordedRequest recordedRequest = server.takeRequest();
assertEquals(1, server.getRequestCount());
assertEquals("bar", recordedRequest.getHeader("foo"));
Assert.assertEquals(1, server.getRequestCount());
Assert.assertEquals("bar", recordedRequest.getHeader("foo"));
}
@ -320,8 +321,8 @@ public class WebClientIntegrationTests {
.verify(Duration.ofSeconds(3));
RecordedRequest recordedRequest = server.takeRequest();
assertEquals(1, server.getRequestCount());
assertEquals("bar", recordedRequest.getHeader("foo"));
Assert.assertEquals(1, server.getRequestCount());
Assert.assertEquals("bar", recordedRequest.getHeader("foo"));
}

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.client.reactive;
package org.springframework.web.reactive.function.client;
import java.util.Collections;
import java.util.List;

View File

@ -22,6 +22,7 @@ import org.junit.Before;
import org.junit.Test;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
@ -32,13 +33,12 @@ import org.springframework.http.codec.BodyExtractors;
import org.springframework.http.codec.ServerSentEvent;
import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests;
import org.springframework.http.server.reactive.HttpHandler;
import reactor.test.StepVerifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.reactive.ClientRequest;
import org.springframework.web.client.reactive.WebClient;
import org.springframework.web.reactive.DispatcherHandler;
import org.springframework.web.reactive.config.EnableWebReactive;
import org.springframework.web.reactive.function.client.ClientRequest;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;

View File

@ -1,6 +0,0 @@
/**
* Provides a reactive {@link org.springframework.web.client.reactive.WebClient}
* that builds on top of the
* {@code org.springframework.http.client.reactive} reactive HTTP adapter layer.
*/
package org.springframework.web.client.reactive;