Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit51f7b83

Browse files
committed
Minor clean up: move all reactivestreams tests to same package
1 parent02c952a commit51f7b83

File tree

2 files changed

+58
-29
lines changed

2 files changed

+58
-29
lines changed

‎client/src/test/java/org/asynchttpclient/netty/handler/NettyReactiveStreamsTest.java‎renamed to ‎client/src/test/java/org/asynchttpclient/reactivestreams/FailingReactiveStreamsTest.java‎

Lines changed: 56 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1111
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
1212
*/
13-
packageorg.asynchttpclient.netty.handler;
13+
packageorg.asynchttpclient.reactivestreams;
1414

1515
importstaticorg.asynchttpclient.Dsl.asyncHttpClient;
1616
importstaticorg.asynchttpclient.test.TestUtils.LARGE_IMAGE_BYTES;
@@ -25,18 +25,20 @@
2525
importjava.util.concurrent.CountDownLatch;
2626
importjava.util.concurrent.atomic.AtomicReference;
2727

28+
importorg.asynchttpclient.AbstractBasicTest;
2829
importorg.asynchttpclient.AsyncHttpClient;
2930
importorg.asynchttpclient.HttpResponseBodyPart;
3031
importorg.asynchttpclient.handler.AsyncHandlerExtensions;
3132
importorg.asynchttpclient.netty.handler.StreamedResponsePublisher;
3233
importorg.asynchttpclient.netty.request.NettyRequest;
33-
importorg.asynchttpclient.reactivestreams.ReactiveStreamsTest;
34+
importorg.asynchttpclient.reactivestreams.ReactiveStreamsTest.SimpleStreamedAsyncHandler;
35+
importorg.asynchttpclient.reactivestreams.ReactiveStreamsTest.SimpleSubscriber;
3436
importorg.reactivestreams.Publisher;
3537
importorg.slf4j.Logger;
3638
importorg.slf4j.LoggerFactory;
3739
importorg.testng.annotations.Test;
3840

