You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by zh...@apache.org on 2022/08/01 07:14:35 UTC

[shenyu] branch master updated: delete file. (#3781)

This is an automated email from the ASF dual-hosted git repository.

zhangzicheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new 128dbd212 delete file. (#3781)
128dbd212 is described below

commit 128dbd2129418a1ea1acc83a8f1138c9b8994962
Author: Kevin Clair <70...@qq.com>
AuthorDate: Mon Aug 1 15:14:29 2022 +0800

    delete file. (#3781)
---
 .../shenyu/admin/config/NacosConfiguration.java    |  72 -------------
 .../admin/config/ZookeeperConfiguration.java       |  56 ----------
 .../admin/config/NacosConfigurationTest.java       | 115 ---------------------
 .../admin/config/ZookeeperConfigurationTest.java   |  86 ---------------
 4 files changed, 329 deletions(-)

diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/NacosConfiguration.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/NacosConfiguration.java
deleted file mode 100644
index 7e71e7a73..000000000
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/NacosConfiguration.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shenyu.admin.config;
-
-import com.alibaba.nacos.api.NacosFactory;
-import com.alibaba.nacos.api.PropertyKeyConst;
-import com.alibaba.nacos.api.config.ConfigService;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.shenyu.admin.config.properties.NacosProperties;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.context.annotation.Bean;
-
-import java.util.Properties;
-
-/**
- * Nacos configuration.
- *
- * @deprecated {@link DataSyncConfiguration.NacosListener#nacosConfigService}
- */
-@Deprecated
-@EnableConfigurationProperties(NacosProperties.class)
-public class NacosConfiguration {
-
-    /**
-     * register configService in spring ioc.
-     *
-     * @param nacosProp the nacos configuration
-     * @return ConfigService {@linkplain ConfigService}
-     * @throws Exception the exception
-     */
-    @Bean
-    @ConditionalOnMissingBean(ConfigService.class)
-    public ConfigService nacosConfigService(final NacosProperties nacosProp) throws Exception {
-        Properties properties = new Properties();
-        if (nacosProp.getAcm() != null && nacosProp.getAcm().isEnabled()) {
-            // Use aliyun ACM service
-            properties.put(PropertyKeyConst.ENDPOINT, nacosProp.getAcm().getEndpoint());
-            properties.put(PropertyKeyConst.NAMESPACE, nacosProp.getAcm().getNamespace());
-            // Use subaccount ACM administrative authority
-            properties.put(PropertyKeyConst.ACCESS_KEY, nacosProp.getAcm().getAccessKey());
-            properties.put(PropertyKeyConst.SECRET_KEY, nacosProp.getAcm().getSecretKey());
-        } else {
-            properties.put(PropertyKeyConst.SERVER_ADDR, nacosProp.getUrl());
-            if (StringUtils.isNotBlank(nacosProp.getNamespace())) {
-                properties.put(PropertyKeyConst.NAMESPACE, nacosProp.getNamespace());
-            }
-            if (StringUtils.isNotBlank(nacosProp.getUsername())) {
-                properties.put(PropertyKeyConst.USERNAME, nacosProp.getUsername());
-            }
-            if (StringUtils.isNotBlank(nacosProp.getPassword())) {
-                properties.put(PropertyKeyConst.PASSWORD, nacosProp.getPassword());
-            }
-        }
-        return NacosFactory.createConfigService(properties);
-    }
-}
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/ZookeeperConfiguration.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/ZookeeperConfiguration.java
deleted file mode 100644
index 58375f0fb..000000000
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/ZookeeperConfiguration.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shenyu.admin.config;
-
-import org.apache.shenyu.admin.config.properties.ZookeeperProperties;
-import org.apache.shenyu.register.client.server.zookeeper.ZookeeperClient;
-import org.apache.shenyu.register.client.server.zookeeper.ZookeeperConfig;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.context.annotation.Bean;
-
-import java.util.Objects;
-
-/**
- * ZookeeperConfiguration.
- *
- * @deprecated {@link DataSyncConfiguration.ZookeeperListener#zookeeperClient}
- */
-@Deprecated
-@EnableConfigurationProperties(ZookeeperProperties.class)
-public class ZookeeperConfiguration {
-
-    /**
-     * register ZookeeperClient in spring ioc.
-     *
-     * @param zookeeperProp the zookeeper configuration
-     * @return ZookeeperClient {@linkplain ZookeeperClient}
-     */
-    @Bean
-    @ConditionalOnMissingBean(ZookeeperClient.class)
-    public ZookeeperClient zookeeperClient(final ZookeeperProperties zookeeperProp) {
-        int sessionTimeout = Objects.isNull(zookeeperProp.getSessionTimeout()) ? 3000 : zookeeperProp.getSessionTimeout();
-        int connectionTimeout = Objects.isNull(zookeeperProp.getConnectionTimeout()) ? 3000 : zookeeperProp.getConnectionTimeout();
-        ZookeeperConfig zkConfig = new ZookeeperConfig(zookeeperProp.getUrl());
-        zkConfig.setSessionTimeoutMilliseconds(sessionTimeout)
-                .setConnectionTimeoutMilliseconds(connectionTimeout);
-        ZookeeperClient client = new ZookeeperClient(zkConfig);
-        client.start();
-        return client;
-    }
-}
diff --git a/shenyu-admin/src/test/java/org/apache/shenyu/admin/config/NacosConfigurationTest.java b/shenyu-admin/src/test/java/org/apache/shenyu/admin/config/NacosConfigurationTest.java
deleted file mode 100644
index 52649b13e..000000000
--- a/shenyu-admin/src/test/java/org/apache/shenyu/admin/config/NacosConfigurationTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shenyu.admin.config;
-
-import com.alibaba.nacos.api.NacosFactory;
-import com.alibaba.nacos.api.PropertyKeyConst;
-import com.alibaba.nacos.api.config.ConfigService;
-import org.apache.shenyu.admin.AbstractConfigurationTest;
-import org.apache.shenyu.admin.config.properties.NacosProperties;
-import org.junit.jupiter.api.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.MockedStatic;
-import org.mockito.Mockito;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.context.annotation.Bean;
-
-import java.util.Properties;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-/**
- * Test cases for NacosConfiguration.
- */
-public final class NacosConfigurationTest extends AbstractConfigurationTest {
-
-    private final String[] inlinedProperties = new String[]{
-        "shenyu.sync.nacos.url=localhost:8848",
-        "shenyu.sync.nacos.namespace=1c10d748-af86-43b9-8265-75f487d20c6c",
-        "shenyu.sync.nacos.username=nacos",
-        "shenyu.sync.nacos.password=nacos",
-        "shenyu.sync.nacos.acm.enabled=false",
-        "shenyu.sync.nacos.acm.endpoint=acm.aliyun.com",
-    };
-
-    @Test
-    public void testNacosConfigServiceMissingBean() {
-        load(NacosConfiguration.class, inlinedProperties);
-        ConfigService configService = (ConfigService) getContext().getBean("nacosConfigService");
-        assertNotNull(configService);
-    }
-
-    @Test
-    public void testNacosConfigService() {
-        String[] inlinedProperties = new String[]{
-            "shenyu.sync.nacos.url=localhost:8848",
-            "shenyu.sync.nacos.namespace=1c10d748-af86-43b9-8265-75f487d20c6c",
-            "shenyu.sync.nacos.acm.enabled=true",
-            "shenyu.sync.nacos.acm.endpoint=localhost:8849",
-            "shenyu.sync.nacos.acm.namespace=namespace",
-            "shenyu.sync.nacos.acm.accessKey=accessKey",
-            "shenyu.sync.nacos.acm.secretKey=secretKey",
-        };
-        try (MockedStatic<NacosFactory> nacosFactoryMockedStatic = Mockito.mockStatic(NacosFactory.class)) {
-            final ConfigService configServiceMock = Mockito.mock(ConfigService.class);
-            ArgumentCaptor<Properties> argument = ArgumentCaptor.forClass(Properties.class);
-            nacosFactoryMockedStatic
-                    .when(() -> NacosFactory.createConfigService(argument.capture()))
-                    .thenReturn(configServiceMock);
-            load(NacosConfiguration.class, inlinedProperties);
-            assertTrue(argument.getValue().containsKey(PropertyKeyConst.ENDPOINT));
-        }
-        ConfigService configService = (ConfigService) getContext().getBean("nacosConfigService");
-        assertNotNull(configService);
-    }
-
-    @Test
-    public void testNacosConfigServiceExistBean() {
-        load(CustomNacosConfiguration.class, inlinedProperties);
-        boolean isExist = getContext().containsBean("nacosConfigService");
-        assertFalse(isExist);
-
-        ConfigService customConfigService = (ConfigService) getContext().getBean("customNacosConfigService");
-        assertNotNull(customConfigService);
-    }
-
-    @EnableConfigurationProperties(NacosProperties.class)
-    static class CustomNacosConfiguration {
-
-        @Bean
-        public ConfigService customNacosConfigService(final NacosProperties nacosProp) throws Exception {
-            Properties properties = new Properties();
-            if (nacosProp.getAcm() != null && nacosProp.getAcm().isEnabled()) {
-                //use aliyun ACM service
-                properties.put(PropertyKeyConst.ENDPOINT, nacosProp.getAcm().getEndpoint());
-                properties.put(PropertyKeyConst.NAMESPACE, nacosProp.getAcm().getNamespace());
-                //use children count ACM manager privilege
-                properties.put(PropertyKeyConst.ACCESS_KEY, nacosProp.getAcm().getAccessKey());
-                properties.put(PropertyKeyConst.SECRET_KEY, nacosProp.getAcm().getSecretKey());
-            } else {
-                properties.put(PropertyKeyConst.SERVER_ADDR, nacosProp.getUrl());
-                properties.put(PropertyKeyConst.NAMESPACE, nacosProp.getNamespace());
-                properties.put(PropertyKeyConst.USERNAME, nacosProp.getUsername());
-                properties.put(PropertyKeyConst.PASSWORD, nacosProp.getPassword());
-            }
-            return NacosFactory.createConfigService(properties);
-        }
-    }
-}
diff --git a/shenyu-admin/src/test/java/org/apache/shenyu/admin/config/ZookeeperConfigurationTest.java b/shenyu-admin/src/test/java/org/apache/shenyu/admin/config/ZookeeperConfigurationTest.java
deleted file mode 100644
index 701b2c149..000000000
--- a/shenyu-admin/src/test/java/org/apache/shenyu/admin/config/ZookeeperConfigurationTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shenyu.admin.config;
-
-import org.apache.shenyu.admin.AbstractConfigurationTest;
-import org.apache.shenyu.admin.config.properties.ZookeeperProperties;
-import org.apache.shenyu.register.client.server.zookeeper.ZookeeperClient;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.context.annotation.Bean;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-/**
- * Test case for ZookeeperConfiguration.
- */
-public final class ZookeeperConfigurationTest extends AbstractConfigurationTest {
-
-    private static final ZookeeperClient ZK_CLIENT = Mockito.mock(ZookeeperClient.class);
-
-    private final String[] inlinedProperties = new String[]{
-        "shenyu.sync.zookeeper.url=127.0.0.1:21810",
-        "shenyu.sync.zookeeper.sessionTimeout=5000",
-        "shenyu.sync.zookeeper.connectionTimeout=2000",
-    };
-
-    @Test
-    public void testOnMissingBean() {
-        // init zkClient by ZookeeperConfiguration
-        load(MockZookeeperConfiguration.class, inlinedProperties);
-        ZookeeperClient zkClient = (ZookeeperClient) getContext().getBean("zookeeperClient");
-        assertNotNull(zkClient);
-    }
-
-    @Test
-    public void testOnExistBean() {
-        // verify zkClient by ZookeeperConfiguration
-        load(CustomZkClientConfiguration.class, inlinedProperties);
-        boolean isExistZkClient = getContext().containsBean("zkClient");
-        assertFalse(isExistZkClient);
-
-        // get customZkClient
-        ZookeeperClient customZkClient = (ZookeeperClient) getContext().getBean("customZkClient");
-        assertNotNull(customZkClient);
-    }
-
-    @EnableConfigurationProperties(ZookeeperProperties.class)
-    static class MockZookeeperConfiguration extends ZookeeperConfiguration {
-        /**
-         * register zkClient in spring ioc.
-         *
-         * @param zookeeperProp the zookeeper configuration
-         * @return ZkClient {@linkplain ZookeeperClient}
-         */
-        @Override
-        public ZookeeperClient zookeeperClient(final ZookeeperProperties zookeeperProp) {
-            return ZK_CLIENT;
-        }
-    }
-
-    @EnableConfigurationProperties(ZookeeperProperties.class)
-    static class CustomZkClientConfiguration {
-
-        @Bean
-        public ZookeeperClient customZkClient(final ZookeeperProperties zookeeperProp) {
-            return ZK_CLIENT;
-        }
-    }
-}