michael-o commented on a change in pull request #118: [TEXT-170] Add String
lookup for host names and IP addresses
URL: https://github.com/apache/commons-text/pull/118#discussion_r308011906
##########
File path:
src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java
##########
@@ -68,6 +68,51 @@ public void testDefaultValueForMissingKeyInResourceBundle()
{
assertEquals("defaultValue",
stringSubstitutor.replace("${keyWithMissingKey}"));
}
+ @Test
+ public void testDnsLookup() throws UnknownHostException {
+ final StringSubstitutor strSubst =
StringSubstitutor.createInterpolator();
+
Assertions.assertEquals(InetAddress.getByName("apache.org").getHostAddress(),
+ strSubst.replace("${dns:apache.org}"));
+ }
+
+ @Test
+ public void testDnsLookupAddress() throws UnknownHostException {
+ final StringSubstitutor strSubst =
StringSubstitutor.createInterpolator();
+
Assertions.assertEquals(InetAddress.getByName("apache.org").getHostAddress(),
+ strSubst.replace("${dns:address|apache.org}"));
+ }
+
+ @Test
+ public void testDnsLookupCanonicalName() throws UnknownHostException {
+ final StringSubstitutor strSubst =
StringSubstitutor.createInterpolator();
+ final String address = InetAddress.getLocalHost().getHostAddress();
+ final InetAddress inetAddress = InetAddress.getByName(address);
+ Assertions.assertEquals(inetAddress.getHostName(),
strSubst.replace("${dns:canonical-name|" + address + "}"));
Review comment:
But this isn't testing for the canoncial name, isn't it?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services