@@ -183,6 +183,37 @@ func TestLoadPropertiesRegistersWatchOnlyWhenInactive(t *testing.T) {
183183 require .True (t , waitForEvent (inactivePath , time .Second ))
184184}
185185
186+ func TestListenerUsesGroupOption (t * testing.T ) {
187+ cluster , client , _ , err := gxzookeeper .NewMockZookeeperClient ("listener-group" , 5 * time .Second )
188+ if err != nil {
189+ t .Skipf ("skip mock zk setup: %v" , err )
190+ }
191+ defer cluster .Stop ()
192+
193+ zkListener := remotingzookeeper .NewZkEventListener (client )
194+ defer zkListener .Close ()
195+ cfg := & zookeeperDynamicConfiguration {
196+ rootPath : "/dubbo/config" ,
197+ client : client ,
198+ url : mustURL (t , "registry://127.0.0.1:2181" ),
199+ cache : newConfigCache (time .Minute ),
200+ listener : zkListener ,
201+ }
202+ cfg .cacheListener = newCacheListener (cfg .rootPath , zkListener , & cfg .cache )
203+ key := "app.properties"
204+ group := "custom"
205+ path := cfg .getPropertiesPath (key , config_center .WithGroup (group ))
206+ rec := & recListener {}
207+
208+ cfg .AddListener (key , rec , config_center .WithGroup (group ))
209+ _ , ok := cfg .cacheListener .keyListeners .Load (path )
210+ require .True (t , ok )
211+
212+ cfg .RemoveListener (key , rec , config_center .WithGroup (group ))
213+ _ , ok = cfg .cacheListener .keyListeners .Load (path )
214+ require .False (t , ok )
215+ }
216+
186217func TestGetPropertiesFallsBackToTTLAtAutoWatchLimit (t * testing.T ) {
187218 cluster , client , events , err := gxzookeeper .NewMockZookeeperClient ("watch-limit" , 5 * time .Second )
188219 if err != nil {
0 commit comments