@Test
public void testAddListener() throws Exception {

    CountDownLatch latch = new CountDownLatch(4);
    TestListener listener1 = new TestListener(latch);
    TestListener listener2 = new TestListener(latch);
    TestListener listener3 = new TestListener(latch);
    TestListener listener4 = new TestListener(latch);
    config.addListener("AService.configurators", listener1);
    config.addListener("AService.configurators", listener2);
    config.addListener("testapp.tagrouters", listener3);
    config.addListener("testapp.tagrouters", listener4);
    put("/dubbo/config/AService/configurators", "new value1");
    Thread.sleep(200);
    put("/dubbo/config/testapp/tagrouters", "new value2");
    Thread.sleep(200);
    put("/dubbo/config/testapp", "new value3");
    Thread.sleep(1000);
    Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
    Assert.assertEquals(1, listener1.getCount("/dubbo/config/AService/configurators"));
    Assert.assertEquals(1, listener2.getCount("/dubbo/config/AService/configurators"));
    Assert.assertEquals(1, listener3.getCount("/dubbo/config/testapp/tagrouters"));
    Assert.assertEquals(1, listener4.getCount("/dubbo/config/testapp/tagrouters"));
    Assert.assertEquals("new value1", listener1.getValue());
    Assert.assertEquals("new value1", listener2.getValue());
    Assert.assertEquals("new value2", listener3.getValue());
    Assert.assertEquals("new value2", listener4.getValue());
}