NIFI-557: modified unit test to connect to localhost, rather than the IP address of localhost, as DNS and multiple NIC cards can cause unit tests to fail otherwise

This commit is contained in:
Mark Payne 2015-05-01 11:37:24 -04:00
parent 73a368f861
commit 6394c8ee40
1 changed files with 3 additions and 4 deletions

View File

@ -95,11 +95,10 @@ public class ClusterManagerProtocolSenderImplTest {
@Test @Test
public void testRequestFlow() throws Exception { public void testRequestFlow() throws Exception {
when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE); when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new FlowResponseMessage()); when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new FlowResponseMessage());
final FlowRequestMessage request = new FlowRequestMessage(); final FlowRequestMessage request = new FlowRequestMessage();
request.setNodeId(new NodeIdentifier("id", "api-address", 1, address.getHostAddress(), port)); request.setNodeId(new NodeIdentifier("id", "api-address", 1, "localhost", port));
final FlowResponseMessage response = sender.requestFlow(request); final FlowResponseMessage response = sender.requestFlow(request);
assertNotNull(response); assertNotNull(response);
} }
@ -110,7 +109,7 @@ public class ClusterManagerProtocolSenderImplTest {
when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE); when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new PingMessage()); when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new PingMessage());
final FlowRequestMessage request = new FlowRequestMessage(); final FlowRequestMessage request = new FlowRequestMessage();
request.setNodeId(new NodeIdentifier("id", "api-address", 1, address.getHostAddress(), port)); request.setNodeId(new NodeIdentifier("id", "api-address", 1, "localhost", port));
try { try {
sender.requestFlow(request); sender.requestFlow(request);
fail("failed to throw exception"); fail("failed to throw exception");
@ -134,7 +133,7 @@ public class ClusterManagerProtocolSenderImplTest {
} }
}); });
final FlowRequestMessage request = new FlowRequestMessage(); final FlowRequestMessage request = new FlowRequestMessage();
request.setNodeId(new NodeIdentifier("id", "api-address", 1, address.getHostAddress(), port)); request.setNodeId(new NodeIdentifier("id", "api-address", 1, "localhost", port));
try { try {
sender.requestFlow(request); sender.requestFlow(request);
fail("failed to throw exception"); fail("failed to throw exception");