Skip to content

Commit f29f401

Browse files
committed
final
1 parent 26241c6 commit f29f401

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

wrapper/src/test/java/software/amazon/jdbc/hostlistprovider/RdsHostListProviderTest.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import java.util.concurrent.TimeUnit;
4949
import org.junit.jupiter.api.AfterEach;
5050
import org.junit.jupiter.api.BeforeEach;
51-
import org.junit.jupiter.api.Disabled;
5251
import org.junit.jupiter.api.Test;
5352
import org.mockito.ArgumentCaptor;
5453
import org.mockito.Captor;
@@ -465,7 +464,6 @@ void testIdentifyConnectionWithInvalidNodeIdQuery() throws SQLException {
465464
}
466465

467466
@Test
468-
@Disabled
469467
void testIdentifyConnectionNullTopology() throws SQLException {
470468
rdsHostListProvider = Mockito.spy(getRdsHostListProvider(
471469
mockHostListProviderService,
@@ -475,8 +473,8 @@ void testIdentifyConnectionNullTopology() throws SQLException {
475473

476474
when(mockResultSet.next()).thenReturn(true);
477475
when(mockResultSet.getString(eq(1))).thenReturn("instance-1");
478-
when(rdsHostListProvider.refresh(eq(mockConnection))).thenReturn(null);
479-
when(rdsHostListProvider.forceRefresh(eq(mockConnection))).thenReturn(null);
476+
doReturn(null).when(rdsHostListProvider).refresh(mockConnection);
477+
doReturn(null).when(rdsHostListProvider).forceRefresh(mockConnection);
480478

481479
assertNull(rdsHostListProvider.identifyConnection(mockConnection));
482480
}
@@ -495,14 +493,13 @@ void testIdentifyConnectionHostNotInTopology() throws SQLException {
495493
"jdbc:someprotocol://url"));
496494
when(mockResultSet.next()).thenReturn(true);
497495
when(mockResultSet.getString(eq(1))).thenReturn("instance-1");
498-
when(rdsHostListProvider.refresh(eq(mockConnection))).thenReturn(cachedTopology);
499-
when(rdsHostListProvider.forceRefresh(eq(mockConnection))).thenReturn(cachedTopology);
496+
doReturn(cachedTopology).when(rdsHostListProvider).refresh(mockConnection);
497+
doReturn(cachedTopology).when(rdsHostListProvider).forceRefresh(mockConnection);
500498

501499
assertNull(rdsHostListProvider.identifyConnection(mockConnection));
502500
}
503501

504502
@Test
505-
@Disabled
506503
void testIdentifyConnectionHostInTopology() throws SQLException {
507504
final HostSpec expectedHost = new HostSpecBuilder(new SimpleHostAvailabilityStrategy())
508505
.host("instance-a-1.xyz.us-east-2.rds.amazonaws.com")
@@ -517,7 +514,8 @@ void testIdentifyConnectionHostInTopology() throws SQLException {
517514
"jdbc:someprotocol://url"));
518515
when(mockResultSet.next()).thenReturn(true);
519516
when(mockResultSet.getString(eq(1))).thenReturn("instance-a-1");
520-
when(rdsHostListProvider.refresh()).thenReturn(cachedTopology);
517+
doReturn(cachedTopology).when(rdsHostListProvider).refresh(mockConnection);
518+
doReturn(cachedTopology).when(rdsHostListProvider).forceRefresh(mockConnection);
521519

522520
final HostSpec actual = rdsHostListProvider.identifyConnection(mockConnection);
523521
assertEquals("instance-a-1.xyz.us-east-2.rds.amazonaws.com", actual.getHost());

wrapper/src/test/java/software/amazon/jdbc/hostlistprovider/RdsMultiAzDbClusterListProviderTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,8 @@ void testIdentifyConnectionNullTopology() throws SQLException {
455455

456456
when(mockResultSet.next()).thenReturn(true);
457457
when(mockResultSet.getString(eq(1))).thenReturn("instance-1");
458-
when(rdsMazDbClusterHostListProvider.refresh(eq(mockConnection))).thenReturn(null);
459-
when(rdsMazDbClusterHostListProvider.forceRefresh(eq(mockConnection))).thenReturn(null);
458+
doReturn(null).when(rdsMazDbClusterHostListProvider).refresh(mockConnection);
459+
doReturn(null).when(rdsMazDbClusterHostListProvider).forceRefresh(mockConnection);
460460

461461
assertNull(rdsMazDbClusterHostListProvider.identifyConnection(mockConnection));
462462
}
@@ -475,8 +475,8 @@ void testIdentifyConnectionHostNotInTopology() throws SQLException {
475475
"jdbc:someprotocol://url"));
476476
when(mockResultSet.next()).thenReturn(true);
477477
when(mockResultSet.getString(eq(1))).thenReturn("instance-1");
478-
when(rdsMazDbClusterHostListProvider.refresh(eq(mockConnection))).thenReturn(cachedTopology);
479-
when(rdsMazDbClusterHostListProvider.forceRefresh(eq(mockConnection))).thenReturn(cachedTopology);
478+
doReturn(cachedTopology).when(rdsMazDbClusterHostListProvider).refresh(mockConnection);
479+
doReturn(cachedTopology).when(rdsMazDbClusterHostListProvider).forceRefresh(mockConnection);
480480

481481
assertNull(rdsMazDbClusterHostListProvider.identifyConnection(mockConnection));
482482
}
@@ -485,19 +485,19 @@ void testIdentifyConnectionHostNotInTopology() throws SQLException {
485485
void testIdentifyConnectionHostInTopology() throws SQLException {
486486
final HostSpec expectedHost = new HostSpecBuilder(new SimpleHostAvailabilityStrategy())
487487
.host("instance-a-1.xyz.us-east-2.rds.amazonaws.com")
488+
.hostId("instance-a-1")
488489
.port(HostSpec.NO_PORT)
489490
.role(HostRole.WRITER)
490491
.build();
491-
expectedHost.setHostId("instance-a-1");
492492
final List<HostSpec> cachedTopology = Collections.singletonList(expectedHost);
493493

494494
rdsMazDbClusterHostListProvider = Mockito.spy(getRdsMazDbClusterHostListProvider(
495495
mockHostListProviderService,
496496
"jdbc:someprotocol://url"));
497497
when(mockResultSet.next()).thenReturn(true);
498498
when(mockResultSet.getString(eq(1))).thenReturn("instance-a-1");
499-
when(rdsMazDbClusterHostListProvider.refresh()).thenReturn(cachedTopology);
500-
when(rdsMazDbClusterHostListProvider.forceRefresh()).thenReturn(cachedTopology);
499+
doReturn(cachedTopology).when(rdsMazDbClusterHostListProvider).refresh(mockConnection);
500+
doReturn(cachedTopology).when(rdsMazDbClusterHostListProvider).forceRefresh(mockConnection);
501501

502502
final HostSpec actual = rdsMazDbClusterHostListProvider.identifyConnection(mockConnection);
503503
assertEquals("instance-a-1.xyz.us-east-2.rds.amazonaws.com", actual.getHost());

0 commit comments

Comments
 (0)