public DynamicConfigSubscribe(String serviceName, DynamicConfigListener listener, String key) {
        this.serviceName = serviceName;
        this.listener = listener;
        this.key = key;
        try {
            this.nacosDynamicConfigService = ServiceManager.getService(NacosDynamicConfigService.class);
        } catch (IllegalArgumentException e) {
            LOGGER.log(Level.SEVERE, "nacosDynamicConfigService is not enabled!");
        }
    }
@Test
    public void testDynamicConfigSubscribe() throws NoSuchFieldException, IllegalAccessException, InterruptedException {
        try {
            // test subscription
            TestListener testListener = new TestListener();
            dynamicConfigSubscribe = new DynamicConfigSubscribe("testServiceName", testListener,
                    "testSubscribeKey");
            Assert.assertTrue(dynamicConfigSubscribe.subscribe());
            Thread.sleep(SLEEP_TIME_MILLIS);

            Assert.assertTrue(
                    nacosDynamicConfigService.doPublishConfig("testSubscribeKey",
                            "app:testApplication_environment:testEnvironment",
                            "content:1"));
            checkChangeTrue(testListener, "content:1");

            Assert.assertTrue(
                    nacosDynamicConfigService.doPublishConfig("testSubscribeKey",
                            "app:testApplication_environment:testEnvironment_service:testServiceName",
                            "content:2"));
            checkChangeTrue(testListener, "content:2");

            Assert.assertTrue(
                    nacosDynamicConfigService.doPublishConfig("testSubscribeKey",
                            "testCustomLabel:testCustomLabelValue",
                            "content:3"));
            checkChangeTrue(testListener, "content:3");

            Optional<Object> listeners = ReflectUtils.getFieldValueByClazz(nacosDynamicConfigService.getClass(),
                    nacosDynamicConfigService, "listeners");
            Assert.assertTrue(listeners.orElse(Collections.emptyList()) instanceof List);
            Assert.assertEquals(3,
                    ((List<NacosListener>) listeners.orElse(Collections.emptyList())).size());

            // test delete subscription
            Assert.assertTrue(dynamicConfigSubscribe.unSubscribe());
            Assert.assertEquals(0,
                    ((List<NacosListener>) listeners.orElse(Collections.emptyList())).size());
            Assert.assertTrue(
                    nacosDynamicConfigService.doPublishConfig("testSubscribeKey",
                            "app:testApplication_environment:testEnvironment",
                            "content:11"));
            checkChangeFalse(testListener);

            Assert.assertTrue(
                    nacosDynamicConfigService.doPublishConfig("testSubscribeKey",
                            "app:testApplication_environment:testEnvironment_service:testServiceName",
                            "content:22"));
            checkChangeFalse(testListener);

            Assert.assertTrue(
                    nacosDynamicConfigService.doPublishConfig("testSubscribeKey",
                            "testCustomLabel:testCustomLabelValue",
                            "content:33"));
            checkChangeFalse(testListener);
        } finally {
            nacosDynamicConfigService.doRemoveConfig("testSubscribeKey",
                    "app:testApplication_environment:testEnvironment");
            nacosDynamicConfigService.doRemoveConfig("testSubscribeKey",
                    "app:testApplication_environment:testEnvironment_service:testServiceName");
            nacosDynamicConfigService.doRemoveConfig("testSubscribeKey", "testCustomLabel:testCustomLabelValue");
        }
    }