From b74ba1b4612d9d8f7b31c2a2b9f4f7094c0c6a53 Mon Sep 17 00:00:00 2001 From: cpatel129 Date: Tue, 12 Apr 2022 12:29:51 +0100 Subject: [PATCH] Fix tests --- tests/amqpprox_session.t.cpp | 46 ++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/tests/amqpprox_session.t.cpp b/tests/amqpprox_session.t.cpp index d2359f4..20629d6 100644 --- a/tests/amqpprox_session.t.cpp +++ b/tests/amqpprox_session.t.cpp @@ -908,8 +908,27 @@ TEST_F(SessionTest, Connect_Multiple_Dns) EXPECT_CALL(d_selector, acquireConnection(_, _)) .WillOnce(DoAll(SetArgPointee<0>(d_cm), Return(0))); - TestSocketState::State base, clientBase; - testSetupHostnameMapperForServerClientBase(base, clientBase); + EXPECT_CALL(*d_mapper, prime(_, _)).Times(AtLeast(1)); + EXPECT_CALL(*d_mapper, mapToHostname(makeEndpoint("2.3.4.5", 2345))) + .WillRepeatedly(Return(std::string("host1"))); + EXPECT_CALL(*d_mapper, mapToHostname(makeEndpoint("1.2.3.4", 1234))) + .WillRepeatedly(Return(std::string("host0"))); + EXPECT_CALL(*d_mapper, mapToHostname(makeEndpoint("1.2.3.4", 32000))) + .WillRepeatedly(Return(std::string("host0"))); + EXPECT_CALL(*d_mapper, mapToHostname(makeEndpoint("3.4.5.6", 5672))) + .WillRepeatedly(Return(std::string("host2"))); + EXPECT_CALL(*d_mapper, mapToHostname(makeEndpoint("0.0.0.0", 0))) + .WillRepeatedly(Return(std::string(""))); + + TestSocketState::State base; + base.d_local = makeEndpoint("1.2.3.4", 1234); + base.d_remote = makeEndpoint("2.3.4.5", 2345); + base.d_secure = false; + + TestSocketState::State clientBase; + clientBase.d_local = makeEndpoint("1.2.3.4", 32000); + clientBase.d_remote = makeEndpoint("3.4.5.6", 5672); + clientBase.d_secure = false; // Initialise the state d_serverState.pushItem(0, base); @@ -1031,8 +1050,27 @@ TEST_F(SessionTest, Failover_Dns_Failure) EXPECT_CALL(d_selector, acquireConnection(_, _)) .WillOnce(DoAll(SetArgPointee<0>(d_cm), Return(0))); - TestSocketState::State base, clientBase; - testSetupHostnameMapperForServerClientBase(base, clientBase); + EXPECT_CALL(*d_mapper, prime(_, _)).Times(AtLeast(1)); + EXPECT_CALL(*d_mapper, mapToHostname(makeEndpoint("2.3.4.5", 2345))) + .WillRepeatedly(Return(std::string("host1"))); + EXPECT_CALL(*d_mapper, mapToHostname(makeEndpoint("1.2.3.4", 1234))) + .WillRepeatedly(Return(std::string("host0"))); + EXPECT_CALL(*d_mapper, mapToHostname(makeEndpoint("1.2.3.4", 32000))) + .WillRepeatedly(Return(std::string("host0"))); + EXPECT_CALL(*d_mapper, mapToHostname(makeEndpoint("3.4.5.6", 5672))) + .WillRepeatedly(Return(std::string("host2"))); + EXPECT_CALL(*d_mapper, mapToHostname(makeEndpoint("0.0.0.0", 0))) + .WillRepeatedly(Return(std::string(""))); + + TestSocketState::State base; + base.d_local = makeEndpoint("1.2.3.4", 1234); + base.d_remote = makeEndpoint("2.3.4.5", 2345); + base.d_secure = false; + + TestSocketState::State clientBase; + clientBase.d_local = makeEndpoint("1.2.3.4", 32000); + clientBase.d_remote = makeEndpoint("3.4.5.6", 5672); + clientBase.d_secure = false; // Initialise the state d_serverState.pushItem(0, base);