Skip to content

Commit

Permalink
[ISSUE alibaba#8515] add tearDown method for the unit test
Browse files Browse the repository at this point in the history
- reformat by nacos-style
  • Loading branch information
onewe committed Jun 13, 2022
1 parent fdf35d3 commit fdd3cc3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 4 additions & 2 deletions sys/src/main/java/com/alibaba/nacos/sys/utils/InetUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ private static void refreshIp() {
}

/**
* Get ip address from environment.
* System property nacos.server.ip.
* Get ip address from environment
* System property nacos.server.ip
* Spring property nacos.inetutils.ip-address.
*
* @return ip address
*/
private static String getNacosIp() {
Expand All @@ -146,6 +147,7 @@ private static String getNacosIp() {

/**
* Get ip address.
*
* @return ip address
*/
private static String getPreferHostnameOverIP() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.alibaba.nacos.common.utils.StringUtils;
import com.alibaba.nacos.sys.env.Constants;
import com.alibaba.nacos.sys.env.EnvUtil;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -47,8 +48,13 @@ public void testRefreshIp() throws InterruptedException {

selfIP = InetUtils.getSelfIP();
Assert.assertTrue(StringUtils.equalsIgnoreCase(selfIP, "1.1.1.2"));


}

@After
public void tearDown() {
System.clearProperty(NACOS_SERVER_IP);
System.clearProperty(Constants.AUTO_REFRESH_TIME);
}

}

0 comments on commit fdd3cc3

Please sign in to comment.