SingleGroupAddressHolder extends AddressHolder { @Override public void addProvider(ProviderGroup providerGroup) { if (ProviderHelper.isEmpty(providerGroup)) { return; } wLock.lock(); try { getProviderGroup(providerGroup.getName()).addAll(providerGroup.getProviderInfos()); } finally { wLock.unlock(); } } protected  SingleGroupAddressHolder(ConsumerBootstrap consumerBootstrap); @Override List<ProviderInfo> getProviderInfos(String groupName); @Override ProviderGroup getProviderGroup(String groupName); @Override List<ProviderGroup> getProviderGroups(); @Override int getAllProviderSize(); @Override void addProvider(ProviderGroup providerGroup); @Override void removeProvider(ProviderGroup providerGroup); @Override void updateProviders(ProviderGroup providerGroup); @Override void updateAllProviders(List<ProviderGroup> providerGroups);  }
@Test public void addProvider() throws Exception { SingleGroupAddressHolder addressHolder = new SingleGroupAddressHolder(null); addressHolder.addProvider(new ProviderGroup("xxx", new ArrayList<ProviderInfo>())); Assert.assertTrue(addressHolder.getProviderGroup(ADDRESS_DEFAULT_GROUP).size() == 0); addressHolder.addProvider(new ProviderGroup("xxx", Arrays.asList( ProviderHelper.toProviderInfo("127.0.0.1:12200"), ProviderHelper.toProviderInfo("127.0.0.1:12201")))); Assert.assertTrue(addressHolder.getProviderGroup(ADDRESS_DEFAULT_GROUP).size() == 2); addressHolder.addProvider(new ProviderGroup(ADDRESS_DIRECT_GROUP, new ArrayList<ProviderInfo>())); Assert.assertTrue(addressHolder.getProviderGroup(ADDRESS_DIRECT_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")))); Assert.assertTrue(addressHolder.getProviderGroup(ADDRESS_DIRECT_GROUP).size() == 2); }