@Test
public void convertProviderToUrls() throws Exception {

    ServerConfig serverConfig = new ServerConfig()
        .setHost("0.0.0.0")
        .setPort(22000)
        .setProtocol("bolt");
    ServerConfig serverConfig2 = new ServerConfig()
        .setHost("127.0.0.1")
        .setPort(12200)
        .setProtocol("tr");
    ServerConfig serverConfig3 = new ServerConfig()
        .setHost("192.1.1.1")
        .setPort(8080)
        .setProtocol("xfire");
    ProviderConfig<?> providerConfig = new ProviderConfig();
    providerConfig
        .setInterfaceId("com.alipay.sofa.rpc.test.TestService")
        .setUniqueId("qqqq")
        .setApplication(new ApplicationConfig().setAppName("xxxx"))
        .setTimeout(4444)
        .setWeight(250)
        .setServer(Arrays.asList(serverConfig, serverConfig2));
    MethodConfig methodConfig = new MethodConfig().setName("echo").setTimeout(3333);
    MethodConfig methodConfig2 = new MethodConfig().setName("xx").setTimeout(2222);
    providerConfig.setMethods(Arrays.asList(methodConfig, methodConfig2));
    String s1 = SofaRegistryHelper.convertProviderToUrls(providerConfig, serverConfig);
    Assert.assertNotNull(s1);
    ProviderInfo providerInfo = SofaRegistryHelper.parseProviderInfo(s1);
    Assert.assertEquals(SystemInfo.getLocalHost(), providerInfo.getHost());
    Assert.assertEquals(serverConfig.getPort(), providerInfo.getPort());
    Assert.assertEquals(providerConfig.getAppName(), providerInfo.getAttr(ProviderInfoAttrs.ATTR_APP_NAME));
    Assert.assertEquals(providerConfig.getTimeout(), providerInfo.getDynamicAttr(ProviderInfoAttrs.ATTR_TIMEOUT));
    String s2 = SofaRegistryHelper.convertProviderToUrls(providerConfig, serverConfig2);
    Assert.assertNotNull(s2);
    ProviderInfo providerInfo2 = SofaRegistryHelper.parseProviderInfo(s2);
    Assert.assertEquals(SystemInfo.getLocalHost(), providerInfo.getHost());
    Assert.assertEquals(serverConfig2.getPort(), providerInfo2.getPort());
    Assert.assertEquals(providerConfig.getAppName(), providerInfo2.getAttr(ProviderInfoAttrs.ATTR_APP_NAME));
    Assert.assertEquals(providerConfig.getTimeout(), providerInfo2.getDynamicAttr(ProviderInfoAttrs.ATTR_TIMEOUT));
    String s3 = SofaRegistryHelper.convertProviderToUrls(providerConfig, serverConfig3);
    Assert.assertNotNull(s3);
    ProviderInfo providerInfo3 = SofaRegistryHelper.parseProviderInfo(s3);
    Assert.assertEquals(serverConfig3.getHost(), providerInfo3.getHost());
    Assert.assertEquals(serverConfig3.getPort(), providerInfo3.getPort());
    Assert.assertEquals(providerConfig.getAppName(), providerInfo3.getAttr(ProviderInfoAttrs.ATTR_APP_NAME));
    Assert.assertEquals(providerConfig.getTimeout(), providerInfo3.getDynamicAttr(ProviderInfoAttrs.ATTR_TIMEOUT));
}