-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added spring boot 3.2 support #675
Changes from 1 commit
511919e
5d7d393
3f73b3a
c22e464
1a23e54
35a3398
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
import reactor.core.publisher.Mono; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.spy; | ||
import static org.mockito.Mockito.verify; | ||
|
||
public class DefaultMethodHandlerTest extends BaseReactorTest { | ||
|
@@ -36,7 +37,7 @@ public void shouldCallNotDefaultMethodOnActualImplementation() throws Throwable | |
DefaultMethodHandler defaultMethodHandler | ||
= new DefaultMethodHandler(TestInterface.class.getMethod("defaultMethod")); | ||
|
||
TestInterface mockImplementation = mock(TestInterface.class); | ||
TestInterface mockImplementation = spy(TestInterface.class); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why spy? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've reverted changes to use mock |
||
|
||
defaultMethodHandler.bindTo(mockImplementation); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,16 +42,16 @@ | |
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.ConcurrentLinkedQueue; | ||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
import static java.util.Arrays.asList; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.awaitility.Awaitility.waitAtMost; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
import static reactivefeign.ReactivityTest.CALLS_NUMBER; | ||
import static reactivefeign.ReactivityTest.timeToCompleteReactively; | ||
import static reactivefeign.TestUtils.toLowerCaseKeys; | ||
|
@@ -99,16 +99,17 @@ public void setUp() { | |
|
||
@Test | ||
public void shouldReturnAllPassedParameters() { | ||
Map<String, String> paramMap = new HashMap<String, String>() {{ | ||
put("paramKey1", "paramValue1"); | ||
put("paramKey2", "paramValue2"); | ||
}}; | ||
Map<String, String> returned = client.mirrorParameters(555,"777", paramMap) | ||
.subscribeOn(testScheduler()).block(); | ||
Map<String, String> paramMap = Map.of("paramKey1", "paramValue1", "paramKey2", "paramValue2"); | ||
|
||
assertThat(returned).containsEntry("paramInPath", "555"); | ||
assertThat(returned).containsEntry("paramInUrl", "777"); | ||
assertThat(returned).containsAllEntriesOf(paramMap); | ||
Mono<Map<String, String>> result = client.mirrorParameters(555,"777", paramMap) | ||
.subscribeOn(testScheduler()); | ||
|
||
StepVerifier.create(result) | ||
.consumeNextWith(returned -> { | ||
assertThat(returned).containsEntry("paramInPath", "555"); | ||
assertThat(returned).containsEntry("paramInUrl", "777"); | ||
assertThat(returned).containsAllEntriesOf(paramMap); | ||
}); | ||
} | ||
|
||
@Test | ||
|
@@ -118,11 +119,15 @@ public void shouldReturnEmptyPassedParameters() { | |
put("paramKey", ""); | ||
} | ||
}; | ||
Map<String, String> returned = client.mirrorParameters(555,"", paramMap) | ||
.subscribeOn(testScheduler()).block(); | ||
Mono<Map<String, String>> returned = client.mirrorParameters(555,"", paramMap) | ||
.subscribeOn(testScheduler()); | ||
|
||
assertThat(returned).containsEntry("paramKey", ""); | ||
assertThat(returned).containsEntry("paramInUrl", ""); | ||
StepVerifier.create(returned) | ||
.consumeNextWith(map -> { | ||
assertThat(map).containsEntry("paramKey", ""); | ||
assertThat(map).containsEntry("paramInUrl", ""); | ||
}) | ||
.verifyComplete(); | ||
} | ||
|
||
@Test | ||
|
@@ -173,10 +178,12 @@ public void shouldNotReturnNullPassedParametersNew() { | |
public void shouldReturnAllPassedListParametersNew() { | ||
|
||
List<Integer> dynamicListParam = asList(1, 2, 3); | ||
List<Integer> returned = client.mirrorListParametersNew(dynamicListParam) | ||
.subscribeOn(testScheduler()).block(); | ||
Mono<List<Integer>> result = client.mirrorListParametersNew(dynamicListParam) | ||
.subscribeOn(testScheduler()); | ||
|
||
assertThat(returned).containsAll(dynamicListParam); | ||
StepVerifier.create(result) | ||
.consumeNextWith(returned -> assertThat(returned).containsAll(dynamicListParam)) | ||
.verifyComplete(); | ||
} | ||
|
||
@Test | ||
|
@@ -251,13 +258,17 @@ public void shouldReturnAllPassedListHeaders() { | |
public void shouldReturnAllPassedMultiMapHeaders() { | ||
Map<String, List<String>> headersMap = new HashMap<String, List<String>>() { | ||
{ | ||
put("headerKey1", asList("headerValue1", "headerValue2")); | ||
put("headerKey1", List.of("headerValue1, headerValue2")); | ||
} | ||
}; | ||
Map<String, List<String>> returned = client.mirrorMultiMapHeaders(headersMap) | ||
.subscribeOn(testScheduler()).block(); | ||
Mono<Map<String, List<String>>> result = client.mirrorMultiMapHeaders(headersMap) | ||
.subscribeOn(testScheduler()); | ||
|
||
assertThat(toLowerCaseKeys(returned)).containsAllEntriesOf(toLowerCaseKeys(headersMap)); | ||
StepVerifier.create(result) | ||
.consumeNextWith(returned -> { | ||
assertNotNull(returned); | ||
assertThat(toLowerCaseKeys(returned)).containsAllEntriesOf(toLowerCaseKeys(headersMap)); | ||
}); | ||
} | ||
|
||
@Test | ||
|
@@ -321,7 +332,7 @@ public void shouldReturnFirstResultBeforeSecondSent() throws InterruptedExceptio | |
AtomicInteger sentCount = new AtomicInteger(); | ||
AtomicInteger receivedCount = new AtomicInteger(); | ||
|
||
CompletableFuture<AllFeaturesApi.TestObject> firstReceived = new CompletableFuture<>(); | ||
CompletableFuture<AllFeaturesApi.TestObject> firstReceived = CompletableFuture.completedFuture(null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't want completed future here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
Flux<AllFeaturesApi.TestObject> returned = client | ||
.mirrorBodyStream(Flux.just(new AllFeaturesApi.TestObject("testMessage1"), | ||
|
@@ -337,14 +348,17 @@ public void shouldReturnFirstResultBeforeSecondSent() throws InterruptedExceptio | |
countDownLatch.countDown(); | ||
}).subscribe(); | ||
|
||
countDownLatch.await(); | ||
boolean await = countDownLatch.await(5, TimeUnit.SECONDS); | ||
assertThat(await).isTrue(); | ||
} | ||
|
||
@Test | ||
public void shouldReturnEmpty() { | ||
Optional<AllFeaturesApi.TestObject> returned = client.empty() | ||
.subscribeOn(testScheduler()).blockOptional(); | ||
assertThat(!returned.isPresent()); | ||
Mono<AllFeaturesApi.TestObject> returned = client.empty() | ||
.subscribeOn(testScheduler()); | ||
|
||
StepVerifier.create(returned) | ||
.verifyComplete(); | ||
} | ||
|
||
@Test | ||
|
@@ -354,7 +368,6 @@ public void shouldReturnDefaultBody() { | |
assertThat(returned).isEqualTo("default"); | ||
} | ||
|
||
|
||
@Test | ||
public void shouldRunReactively() { | ||
|
||
|
@@ -411,33 +424,30 @@ public void shouldMirrorBinaryBody() { | |
|
||
@Test | ||
public void shouldMirrorStreamingBinaryBodyReactive() throws InterruptedException { | ||
|
||
CountDownLatch countDownLatch = new CountDownLatch(2); | ||
|
||
AtomicInteger sentCount = new AtomicInteger(); | ||
ConcurrentLinkedQueue<byte[]> receivedAll = new ConcurrentLinkedQueue<>(); | ||
|
||
CompletableFuture<ByteBuffer> firstReceived = new CompletableFuture<>(); | ||
CompletableFuture<ByteBuffer> firstReceived = CompletableFuture.completedFuture(null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't want completed future here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
Flux<ByteBuffer> returned = client.mirrorStreamingBinaryBodyReactive( | ||
Flux.just(fromByteArray(new byte[]{1,2,3}), fromByteArray(new byte[]{4,5,6}))) | ||
Flux.just(fromByteArray(new byte[]{1, 2, 3}), fromByteArray(new byte[]{4, 5, 6}))) | ||
.subscribeOn(testScheduler()) | ||
.delayUntil(testObject -> sentCount.get() == 1 ? fromFuture(firstReceived) | ||
: empty()) | ||
.doOnNext(sent -> sentCount.incrementAndGet()); | ||
|
||
returned.doOnNext(received -> { | ||
byte[] dataReceived = new byte[received.limit()]; | ||
received.get(dataReceived); | ||
receivedAll.add(dataReceived); | ||
assertThat(receivedAll.size()).isEqualTo(sentCount.get()); | ||
firstReceived.complete(received); | ||
countDownLatch.countDown(); | ||
}).subscribe(); | ||
|
||
countDownLatch.await(); | ||
|
||
assertThat(receivedAll).containsExactly(new byte[]{1,2,3}, new byte[]{4,5,6}); | ||
StepVerifier.create(returned) | ||
.consumeNextWith(byteBuffer -> { | ||
ByteBuffer expectedBuffer = ByteBuffer.allocateDirect(3) | ||
.put(new byte[]{1, 2, 3}) | ||
.position(0); | ||
assertEquals(expectedBuffer, byteBuffer); | ||
}) | ||
.consumeNextWith(byteBuffer -> { | ||
ByteBuffer expectedBuffer = ByteBuffer.allocateDirect(3) | ||
.put(new byte[]{4, 5, 6}) | ||
.position(0); | ||
assertEquals(expectedBuffer, byteBuffer); | ||
}) | ||
.verifyComplete(); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
|
@@ -480,7 +490,7 @@ public void shouldEncodePathParam() { | |
|
||
@Test | ||
public void shouldEncodePathParamWithReservedChars() { | ||
String PATH_PARAM = "workers?in=(\"123/321\")"; | ||
String PATH_PARAM = "workers?in=(\"123321\")"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why did you change this test string? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. jetty12 (as Servlet 6) no longer supports / as part of the path section of the URI |
||
|
||
StepVerifier.create(client.encodePath(PATH_PARAM) | ||
.subscribeOn(testScheduler())) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you changed equals to startsWith?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reverted changes