parent
e1d557563b
commit
e70f5f7b00
@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
* Tencent is pleased to support the open source community by making spring-cloud-tencent available.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the BSD 3-Clause License (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://opensource.org/licenses/BSD-3-Clause
|
|
||||||
*
|
|
||||||
* 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 com.tencent.cloud.common.util;
|
|
||||||
|
|
||||||
import com.tencent.cloud.common.metadata.MetadataContext;
|
|
||||||
import com.tencent.polaris.metadata.core.MetadataObjectValue;
|
|
||||||
import com.tencent.polaris.metadata.core.MetadataType;
|
|
||||||
|
|
||||||
public final class MetadataContextUtils {
|
|
||||||
|
|
||||||
private MetadataContextUtils() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getCallerApplicationMetadataStringValue(MetadataContext metadataContext, String key, String defaultValue) {
|
|
||||||
MetadataObjectValue<String> metadataObjectValue = metadataContext.getMetadataContainer(MetadataType.APPLICATION, true).getMetadataValue(key);
|
|
||||||
if (metadataObjectValue == null) {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
return metadataObjectValue.getObjectValue().orElse(defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void putCallerApplicationMetadataStringValue(MetadataContext metadataContext, String key, String value) {
|
|
||||||
metadataContext.getMetadataContainer(MetadataType.APPLICATION, true).putMetadataObjectValue(key, value);
|
|
||||||
}
|
|
||||||
}
|
|
2
spring-cloud-tencent-plugin-starters/spring-cloud-tencent-gateway-plugin/src/main/java/com/tencent/cloud/plugin/gateway/SCGPluginsAutoConfiguration.java → spring-cloud-tencent-plugin-starters/spring-cloud-tencent-gateway-plugin/src/main/java/com/tencent/cloud/plugin/gateway/GatewayPluginAutoConfiguration.java
2
spring-cloud-tencent-plugin-starters/spring-cloud-tencent-gateway-plugin/src/main/java/com/tencent/cloud/plugin/gateway/SCGPluginsAutoConfiguration.java → spring-cloud-tencent-plugin-starters/spring-cloud-tencent-gateway-plugin/src/main/java/com/tencent/cloud/plugin/gateway/GatewayPluginAutoConfiguration.java
@ -1,2 +1,2 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||||
com.tencent.cloud.plugin.gateway.SCGPluginsAutoConfiguration
|
com.tencent.cloud.plugin.gateway.GatewayPluginAutoConfiguration
|
||||||
|
@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
* Tencent is pleased to support the open source community by making spring-cloud-tencent available.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the BSD 3-Clause License (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://opensource.org/licenses/BSD-3-Clause
|
|
||||||
*
|
|
||||||
* 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 com.tencent.cloud.plugin.gateway;
|
|
||||||
|
|
||||||
import com.tencent.cloud.polaris.context.PolarisSDKContextManager;
|
|
||||||
import com.tencent.polaris.configuration.api.core.ConfigFileService;
|
|
||||||
import com.tencent.polaris.configuration.factory.ConfigFileServiceFactory;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
|
||||||
|
|
||||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.DEFINED_PORT;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for {@link SCGPluginsAutoConfiguration}.
|
|
||||||
* @author derek.yi 2022-11-03
|
|
||||||
*/
|
|
||||||
@ExtendWith(SpringExtension.class)
|
|
||||||
@SpringBootTest(webEnvironment = DEFINED_PORT, classes = SCGPluginsAutoConfigurationTest.TestApplication.class,
|
|
||||||
properties = {"server.port=48081", "spring.config.location = classpath:application-test.yml",
|
|
||||||
"spring.cloud.tencent.plugin.scg.staining.rule-staining.enabled = true"})
|
|
||||||
public class SCGPluginsAutoConfigurationTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ApplicationContext applicationContext;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testAutoConfiguration() {
|
|
||||||
// assertThat(applicationContext.getBeansOfType(RuleStainingProperties.class).size()).isEqualTo(1);
|
|
||||||
// assertThat(applicationContext.getBeansOfType(StainingRuleManager.class).size()).isEqualTo(1);
|
|
||||||
// assertThat(applicationContext.getBeansOfType(TrafficStainingGatewayFilter.class).size()).isEqualTo(1);
|
|
||||||
// assertThat(applicationContext.getBeansOfType(RuleStainingExecutor.class).size()).isEqualTo(1);
|
|
||||||
// assertThat(applicationContext.getBeansOfType(RuleTrafficStainer.class).size()).isEqualTo(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SpringBootApplication
|
|
||||||
public static class TestApplication {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public ConfigFileService configFileService(PolarisSDKContextManager polarisSDKContextManager) {
|
|
||||||
return ConfigFileServiceFactory.createConfigFileService(polarisSDKContextManager.getSDKContext());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in new issue