-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
automatic recognition of address scheme in topic route by host.
- Loading branch information
1 parent
bf2f2a7
commit b44dd55
Showing
5 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
proxy/src/test/java/org/apache/rocketmq/proxy/common/AddressTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.apache.rocketmq.proxy.common; | ||
|
||
import com.google.common.net.HostAndPort; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNull; | ||
public class AddressTest { | ||
|
||
@Test | ||
public void testConstructorWithIPv4() { | ||
HostAndPort hostAndPort = HostAndPort.fromString("192.168.1.1:8080"); | ||
Address address = new Address(hostAndPort); | ||
|
||
assertEquals(Address.AddressScheme.IPv4, address.getAddressScheme()); | ||
assertEquals(hostAndPort, address.getHostAndPort()); | ||
} | ||
|
||
@Test | ||
public void testConstructorWithIPv6() { | ||
HostAndPort hostAndPort = HostAndPort.fromString("[2001:db8::1]:8080"); | ||
Address address = new Address(hostAndPort); | ||
|
||
assertEquals(Address.AddressScheme.IPv6, address.getAddressScheme()); | ||
assertEquals(hostAndPort, address.getHostAndPort()); | ||
} | ||
|
||
@Test | ||
public void testConstructorWithDomainName() { | ||
HostAndPort hostAndPort = HostAndPort.fromString("example.com:8080"); | ||
Address address = new Address(hostAndPort); | ||
|
||
assertEquals(Address.AddressScheme.DOMAIN_NAME, address.getAddressScheme()); | ||
assertEquals(hostAndPort, address.getHostAndPort()); | ||
} | ||
|
||
@Test | ||
public void testConstructorWithNullHostAndPort() { | ||
Address address = new Address(null); | ||
|
||
assertEquals(Address.AddressScheme.UNRECOGNIZED, address.getAddressScheme()); | ||
assertNull(address.getHostAndPort()); | ||
} | ||
} |