Skip to content

Commit

Permalink
Refactor MySQLBinlogClientTest
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Aug 21, 2024
1 parent b82ad57 commit 0a3c131
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,11 @@ class MySQLBinlogClientTest {

@SuppressWarnings("unchecked")
@BeforeEach
void setUp() throws InterruptedException {
void setUp() {
client = new MySQLBinlogClient(new ConnectInfo(1, "host", 3306, "username", "password"), false);
when(channel.pipeline()).thenReturn(pipeline);
when(channel.isOpen()).thenReturn(true);
when(channel.close()).thenReturn(channelFuture);
when(channelFuture.sync()).thenAnswer(invocation -> {
when(channel.isOpen()).thenReturn(false);
return null;
});
when(channel.localAddress()).thenReturn(new InetSocketAddress("host", 3306));
when(channel.attr(MySQLConstants.SEQUENCE_ID_ATTRIBUTE_KEY)).thenReturn(mock(Attribute.class));
when(channel.attr(MySQLConstants.SEQUENCE_ID_ATTRIBUTE_KEY).get()).thenReturn(new AtomicInteger());
Expand Down Expand Up @@ -152,7 +148,7 @@ private void mockChannelResponseInThread(final Object response) {
}

@Test
void assertPollFailed() throws ReflectiveOperationException {
void assertPollOnNotRunning() throws ReflectiveOperationException {
Plugins.getMemberAccessor().set(MySQLBinlogClient.class.getDeclaredField("channel"), client, channel);
Plugins.getMemberAccessor().set(MySQLBinlogClient.class.getDeclaredField("running"), client, false);
assertThat(client.poll(), is(Collections.emptyList()));
Expand Down

0 comments on commit 0a3c131

Please sign in to comment.