@Test
public void mergeProviderInfo() throws Exception {

    SofaRegistrySubscribeCallback callback = new SofaRegistrySubscribeCallback();
    // null + null
    List<ProviderInfo> result = callback.mergeProviderInfo(null, null);
    Assert.assertTrue(CommonUtils.isEmpty(result));
    // 空 + null
    List<String> listData = new ArrayList<String>();
    result = callback.mergeProviderInfo(listData, null);
    Assert.assertTrue(CommonUtils.isEmpty(result));
    // null + 空
    List<String> attrData = new ArrayList<String>();
    result = callback.mergeProviderInfo(null, attrData);
    Assert.assertTrue(CommonUtils.isEmpty(result));
    // 空+ 空
    result = callback.mergeProviderInfo(listData, attrData);
    Assert.assertTrue(CommonUtils.isEmpty(result));
    // 空+非空
    attrData.add("override://127.0.0.1?weight=200");
    result = callback.mergeProviderInfo(listData, attrData);
    Assert.assertTrue(CommonUtils.isEmpty(result));
    // 非空+空
    attrData.clear();
    listData.add("127.0.0.1:22000?weight=100");
    listData.add("127.0.0.1:22001?weight=100");
    result = callback.mergeProviderInfo(listData, attrData);
    Assert.assertTrue(result.size() == 2);
    for (ProviderInfo providerInfo : result) {
        if (providerInfo.getPort() == 22000) {
            Assert.assertTrue(providerInfo.getWeight() == 100);
        } else if (providerInfo.getPort() == 22001) {
            Assert.assertTrue(providerInfo.getWeight() == 100);
        }
    }
    // 覆盖未命中
    attrData.add("override://127.0.0.1:22005?weight=200");
    attrData.add("override://127.0.0.1:22004?disabled=true&weight=200");
    result = callback.mergeProviderInfo(listData, attrData);
    Assert.assertTrue(result.size() == 2);
    for (ProviderInfo providerInfo : result) {
        if (providerInfo.getPort() == 22000) {
            Assert.assertTrue(providerInfo.getWeight() == 100);
        } else if (providerInfo.getPort() == 22001) {
            Assert.assertTrue(providerInfo.getWeight() == 100);
        }
    }
    // 覆盖
    attrData.add("override://127.0.0.1:22000?weight=200");
    attrData.add("override://127.0.0.1:22001?disabled=true&weight=200");
    result = callback.mergeProviderInfo(listData, attrData);
    Assert.assertTrue(result.size() == 1);
    for (ProviderInfo providerInfo : result) {
        if (providerInfo.getPort() == 22000) {
            Assert.assertTrue(providerInfo.getWeight() == 200);
        }
    }
}