2018-06-05 17:18:05 +01:00
|
|
|
/*
|
2020-01-02 07:24:59 -05:00
|
|
|
* Copyright (C) 2018-2020 Lightbend Inc. <https://www.lightbend.com>
|
2018-06-05 17:18:05 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package akka.io.dns
|
|
|
|
|
|
|
|
|
|
import java.net.InetSocketAddress
|
|
|
|
|
|
2020-01-11 15:14:21 +03:00
|
|
|
import org.scalatest.matchers.should.Matchers
|
|
|
|
|
import org.scalatest.wordspec.AnyWordSpec
|
2018-06-05 17:18:05 +01:00
|
|
|
|
2020-01-11 15:14:21 +03:00
|
|
|
class NameserverAddressParserSpec extends AnyWordSpec with Matchers {
|
2018-06-05 17:18:05 +01:00
|
|
|
"Parser" should {
|
|
|
|
|
"handle explicit port in IPv4 address" in {
|
|
|
|
|
DnsSettings.parseNameserverAddress("8.8.8.8:153") shouldEqual new InetSocketAddress("8.8.8.8", 153)
|
|
|
|
|
}
|
|
|
|
|
"handle explicit port in IPv6 address" in {
|
2019-03-11 10:38:24 +01:00
|
|
|
DnsSettings.parseNameserverAddress("[2001:4860:4860::8888]:153") shouldEqual new InetSocketAddress(
|
|
|
|
|
"2001:4860:4860::8888",
|
|
|
|
|
153)
|
2018-06-05 17:18:05 +01:00
|
|
|
}
|
|
|
|
|
"handle default port in IPv4 address" in {
|
|
|
|
|
DnsSettings.parseNameserverAddress("8.8.8.8") shouldEqual new InetSocketAddress("8.8.8.8", 53)
|
|
|
|
|
}
|
|
|
|
|
"handle default port in IPv6 address" in {
|
2019-03-11 10:38:24 +01:00
|
|
|
DnsSettings.parseNameserverAddress("[2001:4860:4860::8888]") shouldEqual new InetSocketAddress(
|
|
|
|
|
"2001:4860:4860::8888",
|
|
|
|
|
53)
|
2018-06-05 17:18:05 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|