INT-1822 Add Attribute to Suppress Reverse DNS Lokup

This commit is contained in:
Gary Russell
2011-03-04 18:53:51 -05:00
parent 5e02a7e63b
commit 9a5c26581b
22 changed files with 167 additions and 77 deletions

View File

@@ -30,6 +30,7 @@
local-address="127.0.0.1"
task-executor="externalTE"
error-channel="errorChannel"
lookup-host="false"
/>
<ip:udp-inbound-channel-adapter id="testInUdpMulticast"
@@ -49,6 +50,7 @@
<ip:tcp-connection-factory id="cfS1"
type="server"
port="#{tcpIpUtils.findAvailableServerSocket(5200)}"
lookup-host="false"
/>
<ip:tcp-inbound-channel-adapter id="testInTcp"
@@ -95,6 +97,7 @@
type="client"
port="#{tcpIpUtils.findAvailableServerSocket(5700)}"
host="localhost"
lookup-host="false"
/>
<ip:tcp-outbound-channel-adapter id="testOutTcpNio"

View File

@@ -17,6 +17,7 @@
package org.springframework.integration.ip.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
@@ -178,6 +179,9 @@ public class ParserUnitTests {
assertEquals("127.0.0.1", dfa.getPropertyValue("localAddress"));
assertSame(taskExecutor, dfa.getPropertyValue("taskExecutor"));
assertEquals(errorChannel, dfa.getPropertyValue("errorChannel"));
DatagramPacketMessageMapper mapper = (DatagramPacketMessageMapper) dfa.getPropertyValue("mapper");
DirectFieldAccessor mapperAccessor = new DirectFieldAccessor(mapper);
assertFalse((Boolean)mapperAccessor.getPropertyValue("lookupHost"));
}
@Test
@@ -193,6 +197,9 @@ public class ParserUnitTests {
assertEquals("127.0.0.1", dfa.getPropertyValue("localAddress"));
assertNotSame(taskExecutor, dfa.getPropertyValue("taskExecutor"));
assertNull(dfa.getPropertyValue("errorChannel"));
DatagramPacketMessageMapper mapper = (DatagramPacketMessageMapper) dfa.getPropertyValue("mapper");
DirectFieldAccessor mapperAccessor = new DirectFieldAccessor(mapper);
assertTrue((Boolean)mapperAccessor.getPropertyValue("lookupHost"));
}
@Test
@@ -202,6 +209,7 @@ public class ParserUnitTests {
assertEquals("testInTcp",tcpIn.getComponentName());
assertEquals("ip:tcp-inbound-channel-adapter", tcpIn.getComponentType());
assertEquals(errorChannel, dfa.getPropertyValue("errorChannel"));
assertFalse(cfS1.isLookupHost());
}
@Test
@@ -253,6 +261,7 @@ public class ParserUnitTests {
assertSame(cfC1, dfa.getPropertyValue("clientConnectionFactory"));
assertEquals("testOutTcpNio",tcpOut.getComponentName());
assertEquals("ip:tcp-outbound-channel-adapter", tcpOut.getComponentType());
assertFalse(cfC1.isLookupHost());
}
@Test
@@ -263,6 +272,7 @@ public class ParserUnitTests {
assertEquals("inGateway1",tcpInboundGateway1.getComponentName());
assertEquals("ip:tcp-inbound-gateway", tcpInboundGateway1.getComponentType());
assertEquals(errorChannel, dfa.getPropertyValue("errorChannel"));
assertTrue(cfS2.isLookupHost());
}
@Test
@@ -283,6 +293,7 @@ public class ParserUnitTests {
assertEquals(567L, dfa.getPropertyValue("replyTimeout"));
assertEquals("outGateway",tcpOutboundGateway.getComponentName());
assertEquals("ip:tcp-outbound-gateway", tcpOutboundGateway.getComponentType());
assertTrue(cfC2.isLookupHost());
}
@Test

View File

@@ -19,6 +19,7 @@
single-use="true"
port="#{tcpIpUtils.findAvailableServerSocket(10000)}"
task-executor="exec"
lookup-host="false"
so-timeout="20000"
/>
@@ -27,6 +28,7 @@
host="localhost"
port="#{server.port}"
single-use="true"
lookup-host="false"
so-timeout="100000"
/>

View File

@@ -18,6 +18,7 @@ package org.springframework.integration.ip.tcp;
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import java.util.Properties;
@@ -99,4 +100,19 @@ public class ConnectionToConnectionTests {
assertNotNull(message);
assertEquals("Test", new String((byte[]) message.getPayload()));
}
@Test
public void testLookup() throws Exception {
TcpConnection connection = client.getConnection();
assertFalse(connection.getConnectionId().contains("localhost"));
connection.close();
client.setLookupHost(true);
connection = client.getConnection();
assertTrue(connection.getConnectionId().contains("localhost"));
connection.close();
client.setLookupHost(false);
connection = client.getConnection();
assertFalse(connection.getConnectionId().contains("localhost"));
connection.close();
}
}

View File

@@ -73,7 +73,7 @@ public class TcpMessageMapperTests {
TcpMessageMapper mapper = new TcpMessageMapper();
Socket socket = SocketFactory.getDefault().createSocket();
TcpConnection connection = new AbstractTcpConnection(socket, false) {
TcpConnection connection = new AbstractTcpConnection(socket, false, false) {
public void run() {
}
public void send(Message<?> message) throws Exception {

View File

@@ -18,6 +18,7 @@ package org.springframework.integration.ip.udp;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
import java.net.DatagramPacket;
@@ -71,6 +72,15 @@ public class DatagramPacketMessageMapperTests {
assertEquals(messageOut.getHeaders().get(IpHeaders.ACK_ID).toString(),
message.getHeaders().getId().toString());
}
assertTrue(((String)messageOut.getHeaders().get(IpHeaders.HOSTNAME)).contains("localhost"));
mapper.setLookupHost(false);
messageOut = mapper.toMessage(packet);
assertEquals(new String(message.getPayload()), new String(messageOut.getPayload()));
if (ack) {
assertEquals(messageOut.getHeaders().get(IpHeaders.ACK_ID).toString(),
message.getHeaders().getId().toString());
}
assertFalse(((String)messageOut.getHeaders().get(IpHeaders.HOSTNAME)).contains("localhost"));
}
@Test