|
|
|
@ -17,8 +17,75 @@
|
|
|
|
|
|
|
|
|
|
package cn.hippo4j.config.toolkit;
|
|
|
|
|
|
|
|
|
|
import cn.hippo4j.common.toolkit.Assert;
|
|
|
|
|
import cn.hippo4j.config.model.ConfigAllInfo;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import org.assertj.core.util.Lists;
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Md5ConfigUtil Test
|
|
|
|
|
*/
|
|
|
|
|
public class Md5ConfigUtilTest {
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void getKeyTest() {
|
|
|
|
|
String key = Md5ConfigUtil.getKey("DataId", "Group");
|
|
|
|
|
Assert.isTrue(Objects.equals("DataId+Group", key));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void getKeySpecialTest() {
|
|
|
|
|
String key = Md5ConfigUtil.getKey("DataId+", "Group");
|
|
|
|
|
Assert.isTrue(Objects.equals("DataId%2B+Group", key));
|
|
|
|
|
|
|
|
|
|
String key1 = Md5ConfigUtil.getKey("DataId%", "Group");
|
|
|
|
|
Assert.isTrue(Objects.equals("DataId%25+Group", key1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void getKeyTenantIdentifyTest() {
|
|
|
|
|
String key = Md5ConfigUtil.getKey("DataId", "Group", "Tenant", "Identify");
|
|
|
|
|
Assert.isTrue(Objects.equals("DataId+Group+Tenant+Identify", key));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void getKeyTenantIdentifySpecialTest() {
|
|
|
|
|
String key = Md5ConfigUtil.getKey("DataId+", "Group+", "Tenant+", "Identify");
|
|
|
|
|
Assert.isTrue(Objects.equals("DataId%2B+Group%2B+Tenant%2B+Identify", key));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void compareMd5ResultStringEmptyTest() {
|
|
|
|
|
String key = null;
|
|
|
|
|
try {
|
|
|
|
|
key = Md5ConfigUtil.compareMd5ResultString(Lists.newArrayList());
|
|
|
|
|
} catch (IOException ignored) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Assert.isTrue(Objects.equals(StrUtil.EMPTY, key));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void compareMd5ResultStringTest() {
|
|
|
|
|
String key = null;
|
|
|
|
|
try {
|
|
|
|
|
key = Md5ConfigUtil.compareMd5ResultString(Lists.newArrayList("DataId+Group"));
|
|
|
|
|
} catch (IOException ignored) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Assert.isTrue(Objects.equals("DataId%02Group%01", key));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void getClientMd5MapTest() {
|
|
|
|
|
ConfigAllInfo configAllInfo = new ConfigAllInfo();
|
|
|
|
|
configAllInfo.setDesc("hippo4j config");
|
|
|
|
|
String tpContentMd5 = Md5ConfigUtil.getTpContentMd5(configAllInfo);
|
|
|
|
|
Assert.isTrue(StrUtil.isNotEmpty(tpContentMd5));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|