-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate adding push handlers in initializer
- Loading branch information
Karthik Yagna
committed
Oct 20, 2023
1 parent
8eeb23e
commit d7f3cb0
Showing
3 changed files
with
50 additions
and
13 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
44 changes: 44 additions & 0 deletions
44
...re/src/test/java/com/netflix/zuul/netty/server/push/PushMessageSenderInitializerTest.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,44 @@ | ||
package com.netflix.zuul.netty.server.push; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.mockito.Mockito.mock; | ||
import io.netty.channel.Channel; | ||
import io.netty.channel.ChannelHandler; | ||
import io.netty.channel.ChannelPipeline; | ||
import io.netty.channel.embedded.EmbeddedChannel; | ||
import io.netty.handler.codec.http.HttpObjectAggregator; | ||
import io.netty.handler.codec.http.HttpServerCodec; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* Unit tests for {@link PushMessageSenderInitializer}. | ||
*/ | ||
public class PushMessageSenderInitializerTest { | ||
private PushMessageSenderInitializer initializer; | ||
private Channel channel; | ||
private ChannelHandler handler; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
handler = mock(ChannelHandler.class); // Initialize mock handler | ||
|
||
initializer = new PushMessageSenderInitializer() { | ||
@Override | ||
protected void addPushMessageHandlers(ChannelPipeline pipeline) { | ||
pipeline.addLast("mockHandler", handler); | ||
} | ||
}; | ||
|
||
channel = new EmbeddedChannel(); | ||
} | ||
|
||
@Test | ||
public void testInitChannel() throws Exception { | ||
initializer.initChannel(channel); | ||
|
||
assertNotNull(channel.pipeline().context(HttpServerCodec.class)); | ||
assertNotNull(channel.pipeline().context(HttpObjectAggregator.class)); | ||
assertNotNull(channel.pipeline().get("mockHandler")); | ||
} | ||
} |
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