Skip to content

Commit

Permalink
[ISSUE #5380] Use assert instead of System.out (#5472)
Browse files Browse the repository at this point in the history
* use assert instead of System.out

* move test case, there is no file named ParamCheckUtil.java
  • Loading branch information
孙继峰 committed Apr 25, 2021
1 parent ee8f636 commit da3a1ea
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 34 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ public void testSplitIpPort() {
checkSplitIPPortStr("[127.0.0.1]:88", true);
}

@Test
public void testCheckIPs() {
String[] ips = {"127.0.0.1"};
Assert.assertEquals("ok", IPUtil.checkIPs(ips));

String[] illegalIps = {"127.100.19", "127.0.0.1"};
Assert.assertEquals("illegal ip: 127.100.19", IPUtil.checkIPs(illegalIps));
}

/**
* checkSplitIpPortStr.
* 2020/9/4 14:12
Expand Down
8 changes: 7 additions & 1 deletion test/src/test/java/com/alibaba/nacos/test/BaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.alibaba.nacos.common.utils.JacksonUtils;
import com.alibaba.nacos.naming.healthcheck.RsInfo;
import org.junit.Assert;
import org.junit.Test;

/**
Expand All @@ -33,7 +34,12 @@ public class BaseTest {
public void test_rs_json() {
String json = "{\"cluster\":\"DEFAULT\",\"ip\":\"127.0.0.1\",\"metadata\":{},\"port\":60000,\"scheduled\":true,\"serviceName\":\"DEFAULT_GROUP@@jinhan9J7ye.Vj6hx.net\",\"weight\":1.0}";
RsInfo client = JacksonUtils.toObj(json, RsInfo.class);
System.out.println(client);
Assert.assertEquals(60000, client.getPort());
Assert.assertEquals("DEFAULT_GROUP@@jinhan9J7ye.Vj6hx.net", client.getServiceName());
Assert.assertEquals("DEFAULT", client.getCluster());
Assert.assertEquals(1D, client.getWeight(), 0);
Assert.assertTrue(client.getMetadata().isEmpty());
Assert.assertEquals("127.0.0.1", client.getIp());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ public void test_deserialization_type() throws Exception {
public void test_rest_result() throws Exception {
String json = "{\"code\":200,\"message\":null,\"data\":[{\"USERNAME\":\"nacos\",\"PASSWORD\":\"$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu\",\"ENABLED\":true}]}";
RestResult<Object> result = ResponseHandler.convert(json, new GenericType<RestResult<Object>>(){}.getType());
System.out.println(result);
Assert.assertEquals(200, result.getCode());
Assert.assertNull(result.getMessage());
Assert.assertNotNull(result.getData());
}

@Test
Expand Down

0 comments on commit da3a1ea

Please sign in to comment.