mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -1,10 +1,22 @@
|
||||
package org.dromara.hutool.core.net;
|
||||
|
||||
import org.dromara.hutool.core.regex.PatternPool;
|
||||
import org.dromara.hutool.core.regex.ReUtil;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
public class Ipv4UtilTest {
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void getLocalHostNameTest() {
|
||||
// 注意此方法会触发反向DNS解析,导致阻塞,阻塞时间取决于网络!
|
||||
Assertions.assertNotNull(Ipv4Util.getLocalHostName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void formatIpBlockTest() {
|
||||
for (int i = Ipv4Util.IPV4_MASK_BIT_VALID_MIN; i < Ipv4Util.IPV4_MASK_BIT_MAX; i++) {
|
||||
@@ -199,4 +211,22 @@ public class Ipv4UtilTest {
|
||||
Assertions.assertEquals(Ipv4Util.getMaskByMaskBit(i), Ipv4Util.getMaskByIpRange(beginIpStr, endIpStr));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void getLocalhostTest() {
|
||||
final InetAddress localhost = Ipv4Util.getLocalhost();
|
||||
Assertions.assertNotNull(localhost);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void getLocalMacAddressTest() {
|
||||
final String macAddress = Ipv4Util.getLocalMacAddress();
|
||||
Assertions.assertNotNull(macAddress);
|
||||
|
||||
// 验证MAC地址正确
|
||||
final boolean match = ReUtil.isMatch(PatternPool.MAC_ADDRESS, macAddress);
|
||||
Assertions.assertTrue(match);
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,11 @@
|
||||
package org.dromara.hutool.core.net;
|
||||
|
||||
import org.dromara.hutool.core.lang.Console;
|
||||
import org.dromara.hutool.core.regex.PatternPool;
|
||||
import org.dromara.hutool.core.regex.ReUtil;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.net.HttpCookie;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.List;
|
||||
|
||||
@@ -23,28 +20,10 @@ public class NetUtilTest {
|
||||
@Test
|
||||
@Disabled
|
||||
public void getLocalhostStrTest() {
|
||||
final String localhost = NetUtil.getLocalhostStr();
|
||||
final String localhost = NetUtil.getLocalhostStrV4();
|
||||
Assertions.assertNotNull(localhost);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void getLocalhostTest() {
|
||||
final InetAddress localhost = NetUtil.getLocalhost();
|
||||
Assertions.assertNotNull(localhost);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void getLocalMacAddressTest() {
|
||||
final String macAddress = NetUtil.getLocalMacAddress();
|
||||
Assertions.assertNotNull(macAddress);
|
||||
|
||||
// 验证MAC地址正确
|
||||
final boolean match = ReUtil.isMatch(PatternPool.MAC_ADDRESS, macAddress);
|
||||
Assertions.assertTrue(match);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void longToIpTest() {
|
||||
final String ipv4 = NetUtil.longToIpv4(2130706433L);
|
||||
@@ -77,16 +56,9 @@ public class NetUtilTest {
|
||||
Assertions.assertEquals("cookiedomain.com", httpCookie.getDomain());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void getLocalHostNameTest() {
|
||||
// 注意此方法会触发反向DNS解析,导致阻塞,阻塞时间取决于网络!
|
||||
Assertions.assertNotNull(NetUtil.getLocalHostName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLocalHostTest() {
|
||||
Assertions.assertNotNull(NetUtil.getLocalhost());
|
||||
Assertions.assertNotNull(NetUtil.getLocalhostV4());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user