39-
publicclassNettyReactiveStreamsTestextendsReactiveStreamsTest {
41+
publicclassFailingReactiveStreamsTestextendsAbstractBasicTest {
4042

4143
@Test(groups ="standalone")
4244
publicvoidtestRetryingOnFailingStream()throwsException {
@@ -45,20 +47,17 @@ public void testRetryingOnFailingStream() throws Exception {
4547
finalCountDownLatchstreamOnHold =newCountDownLatch(1);// allows us to hold the subscriber from processing further body chunks
4648
finalCountDownLatchreplayingRequest =newCountDownLatch(1);// allows us to block until the request is being replayed ( this is what we want to test here!)
4749

48-
// a ref to the publisher is needed to get a hold on the channel (if there is a better way, this should be changed)
50+
// a ref to the publisher is needed to get a hold on the channel (if there is a better way, this should be changed)
4951
finalAtomicReference<StreamedResponsePublisher>publisherRef =newAtomicReference<>(null);
5052

5153
// executing the request
52-
client.preparePost(getTargetUrl())
53-
.setBody(LARGE_IMAGE_BYTES)
54-
.execute(newReplayedSimpleAsyncHandler(replayingRequest,
55-
newBlockedStreamSubscriber(streamStarted,streamOnHold)) {
54+
client.preparePost(getTargetUrl()).setBody(LARGE_IMAGE_BYTES)
55+
.execute(newReplayedSimpleAsyncHandler(replayingRequest,newBlockedStreamSubscriber(streamStarted,streamOnHold)) {
5656
@Override
5757
publicStateonStream(Publisher<HttpResponseBodyPart>publisher) {
58-
if(!(publisherinstanceofStreamedResponsePublisher)) {
58+
if(!(publisherinstanceofStreamedResponsePublisher)) {
5959
thrownewIllegalStateException(String.format("publisher %s is expected to be an instance of %s",publisher,StreamedResponsePublisher.class));
60-
}
61-
elseif(!publisherRef.compareAndSet(null, (StreamedResponsePublisher)publisher)) {
60+
}elseif (!publisherRef.compareAndSet(null, (StreamedResponsePublisher)publisher)) {
6261
// abort on retry
6362
returnState.ABORT;
6463
}
@@ -87,7 +86,7 @@ public void operationComplete(ChannelFuture future) throws Exception {
8786
// now we expect a new connection to be created and AHC retry logic to kick-in automatically
8887
replayingRequest.await();// wait until we are notified the request is being replayed
8988

90-
// Change this if there is a better way of stating the test succeeded
89+
// Change this if there is a better way of stating the test succeeded
9190
assertTrue(true);
9291
}
9392
}
@@ -119,40 +118,70 @@ public void onNext(HttpResponseBodyPart t) {
119118
super.onNext(t);
120119
}
121120
}
122-
121+
123122
privatestaticclassReplayedSimpleAsyncHandlerextendsSimpleStreamedAsyncHandlerimplementsAsyncHandlerExtensions {
124123
privatefinalCountDownLatchreplaying;
124+
125125
publicReplayedSimpleAsyncHandler(CountDownLatchreplaying,SimpleSubscriber<HttpResponseBodyPart>subscriber) {
126126
super(subscriber);
127127
this.replaying =replaying;
128128
}
129+
129130
@Override
130-
publicvoidonHostnameResolutionAttempt(Stringname) {}
131+
publicvoidonHostnameResolutionAttempt(Stringname) {
132+
}
133+
131134
@Override
132-
publicvoidonHostnameResolutionSuccess(Stringname,List<InetSocketAddress>addresses) {}
135+
publicvoidonHostnameResolutionSuccess(Stringname,List<InetSocketAddress>addresses) {
136+
}
137+
133138
@Override
134-
publicvoidonHostnameResolutionFailure(Stringname,Throwablecause) {}
139+
publicvoidonHostnameResolutionFailure(Stringname,Throwablecause) {
140+
}
141+
135142
@Override
136-
publicvoidonTcpConnectAttempt(InetSocketAddressaddress) {}
143+
publicvoidonTcpConnectAttempt(InetSocketAddressaddress) {
144+
}
145+
137146
@Override
138-
publicvoidonTcpConnectSuccess(InetSocketAddressaddress,Channelconnection) {}
147+
publicvoidonTcpConnectSuccess(InetSocketAddressaddress,Channelconnection) {
148+
}
149+
139150
@Override
140-
publicvoidonTcpConnectFailure(InetSocketAddressaddress,Throwablecause) {}
151+
publicvoidonTcpConnectFailure(InetSocketAddressaddress,Throwablecause) {
152+
}
153+
141154
@Override
142-
publicvoidonTlsHandshakeAttempt() {}
155+
publicvoidonTlsHandshakeAttempt() {
156+
}
157+
143158
@Override
144-
publicvoidonTlsHandshakeSuccess() {}
159+
publicvoidonTlsHandshakeSuccess() {
160+
}
161+
145162
@Override
146-
publicvoidonTlsHandshakeFailure(Throwablecause) {}
163+
publicvoidonTlsHandshakeFailure(Throwablecause) {
164+
}
165+
147166
@Override
148-
publicvoidonConnectionPoolAttempt() {}
167+
publicvoidonConnectionPoolAttempt() {
168+
}
169+
149170
@Override
150-
publicvoidonConnectionPooled(Channelconnection) {}
171+
publicvoidonConnectionPooled(Channelconnection) {
172+
}
173+
151174
@Override
152-
publicvoidonConnectionOffer(Channelconnection) {}
175+
publicvoidonConnectionOffer(Channelconnection) {
176+
}
177+
153178
@Override
154-
publicvoidonRequestSend(NettyRequestrequest) {}
179+
publicvoidonRequestSend(NettyRequestrequest) {
180+
}
181+
155182
@Override
156-
publicvoidonRetry() {replaying.countDown(); }
183+
publicvoidonRetry() {
184+
replaying.countDown();
185+
}
157186
}
158187
}

‎client/src/test/java/org/asynchttpclient/reactivestreams/ReactiveStreamsTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public void cancelStreamedResponseTest() throws Throwable {
162162
}
163163
}
164164

165-
staticprotectedclassSimpleStreamedAsyncHandlerimplementsStreamedAsyncHandler<SimpleStreamedAsyncHandler> {
165+
staticclassSimpleStreamedAsyncHandlerimplementsStreamedAsyncHandler<SimpleStreamedAsyncHandler> {
166166
privatefinalSimpleSubscriber<HttpResponseBodyPart>subscriber;
167167

168168
publicSimpleStreamedAsyncHandler() {
@@ -217,7 +217,7 @@ public byte[] getBytes() throws Throwable {
217217
/**
218218
* Simple subscriber that requests and buffers one element at a time.
219219
*/
220-
staticprotectedclassSimpleSubscriber<T>implementsSubscriber<T> {
220+
staticclassSimpleSubscriber<T>implementsSubscriber<T> {
221221
privatevolatileSubscriptionsubscription;
222222
privatevolatileThrowableerror;
223223
privatefinalList<T>elements =Collections.synchronizedList(newArrayList<>());

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp