Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Issue 509: `HttpServerToConnectionBridge` was calling `ctx.fireUserEvent..` method instead of `super.userEv..` which will make the second subscriber unregistered. Now calling `super.userEven..`. Also added a test for this. - `AbstractHttpConnectionBridge` was setting the status as complete before invoking the subscribers. This will cause issues for concatenated subscribers as the second subscriber to the content will see that the content is already completed.
- Loading branch information
1 parent
103b21f
commit 8c70db9
Showing
5 changed files
with
78 additions
and
9 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
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
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
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
45 changes: 45 additions & 0 deletions
45
...c/test/java/io/reactivex/netty/protocol/http/server/HttpServerToConnectionBridgeTest.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,45 @@ | ||
package io.reactivex.netty.protocol.http.server; | ||
|
||
import io.reactivex.netty.protocol.http.internal.AbstractHttpConnectionBridge; | ||
import io.reactivex.netty.protocol.http.internal.AbstractHttpConnectionBridgeTest.AbstractHttpConnectionBridgeMock; | ||
import io.reactivex.netty.protocol.http.internal.AbstractHttpConnectionBridgeTest.HandlerRule; | ||
import io.reactivex.netty.protocol.http.internal.HttpContentSubscriberEvent; | ||
import io.reactivex.netty.protocol.http.server.events.HttpServerEventPublisher; | ||
import io.reactivex.netty.protocol.tcp.server.events.TcpServerEventPublisher; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import rx.observers.TestSubscriber; | ||
|
||
import java.nio.channels.ClosedChannelException; | ||
|
||
public class HttpServerToConnectionBridgeTest { | ||
|
||
@Rule | ||
public final HandlerRule handlerRule = new HandlerRule() { | ||
@Override | ||
protected AbstractHttpConnectionBridge<String> newAbstractHttpConnectionBridgeMock() { | ||
return new HttpServerToConnectionBridge<>(new HttpServerEventPublisher(new TcpServerEventPublisher())); | ||
} | ||
}; | ||
|
||
@Test(timeout = 60000) | ||
public void testPendingContentSubscriber() throws Exception { | ||
handlerRule.setupAndAssertConnectionInputSub(); | ||
handlerRule.simulateHeaderReceive(); /*Simulate header receive, required for content sub.*/ | ||
TestSubscriber<String> subscriber = new TestSubscriber<>(); | ||
handlerRule.getChannel().pipeline().fireUserEventTriggered(new HttpContentSubscriberEvent<>(subscriber)); | ||
TestSubscriber<String> subscriber1 = new TestSubscriber<>(); | ||
handlerRule.getChannel().pipeline().fireUserEventTriggered(new HttpContentSubscriberEvent<>(subscriber1)); | ||
|
||
subscriber.assertNoErrors(); | ||
subscriber1.assertNoErrors(); | ||
subscriber.unsubscribe(); | ||
|
||
subscriber.assertUnsubscribed(); | ||
|
||
handlerRule.getChannel().close().await(); | ||
|
||
subscriber.assertNoErrors(); | ||
subscriber1.assertError(ClosedChannelException.class); | ||
} | ||
} |