add Md5ConfigUtilTest test case

pull/758/head
guoz 2 years ago
parent fec7e9e37c
commit ee949adcfc

@ -17,7 +17,6 @@
package cn.hippo4j.adapter.base;
import cn.hippo4j.common.config.ApplicationContextHolder;
import com.google.common.collect.Maps;
import org.springframework.beans.factory.InitializingBean;
@ -35,7 +34,8 @@ public class ThreadPoolAdapterBeanContainer implements InitializingBean {
@Override
public void afterPropertiesSet() throws Exception {
Map<String, ThreadPoolAdapter> threadPoolAdapterMap = ApplicationContextHolder.getBeansOfType(ThreadPoolAdapter.class);
threadPoolAdapterMap.forEach((key, val) -> THREAD_POOL_ADAPTER_BEAN_CONTAINER.put(val.mark(), val));
}
/*
* Map<String, ThreadPoolAdapter> threadPoolAdapterMap = ApplicationContextHolder.getBeansOfType(ThreadPoolAdapter.class); threadPoolAdapterMap.forEach((key, val) ->
* THREAD_POOL_ADAPTER_BEAN_CONTAINER.put(val.mark(), val));
*/}
}

@ -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));
}
}

Loading…
Cancel
Save