-
Notifications
You must be signed in to change notification settings - Fork 38.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed "partitioned" attribute from DefaultCookie of ReactorClientHttp…
…Response.getCookies Signed-off-by: Rhett CfZhuang <[email protected]>
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...src/test/java/org/springframework/http/client/reactive/ReactorClientHttpResponseTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.springframework.http.client.reactive; | ||
|
||
import io.netty.buffer.AdaptiveByteBufAllocator; | ||
import io.netty.handler.codec.http.DefaultHttpHeaders; | ||
import io.netty.handler.codec.http.cookie.Cookie; | ||
import io.netty.handler.codec.http.cookie.DefaultCookie; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.http.ResponseCookie; | ||
import reactor.netty.Connection; | ||
import reactor.netty.NettyOutbound; | ||
import reactor.netty.http.client.HttpClientResponse; | ||
|
||
import java.util.*; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.BDDMockito.given; | ||
import static org.mockito.Mockito.mock; | ||
|
||
class ReactorClientHttpResponseTest { | ||
private final HttpClientResponse mockResponse = mock(); | ||
|
||
private final DefaultHttpHeaders httpHeaders = mock(); | ||
|
||
private final Connection connection = mock(); | ||
|
||
private final NettyOutbound outbound = mock(); | ||
|
||
private ReactorClientHttpResponse reactorClientHttpResponse; | ||
|
||
|
||
@BeforeEach | ||
void configureMocks() { | ||
given(mockResponse.responseHeaders()).willReturn(httpHeaders); | ||
given(connection.outbound()).willReturn(outbound); | ||
given(outbound.alloc()).willReturn(new AdaptiveByteBufAllocator()); | ||
reactorClientHttpResponse = new ReactorClientHttpResponse(mockResponse, connection); | ||
} | ||
|
||
@Test | ||
void defaultCookies() { | ||
Map<CharSequence, Set<Cookie>> mockCookieMap = new HashMap<>(); | ||
DefaultCookie cookie = new DefaultCookie("foo", "bar"); | ||
cookie.setPartitioned(true); | ||
mockCookieMap.put("foo", Set.of(cookie)); | ||
given(mockResponse.cookies()).willReturn(mockCookieMap); | ||
|
||
Assertions.assertTrue(reactorClientHttpResponse.getCookies().size() == 1 && | ||
reactorClientHttpResponse.getCookies().containsKey("foo")); | ||
ResponseCookie foo = reactorClientHttpResponse.getCookies().getFirst("foo"); | ||
assertThat(foo.isPartitioned()).isSameAs(cookie.isPartitioned()); | ||
} | ||
} |