@Test
public void removeProvider() throws Exception {

    SingleGroupAddressHolder addressHolder = new SingleGroupAddressHolder(null);
    addressHolder.addProvider(new ProviderGroup("xxx", Arrays.asList(
        ProviderHelper.toProviderInfo("127.0.0.1:12200"),
        ProviderHelper.toProviderInfo("127.0.0.1:12201"),
        ProviderHelper.toProviderInfo("127.0.0.1:12202"))));
    Assert.assertTrue(addressHolder.getProviderGroup(ADDRESS_DEFAULT_GROUP).size() == 3);
    addressHolder.removeProvider(new ProviderGroup("xxx", new ArrayList<ProviderInfo>()));
    Assert.assertTrue(addressHolder.getProviderGroup(ADDRESS_DEFAULT_GROUP).size() == 3);
    addressHolder.removeProvider(new ProviderGroup("xxx", Collections.singletonList(
        ProviderHelper.toProviderInfo("127.0.0.1:12200"))));
    Assert.assertTrue(addressHolder.getProviderGroup(ADDRESS_DEFAULT_GROUP).size() == 2);
    addressHolder.removeProvider(new ProviderGroup("xxx", Arrays.asList(
        ProviderHelper.toProviderInfo("127.0.0.1:12201"),
        ProviderHelper.toProviderInfo("127.0.0.1:12202"))));
    Assert.assertTrue(addressHolder.getProviderGroup(ADDRESS_DEFAULT_GROUP).size() == 0);
    addressHolder.addProvider(new ProviderGroup(ADDRESS_DIRECT_GROUP, Arrays.asList(
        ProviderHelper.toProviderInfo("127.0.0.1:12200"),
        ProviderHelper.toProviderInfo("127.0.0.1:12201"),
        ProviderHelper.toProviderInfo("127.0.0.1:12202"))));
    Assert.assertTrue(addressHolder.getProviderGroup(ADDRESS_DIRECT_GROUP).size() == 3);
    addressHolder.removeProvider(new ProviderGroup(ADDRESS_DIRECT_GROUP, new ArrayList<ProviderInfo>()));
    Assert.assertTrue(addressHolder.getProviderGroup(ADDRESS_DIRECT_GROUP).size() == 3);
    addressHolder.removeProvider(new ProviderGroup(ADDRESS_DIRECT_GROUP, Collections.singletonList(
        ProviderHelper.toProviderInfo("127.0.0.1:12200"))));
    Assert.assertTrue(addressHolder.getProviderGroup(ADDRESS_DIRECT_GROUP).size() == 2);
    addressHolder.removeProvider(new ProviderGroup(ADDRESS_DIRECT_GROUP, Arrays.asList(
        ProviderHelper.toProviderInfo("127.0.0.1:12201"),
        ProviderHelper.toProviderInfo("127.0.0.1:12202"))));
    Assert.assertTrue(addressHolder.getProviderGroup(ADDRESS_DIRECT_GROUP).size() == 0);
}