public void subscribe(URL url) {
        setSubscribeUrl(url);
        registry.subscribe(url, this);
    }
@Test
    void testSubscribe() {

        Map<String, String> parameters = new HashMap<>();
        parameters.put(INTERFACE_KEY, DemoService.class.getName());
        parameters.put("registry", "zookeeper");
        parameters.put("register", "true");
        parameters.put(REGISTER_IP_KEY, "172.23.236.180");

        Map<String, Object> attributes = new HashMap<>();
        ServiceConfigURL serviceConfigUrl = new ServiceConfigURL(
                "registry", "127.0.0.1", 2181, "org.apache.dubbo.registry.RegistryService", parameters);
        Map<String, String> refer = new HashMap<>();
        attributes.put(REFER_KEY, refer);
        attributes.put("key1", "value1");
        URL url = serviceConfigUrl.addAttributes(attributes);

        DemoDynamicDirectory<DemoService> demoDynamicDirectory = new DemoDynamicDirectory<>(DemoService.class, url);

        URL subscribeUrl = new ServiceConfigURL("dubbo", "127.0.0.1", 20881, DemoService.class.getName(), parameters);

        Registry registry = mock(Registry.class);
        demoDynamicDirectory.setRegistry(registry);

        demoDynamicDirectory.subscribe(subscribeUrl);

        verify(registry, times(1)).subscribe(subscribeUrl, demoDynamicDirectory);
        Assertions.assertEquals(subscribeUrl, demoDynamicDirectory.getSubscribeUrl());
    }