@Test
    public void toUrl() throws Exception {
        {
            String src = "10.15.233.114:12200";
            ProviderInfo providerInfo = ProviderHelper.toProviderInfo(src);
            Assert.assertEquals(providerInfo.getHost(), "10.15.233.114");
            Assert.assertEquals(providerInfo.getPort(), 12200);
            Assert.assertEquals(providerInfo.getPath(), StringUtils.EMPTY);
            Assert.assertEquals(ProviderHelper.toUrl(providerInfo), providerInfo.getProtocolType() + "://" + src);
        }
        {
            String src = "10.15.233.114:12200/";
            ProviderInfo providerInfo = ProviderHelper.toProviderInfo(src);
            Assert.assertEquals(providerInfo.getHost(), "10.15.233.114");
            Assert.assertEquals(providerInfo.getPort(), 12200);
            Assert.assertEquals(providerInfo.getPath(), StringUtils.CONTEXT_SEP);
            Assert.assertEquals(ProviderHelper.toUrl(providerInfo), providerInfo.getProtocolType() + "://" + src);
        }
        {
            String src = "bolt://10.15.233.114:12200";
            ProviderInfo providerInfo = ProviderHelper.toProviderInfo(src);
            Assert.assertEquals(providerInfo.getProtocolType(), "bolt");
            Assert.assertEquals(providerInfo.getHost(), "10.15.233.114");
            Assert.assertEquals(providerInfo.getPort(), 12200);
            Assert.assertEquals(providerInfo.getPath(), StringUtils.EMPTY);
            Assert.assertEquals(ProviderHelper.toUrl(providerInfo), src);
        }
        {
            String src = "bolt://10.15.233.114:12200/";
            ProviderInfo providerInfo = ProviderHelper.toProviderInfo(src);
            Assert.assertEquals(providerInfo.getProtocolType(), "bolt");
            Assert.assertEquals(providerInfo.getHost(), "10.15.233.114");
            Assert.assertEquals(providerInfo.getPort(), 12200);
            Assert.assertEquals(providerInfo.getPath(), StringUtils.CONTEXT_SEP);
            Assert.assertEquals(ProviderHelper.toUrl(providerInfo), src);
        }
        {
            String src = "bolt://10.15.233.114:12200?weight=222&serialization=hessian2";
            ProviderInfo providerInfo = ProviderHelper.toProviderInfo(src);
            Assert.assertEquals(providerInfo.getProtocolType(), "bolt");
            Assert.assertEquals(providerInfo.getHost(), "10.15.233.114");
            Assert.assertEquals(providerInfo.getPort(), 12200);
            Assert.assertEquals(providerInfo.getPath(), StringUtils.EMPTY);
            Assert.assertEquals(providerInfo.getWeight(), 222);
            Assert.assertEquals(providerInfo.getSerializationType(), "hessian2");
            Assert.assertEquals(ProviderHelper.toProviderInfo(ProviderHelper.toUrl(providerInfo)), providerInfo);
        }
        {
            String src = "bolt://10.15.233.114:12200/?weight=222&serialization=hessian2";
            ProviderInfo providerInfo = ProviderHelper.toProviderInfo(src);
            Assert.assertEquals(providerInfo.getProtocolType(), "bolt");
            Assert.assertEquals(providerInfo.getHost(), "10.15.233.114");
            Assert.assertEquals(providerInfo.getPort(), 12200);
            Assert.assertEquals(providerInfo.getPath(), StringUtils.CONTEXT_SEP);
            Assert.assertEquals(providerInfo.getWeight(), 222);
            Assert.assertEquals(providerInfo.getSerializationType(), "hessian2");
            Assert.assertEquals(ProviderHelper.toProviderInfo(ProviderHelper.toUrl(providerInfo)), providerInfo);
        }
    }
@author <a href="mailto:zhanggeng.zg@antfin.com">GengZhang</a>
core/api/src/test/java/com/alipay/sofa/rpc/client/ProviderHelperTest.java