commit
32fa5864f2
@ -1,34 +0,0 @@
|
|||||||
name: Codecov
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- hoxton
|
|
||||||
- 2021.0
|
|
||||||
- 2020.0
|
|
||||||
- greenwich
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- hoxton
|
|
||||||
- 2021.0
|
|
||||||
- 2020.0
|
|
||||||
- greenwich
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout codes
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
- name: Set up JDK 8
|
|
||||||
uses: actions/setup-java@v3
|
|
||||||
with:
|
|
||||||
distribution: 'temurin'
|
|
||||||
java-version: 8
|
|
||||||
- name: Test with Maven
|
|
||||||
run: mvn -B test --file pom.xml
|
|
||||||
- name: Upload coverage to Codecov
|
|
||||||
uses: codecov/codecov-action@v3
|
|
||||||
with:
|
|
||||||
file: ${{ github.workspace }}/target/site/jacoco/jacoco.xml
|
|
@ -1,15 +1,5 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
---
|
---
|
||||||
|
|
||||||
- [Optimize: remove discovery module useless code](https://github.com/Tencent/spring-cloud-tencent/pull/597)
|
- [Optimize:optimize spring value processor](https://github.com/Tencent/spring-cloud-tencent/pull/669)
|
||||||
- [Bugfix: InstancePreRegisteredEvent and InstanceRegisteredEvent modify Registration info](https://github.com/Tencent/spring-cloud-tencent/pull/583)
|
|
||||||
- [Fix issue 579:Report the labels in request when report the result of invocation by RestTemplate](https://github.com/Tencent/spring-cloud-tencent/pull/600)
|
|
||||||
- [Optimize: optimize configuration conditional & optimize config data tips"](https://github.com/Tencent/spring-cloud-tencent/pull/605)
|
|
||||||
- [Optimize: Maybe remove Chinese characters](https://github.com/Tencent/spring-cloud-tencent/pull/609)
|
|
||||||
- [Optimize: InstanceId of PolarisRegistration and PolarisServiceRegistry](https://github.com/Tencent/spring-cloud-tencent/pull/612)
|
|
||||||
- [Bugfix: fix feign report call result error when using feign direct call](https://github.com/Tencent/spring-cloud-tencent/pull/623)
|
|
||||||
- [optimize:optimize PolarisRouterContext and constants.](https://github.com/Tencent/spring-cloud-tencent/pull/628)
|
|
||||||
- [support spring-retry router](https://github.com/Tencent/spring-cloud-tencent/pull/631)
|
|
||||||
- [feat:Transfer http headers specified by environment variables](https://github.com/Tencent/spring-cloud-tencent/pull/638)
|
|
||||||
- [feat:support read config file from local file system.](https://github.com/Tencent/spring-cloud-tencent/pull/649)
|
|
||||||
- [feat: publish spring event named ConfigChangeSpringEvent when the configuration is changed](https://github.com/Tencent/spring-cloud-tencent/pull/651)
|
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
# Change Log
|
||||||
|
---
|
||||||
|
|
||||||
|
- [Optimize: remove discovery module useless code](https://github.com/Tencent/spring-cloud-tencent/pull/597)
|
||||||
|
- [Bugfix: InstancePreRegisteredEvent and InstanceRegisteredEvent modify Registration info](https://github.com/Tencent/spring-cloud-tencent/pull/583)
|
||||||
|
- [Fix issue 579:Report the labels in request when report the result of invocation by RestTemplate](https://github.com/Tencent/spring-cloud-tencent/pull/600)
|
||||||
|
- [Optimize: optimize configuration conditional & optimize config data tips"](https://github.com/Tencent/spring-cloud-tencent/pull/605)
|
||||||
|
- [Optimize: Maybe remove Chinese characters](https://github.com/Tencent/spring-cloud-tencent/pull/609)
|
||||||
|
- [Optimize: InstanceId of PolarisRegistration and PolarisServiceRegistry](https://github.com/Tencent/spring-cloud-tencent/pull/612)
|
||||||
|
- [Bugfix: fix feign report call result error when using feign direct call](https://github.com/Tencent/spring-cloud-tencent/pull/623)
|
||||||
|
- [optimize:optimize PolarisRouterContext and constants.](https://github.com/Tencent/spring-cloud-tencent/pull/628)
|
||||||
|
- [support spring-retry router](https://github.com/Tencent/spring-cloud-tencent/pull/631)
|
||||||
|
- [feat:Transfer http headers specified by environment variables](https://github.com/Tencent/spring-cloud-tencent/pull/638)
|
||||||
|
- [feat:support read config file from local file system.](https://github.com/Tencent/spring-cloud-tencent/pull/649)
|
||||||
|
- [feat: publish spring event named ConfigChangeSpringEvent when the configuration is changed](https://github.com/Tencent/spring-cloud-tencent/pull/651)
|
||||||
|
- [Feature: support new expression](https://github.com/Tencent/spring-cloud-tencent/pull/661)
|
||||||
|
- [Optimize:optimize TransHeadersTransfer.](https://github.com/Tencent/spring-cloud-tencent/pull/662)
|
||||||
|
- [fix:fix transfer http headers not working bug.](https://github.com/Tencent/spring-cloud-tencent/pull/663)
|
@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
* Tencent is pleased to support the open source community by making Spring Cloud Tencent available.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 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.metadata.core;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import com.tencent.cloud.common.metadata.MetadataContextHolder;
|
||||||
|
import com.tencent.cloud.common.util.JacksonUtils;
|
||||||
|
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* According to request and trans-headers(key list in string type) in metadata, build
|
||||||
|
* the complete headers(key-value list in map type) into metadata.
|
||||||
|
*
|
||||||
|
* @author lingxiao.wlx
|
||||||
|
*/
|
||||||
|
public final class TransHeadersTransfer {
|
||||||
|
|
||||||
|
private TransHeadersTransfer() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* According to {@link HttpServletRequest} and trans-headers(key list in string type) in metadata, build
|
||||||
|
* the complete headers(key-value list in map type) into metadata.
|
||||||
|
*
|
||||||
|
* @param httpServletRequest httpServletRequest
|
||||||
|
*/
|
||||||
|
public static void transfer(HttpServletRequest httpServletRequest) {
|
||||||
|
// transHeaderMetadata: for example, {"trans-headers" : {"header1,header2,header3":""}}
|
||||||
|
Map<String, String> transHeaderMetadata = MetadataContextHolder.get().getTransHeaders();
|
||||||
|
if (!CollectionUtils.isEmpty(transHeaderMetadata)) {
|
||||||
|
String transHeaders = transHeaderMetadata.keySet().stream().findFirst().orElse("");
|
||||||
|
String[] transHeaderArray = transHeaders.split(",");
|
||||||
|
Enumeration<String> httpHeaders = httpServletRequest.getHeaderNames();
|
||||||
|
while (httpHeaders.hasMoreElements()) {
|
||||||
|
String httpHeader = httpHeaders.nextElement();
|
||||||
|
Arrays.stream(transHeaderArray).forEach(transHeader -> {
|
||||||
|
if (transHeader.equals(httpHeader)) {
|
||||||
|
String httpHeaderValue = httpServletRequest.getHeader(httpHeader);
|
||||||
|
// for example, {"trans-headers-kv" : {"header1":"v1","header2":"v2"...}}
|
||||||
|
MetadataContextHolder.get().setTransHeadersKV(httpHeader, httpHeaderValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* According to {@link ServerHttpRequest} and trans-headers(key list in string type) in metadata, build
|
||||||
|
* the complete headers(key-value list in map type) into metadata.
|
||||||
|
*
|
||||||
|
* @param serverHttpRequest serverHttpRequest
|
||||||
|
*/
|
||||||
|
public static void transfer(ServerHttpRequest serverHttpRequest) {
|
||||||
|
// transHeaderMetadata: for example, {"trans-headers" : {"header1,header2,header3":""}}
|
||||||
|
Map<String, String> transHeaderMetadata = MetadataContextHolder.get().getTransHeaders();
|
||||||
|
if (!CollectionUtils.isEmpty(transHeaderMetadata)) {
|
||||||
|
String transHeaders = transHeaderMetadata.keySet().stream().findFirst().orElse("");
|
||||||
|
String[] transHeaderArray = transHeaders.split(",");
|
||||||
|
HttpHeaders headers = serverHttpRequest.getHeaders();
|
||||||
|
Set<String> headerKeys = headers.keySet();
|
||||||
|
for (String httpHeader : headerKeys) {
|
||||||
|
Arrays.stream(transHeaderArray).forEach(transHeader -> {
|
||||||
|
if (transHeader.equals(httpHeader)) {
|
||||||
|
List<String> list = headers.get(httpHeader);
|
||||||
|
String httpHeaderValue = JacksonUtils.serialize2Json(list);
|
||||||
|
// for example, {"trans-headers-kv" : {"header1":"v1","header2":"v2"...}}
|
||||||
|
MetadataContextHolder.get().setTransHeadersKV(httpHeader, httpHeaderValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* Tencent is pleased to support the open source community by making Spring Cloud Tencent available.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 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.metadata.core;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.tencent.cloud.common.metadata.MetadataContext;
|
||||||
|
import com.tencent.cloud.common.metadata.MetadataContextHolder;
|
||||||
|
import com.tencent.cloud.common.util.JacksonUtils;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
|
||||||
|
import org.springframework.mock.web.MockHttpServletRequest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test for {@link TransHeadersTransfer}.
|
||||||
|
*
|
||||||
|
* @author lingxiao.wlx
|
||||||
|
*/
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest(webEnvironment = RANDOM_PORT,
|
||||||
|
classes = DecodeTransferMetadataServletFilterTest.TestApplication.class,
|
||||||
|
properties = {"spring.config.location = classpath:application-test.yml", "spring.main.web-application-type=reactive"})
|
||||||
|
public class TransHeadersTransferTest {
|
||||||
|
@AfterClass
|
||||||
|
public static void afterClass() {
|
||||||
|
MetadataContextHolder.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void transferServletTest() {
|
||||||
|
MetadataContext metadataContext = MetadataContextHolder.get();
|
||||||
|
metadataContext.setTransHeaders("header1,header2,header3", "");
|
||||||
|
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||||
|
request.addHeader("header1", "1");
|
||||||
|
request.addHeader("header2", "2");
|
||||||
|
request.addHeader("header3", "3");
|
||||||
|
TransHeadersTransfer.transfer(request);
|
||||||
|
Map<String, String> transHeadersKV = MetadataContextHolder.get().getTransHeadersKV();
|
||||||
|
Assertions.assertEquals(transHeadersKV.get("header1"), "1");
|
||||||
|
Assertions.assertEquals(transHeadersKV.get("header2"), "2");
|
||||||
|
Assertions.assertEquals(transHeadersKV.get("header3"), "3");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void transferReactiveTest() {
|
||||||
|
MetadataContext metadataContext = MetadataContextHolder.get();
|
||||||
|
metadataContext.setTransHeaders("header1,header2,header3", "");
|
||||||
|
MockServerHttpRequest.BaseBuilder<?> builder = MockServerHttpRequest.get("");
|
||||||
|
String[] header1 = {"1"};
|
||||||
|
String[] header2 = {"2"};
|
||||||
|
String[] header3 = {"3"};
|
||||||
|
builder.header("header1", header1);
|
||||||
|
builder.header("header2", header2);
|
||||||
|
builder.header("header3", header3);
|
||||||
|
MockServerHttpRequest request = builder.build();
|
||||||
|
TransHeadersTransfer.transfer(request);
|
||||||
|
Map<String, String> transHeadersKV = MetadataContextHolder.get().getTransHeadersKV();
|
||||||
|
Assertions.assertEquals(transHeadersKV.get("header1"), JacksonUtils.serialize2Json(header1));
|
||||||
|
Assertions.assertEquals(transHeadersKV.get("header2"), JacksonUtils.serialize2Json(header2));
|
||||||
|
Assertions.assertEquals(transHeadersKV.get("header3"), JacksonUtils.serialize2Json(header3));
|
||||||
|
}
|
||||||
|
}
|
@ -1,126 +0,0 @@
|
|||||||
/*
|
|
||||||
* Tencent is pleased to support the open source community by making Spring Cloud Tencent available.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2019 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.polaris.config.spring.property;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import com.google.common.collect.LinkedListMultimap;
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.google.common.collect.Multimap;
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
import com.tencent.cloud.polaris.config.config.PolarisConfigProperties;
|
|
||||||
|
|
||||||
import org.springframework.beans.BeansException;
|
|
||||||
import org.springframework.beans.MutablePropertyValues;
|
|
||||||
import org.springframework.beans.PropertyValue;
|
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
|
||||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
|
||||||
import org.springframework.beans.factory.config.TypedStringValue;
|
|
||||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
|
||||||
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
|
|
||||||
import org.springframework.lang.NonNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* To process xml config placeholders, e.g.
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* <bean class="com.demo.bean.XmlBean">
|
|
||||||
* <property name="timeout" value="${timeout:200}"/>
|
|
||||||
* <property name="batch" value="${batch:100}"/>
|
|
||||||
* </bean>
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* This source file was originally from:
|
|
||||||
* <code><a href=https://github.com/apolloconfig/apollo/blob/master/apollo-client/src/main/java/com/ctrip/framework/apollo/spring/property/SpringValueDefinitionProcessor.java>
|
|
||||||
* SpringValueDefinitionProcessor</a></code>
|
|
||||||
*
|
|
||||||
* @author weihubeats 2022-7-10
|
|
||||||
*/
|
|
||||||
public class SpringValueDefinitionProcessor implements BeanDefinitionRegistryPostProcessor {
|
|
||||||
private static final Map<BeanDefinitionRegistry, Multimap<String, SpringValueDefinition>> beanName2SpringValueDefinitions =
|
|
||||||
Maps.newConcurrentMap();
|
|
||||||
private static final Set<BeanDefinitionRegistry> PROPERTY_VALUES_PROCESSED_BEAN_FACTORIES = Sets.newConcurrentHashSet();
|
|
||||||
|
|
||||||
private final PlaceholderHelper placeholderHelper;
|
|
||||||
|
|
||||||
private final PolarisConfigProperties polarisConfigProperties;
|
|
||||||
|
|
||||||
public SpringValueDefinitionProcessor(PlaceholderHelper placeholderHelper, PolarisConfigProperties polarisConfigProperties) {
|
|
||||||
this.polarisConfigProperties = polarisConfigProperties;
|
|
||||||
this.placeholderHelper = placeholderHelper;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postProcessBeanDefinitionRegistry(@NonNull BeanDefinitionRegistry registry) throws BeansException {
|
|
||||||
if (polarisConfigProperties.isAutoRefresh()) {
|
|
||||||
processPropertyValues(registry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postProcessBeanFactory(@NonNull ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Multimap<String, SpringValueDefinition> getBeanName2SpringValueDefinitions(BeanDefinitionRegistry registry) {
|
|
||||||
Multimap<String, SpringValueDefinition> springValueDefinitions = beanName2SpringValueDefinitions.get(registry);
|
|
||||||
if (springValueDefinitions == null) {
|
|
||||||
springValueDefinitions = LinkedListMultimap.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
return springValueDefinitions;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processPropertyValues(BeanDefinitionRegistry beanRegistry) {
|
|
||||||
if (!PROPERTY_VALUES_PROCESSED_BEAN_FACTORIES.add(beanRegistry)) {
|
|
||||||
// already initialized
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!beanName2SpringValueDefinitions.containsKey(beanRegistry)) {
|
|
||||||
beanName2SpringValueDefinitions.put(beanRegistry, LinkedListMultimap.create());
|
|
||||||
}
|
|
||||||
|
|
||||||
Multimap<String, SpringValueDefinition> springValueDefinitions = beanName2SpringValueDefinitions.get(beanRegistry);
|
|
||||||
|
|
||||||
String[] beanNames = beanRegistry.getBeanDefinitionNames();
|
|
||||||
for (String beanName : beanNames) {
|
|
||||||
BeanDefinition beanDefinition = beanRegistry.getBeanDefinition(beanName);
|
|
||||||
MutablePropertyValues mutablePropertyValues = beanDefinition.getPropertyValues();
|
|
||||||
List<PropertyValue> propertyValues = mutablePropertyValues.getPropertyValueList();
|
|
||||||
for (PropertyValue propertyValue : propertyValues) {
|
|
||||||
Object value = propertyValue.getValue();
|
|
||||||
if (!(value instanceof TypedStringValue)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
String placeholder = ((TypedStringValue) value).getValue();
|
|
||||||
Set<String> keys = placeholderHelper.extractPlaceholderKeys(placeholder);
|
|
||||||
|
|
||||||
if (keys.isEmpty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String key : keys) {
|
|
||||||
springValueDefinitions.put(beanName, new SpringValueDefinition(key, placeholder, propertyValue.getName()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,75 +0,0 @@
|
|||||||
/*
|
|
||||||
* Tencent is pleased to support the open source community by making Spring Cloud Tencent available.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2019 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.polaris.config.spring.property;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import com.tencent.polaris.api.utils.CollectionUtils;
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.BeanFactory;
|
|
||||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for {@link SpringValueDefinitionProcessor}.
|
|
||||||
*
|
|
||||||
* @author lingxiao.wlx
|
|
||||||
*/
|
|
||||||
public class SpringValueDefinitionProcessorTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void springValueDefinitionProcessorTest() {
|
|
||||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
|
|
||||||
Person person = context.getBean(Person.class);
|
|
||||||
|
|
||||||
SpringValueRegistry springValueRegistry = context.getBean(SpringValueRegistry.class);
|
|
||||||
|
|
||||||
BeanFactory beanFactory = person.getBeanFactory();
|
|
||||||
Collection<SpringValue> name = springValueRegistry.get(beanFactory, "name");
|
|
||||||
Assert.assertFalse(CollectionUtils.isEmpty(name));
|
|
||||||
Optional<SpringValue> nameSpringValueOptional = name.stream().findAny();
|
|
||||||
Assert.assertTrue(nameSpringValueOptional.isPresent());
|
|
||||||
|
|
||||||
SpringValue nameSpringValue = nameSpringValueOptional.get();
|
|
||||||
Method method = nameSpringValue.getMethodParameter().getMethod();
|
|
||||||
Assert.assertTrue(Objects.nonNull(method));
|
|
||||||
Assert.assertEquals("setName", method.getName());
|
|
||||||
Assert.assertEquals("${name:test}", nameSpringValue.getPlaceholder());
|
|
||||||
Assert.assertFalse(nameSpringValue.isField());
|
|
||||||
Assert.assertEquals(String.class, nameSpringValue.getTargetType());
|
|
||||||
|
|
||||||
|
|
||||||
Collection<SpringValue> age = springValueRegistry.get(beanFactory, "age");
|
|
||||||
Assert.assertFalse(CollectionUtils.isEmpty(age));
|
|
||||||
Optional<SpringValue> ageSpringValueOptional = age.stream().findAny();
|
|
||||||
Assert.assertTrue(ageSpringValueOptional.isPresent());
|
|
||||||
|
|
||||||
SpringValue ageSpringValue = ageSpringValueOptional.get();
|
|
||||||
Method method1 = ageSpringValue.getMethodParameter().getMethod();
|
|
||||||
Assert.assertTrue(Objects.nonNull(method1));
|
|
||||||
Assert.assertEquals("setAge", method1.getName());
|
|
||||||
Assert.assertEquals("${age:10}", ageSpringValue.getPlaceholder());
|
|
||||||
Assert.assertFalse(ageSpringValue.isField());
|
|
||||||
Assert.assertEquals(String.class, ageSpringValue.getTargetType());
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* Tencent is pleased to support the open source community by making Spring Cloud Tencent available.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 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.expresstion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expression parser for rate limit rule and router rule.
|
||||||
|
* @author lepdou 2022-10-08
|
||||||
|
*/
|
||||||
|
public interface ExpressionParser {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* whether is valid expression.
|
||||||
|
* @param expression the expression
|
||||||
|
* @return true if is valid
|
||||||
|
*/
|
||||||
|
boolean isExpressionLabel(String expression);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* whether is header expression.
|
||||||
|
* @param expression the expression
|
||||||
|
* @return true if is header expression
|
||||||
|
*/
|
||||||
|
boolean isHeaderLabel(String expression);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* parse label from header expression.
|
||||||
|
* @param expression the expression
|
||||||
|
* @return parsed key from expression
|
||||||
|
*/
|
||||||
|
String parseHeaderKey(String expression);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* whether is query expression.
|
||||||
|
* @param expression the expression
|
||||||
|
* @return true if is query expression
|
||||||
|
*/
|
||||||
|
boolean isQueryLabel(String expression);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* parse label from query expression.
|
||||||
|
* @param expression the expression
|
||||||
|
* @return parsed key from expression
|
||||||
|
*/
|
||||||
|
String parseQueryKey(String expression);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* whether is cookie expression.
|
||||||
|
* @param expression the expression
|
||||||
|
* @return true if is cookie expression
|
||||||
|
*/
|
||||||
|
boolean isCookieLabel(String expression);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* parse label from cookie expression.
|
||||||
|
* @param expression the expression
|
||||||
|
* @return parsed cookie key from expression
|
||||||
|
*/
|
||||||
|
String parseCookieKey(String expression);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* whether is method expression.
|
||||||
|
* @param expression the expression
|
||||||
|
* @return true if is method expression
|
||||||
|
*/
|
||||||
|
boolean isMethodLabel(String expression);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* whether is uri/path expression.
|
||||||
|
* @param expression the expression
|
||||||
|
* @return true if is uri/path expression
|
||||||
|
*/
|
||||||
|
boolean isUriLabel(String expression);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* whether is caller ip expression.
|
||||||
|
* @param expression the expression
|
||||||
|
* @return true if is caller ip expression
|
||||||
|
*/
|
||||||
|
boolean isCallerIPLabel(String expression);
|
||||||
|
}
|
@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* Tencent is pleased to support the open source community by making Spring Cloud Tencent available.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 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.expresstion;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Old custom expression resolver like ${http.query.key}、${http.header.key}.
|
||||||
|
* New expression like $query.key、$header.key
|
||||||
|
* @author lepdou 2022-10-08
|
||||||
|
*/
|
||||||
|
public class ExpressionParserV1 implements ExpressionParser {
|
||||||
|
|
||||||
|
private static final String LABEL_HEADER_PREFIX = "${http.header.";
|
||||||
|
private static final int LABEL_HEADER_PREFIX_LEN = LABEL_HEADER_PREFIX.length();
|
||||||
|
private static final String LABEL_QUERY_PREFIX = "${http.query.";
|
||||||
|
private static final int LABEL_QUERY_PREFIX_LEN = LABEL_QUERY_PREFIX.length();
|
||||||
|
private static final String LABEL_COOKIE_PREFIX = "${http.cookie.";
|
||||||
|
private static final int LABEL_COOKIE_PREFIX_LEN = LABEL_COOKIE_PREFIX.length();
|
||||||
|
private static final String LABEL_METHOD = "${http.method}";
|
||||||
|
private static final String LABEL_URI = "${http.uri}";
|
||||||
|
private static final String LABEL_CALLER_IP = "${http.caller.ip}";
|
||||||
|
private static final String LABEL_PREFIX = "${";
|
||||||
|
private static final String LABEL_SUFFIX = "}";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isExpressionLabel(String labelKey) {
|
||||||
|
if (StringUtils.isEmpty(labelKey)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return StringUtils.startsWith(labelKey, LABEL_PREFIX) && StringUtils.endsWith(labelKey, LABEL_SUFFIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isHeaderLabel(String expression) {
|
||||||
|
return StringUtils.startsWith(expression, LABEL_HEADER_PREFIX) && StringUtils.endsWith(expression, LABEL_SUFFIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String parseHeaderKey(String expression) {
|
||||||
|
return expression.substring(LABEL_HEADER_PREFIX_LEN, expression.length() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isQueryLabel(String expression) {
|
||||||
|
return StringUtils.startsWith(expression, LABEL_QUERY_PREFIX) && StringUtils.endsWith(expression, LABEL_SUFFIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String parseQueryKey(String expression) {
|
||||||
|
return expression.substring(LABEL_QUERY_PREFIX_LEN, expression.length() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCookieLabel(String expression) {
|
||||||
|
return StringUtils.startsWith(expression, LABEL_COOKIE_PREFIX) && StringUtils.endsWith(expression, LABEL_SUFFIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String parseCookieKey(String expression) {
|
||||||
|
return expression.substring(LABEL_COOKIE_PREFIX_LEN, expression.length() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isMethodLabel(String expression) {
|
||||||
|
return StringUtils.equalsIgnoreCase(expression, LABEL_METHOD);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isUriLabel(String expression) {
|
||||||
|
return StringUtils.equalsIgnoreCase(expression, LABEL_URI);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCallerIPLabel(String expression) {
|
||||||
|
return StringUtils.equalsIgnoreCase(expression, LABEL_CALLER_IP);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* Tencent is pleased to support the open source community by making Spring Cloud Tencent available.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 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.expresstion;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* New custom expression resolver like $query.key、$header.key.
|
||||||
|
* Old expression like ${http.query.key}、${http.header.key}
|
||||||
|
* @author lepdou 2022-10-08
|
||||||
|
*/
|
||||||
|
public class ExpressionParserV2 implements ExpressionParser {
|
||||||
|
|
||||||
|
private static final String LABEL_HEADER_PREFIX = "$header.";
|
||||||
|
private static final int LABEL_HEADER_PREFIX_LEN = LABEL_HEADER_PREFIX.length();
|
||||||
|
private static final String LABEL_QUERY_PREFIX = "$query.";
|
||||||
|
private static final int LABEL_QUERY_PREFIX_LEN = LABEL_QUERY_PREFIX.length();
|
||||||
|
private static final String LABEL_METHOD = "$method";
|
||||||
|
private static final String LABEL_PATH = "$path";
|
||||||
|
private static final String LABEL_CALLER_IP = "$caller_ip";
|
||||||
|
private static final String LABEL_PREFIX = "$";
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isExpressionLabel(String expression) {
|
||||||
|
return StringUtils.startsWith(expression, LABEL_PREFIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isHeaderLabel(String expression) {
|
||||||
|
return StringUtils.startsWith(expression, LABEL_HEADER_PREFIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String parseHeaderKey(String expression) {
|
||||||
|
return StringUtils.substring(expression, LABEL_HEADER_PREFIX_LEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isQueryLabel(String expression) {
|
||||||
|
return StringUtils.startsWith(expression, LABEL_QUERY_PREFIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String parseQueryKey(String expression) {
|
||||||
|
return StringUtils.substring(expression, LABEL_QUERY_PREFIX_LEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCookieLabel(String expression) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String parseCookieKey(String expression) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isMethodLabel(String expression) {
|
||||||
|
return StringUtils.equalsIgnoreCase(expression, LABEL_METHOD);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isUriLabel(String expression) {
|
||||||
|
return StringUtils.equalsIgnoreCase(expression, LABEL_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCallerIPLabel(String expression) {
|
||||||
|
return StringUtils.equalsIgnoreCase(expression, LABEL_CALLER_IP);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Tencent is pleased to support the open source community by making Spring Cloud Tencent available.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 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.util.expresstion.ExpressionParserV1;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test for {@link ExpressionParserV1}.
|
||||||
|
* @author lepdou 2022-10-08
|
||||||
|
*/
|
||||||
|
public class ExpressionParserV1Test {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExpressionLabel() {
|
||||||
|
String validLabel1 = "${http.query.uid}";
|
||||||
|
String validLabel2 = "${http.header.uid}";
|
||||||
|
String validLabel3 = "${http.cookie.uid}";
|
||||||
|
String validLabel4 = "${http.method}";
|
||||||
|
String validLabel5 = "${http.uri}";
|
||||||
|
String invalidLabel1 = "${http.queryuid}";
|
||||||
|
String invalidLabel2 = "{http.query.uid}";
|
||||||
|
String invalidLabel3 = "${http.query.uid";
|
||||||
|
String invalidLabel4 = "$ {http.query.uid}";
|
||||||
|
String invalidLabel5 = "${ http.query.uid}";
|
||||||
|
String invalidLabel6 = "${query.uid}";
|
||||||
|
String invalidLabel7 = "http.query.uid";
|
||||||
|
String invalidLabel8 = "$${http.uri}";
|
||||||
|
String invalidLabel9 = "#{http.uri}";
|
||||||
|
|
||||||
|
ExpressionParserV1 parser = new ExpressionParserV1();
|
||||||
|
|
||||||
|
Assert.assertTrue(parser.isExpressionLabel(validLabel1));
|
||||||
|
Assert.assertTrue(parser.isExpressionLabel(validLabel2));
|
||||||
|
Assert.assertTrue(parser.isExpressionLabel(validLabel3));
|
||||||
|
Assert.assertTrue(parser.isExpressionLabel(validLabel4));
|
||||||
|
Assert.assertTrue(parser.isExpressionLabel(validLabel5));
|
||||||
|
Assert.assertTrue(parser.isExpressionLabel(invalidLabel1));
|
||||||
|
Assert.assertFalse(parser.isExpressionLabel(invalidLabel2));
|
||||||
|
Assert.assertFalse(parser.isExpressionLabel(invalidLabel3));
|
||||||
|
Assert.assertFalse(parser.isExpressionLabel(invalidLabel4));
|
||||||
|
Assert.assertTrue(parser.isExpressionLabel(invalidLabel5));
|
||||||
|
Assert.assertTrue(parser.isExpressionLabel(invalidLabel6));
|
||||||
|
Assert.assertFalse(parser.isExpressionLabel(invalidLabel7));
|
||||||
|
Assert.assertFalse(parser.isExpressionLabel(invalidLabel8));
|
||||||
|
Assert.assertFalse(parser.isExpressionLabel(invalidLabel9));
|
||||||
|
|
||||||
|
Assert.assertTrue(parser.isQueryLabel(validLabel1));
|
||||||
|
Assert.assertTrue(parser.isHeaderLabel(validLabel2));
|
||||||
|
Assert.assertTrue(parser.isCookieLabel(validLabel3));
|
||||||
|
Assert.assertTrue(parser.isMethodLabel(validLabel4));
|
||||||
|
Assert.assertTrue(parser.isUriLabel(validLabel5));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* Tencent is pleased to support the open source community by making Spring Cloud Tencent available.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 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.util.expresstion.ExpressionParserV2;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test for {@link ExpressionParserV2}.
|
||||||
|
* @author lepdou 2022-10-08
|
||||||
|
*/
|
||||||
|
public class ExpressionParserV2Test {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExpressionLabel() {
|
||||||
|
String validLabel1 = "${http.query.uid}";
|
||||||
|
String validLabel2 = "${http.header.uid}";
|
||||||
|
String validLabel3 = "${http.cookie.uid}";
|
||||||
|
String validLabel4 = "${http.method}";
|
||||||
|
String validLabel5 = "${http.uri}";
|
||||||
|
String invalidLabel1 = "${http.queryuid}";
|
||||||
|
String invalidLabel2 = "{http.query.uid}";
|
||||||
|
String invalidLabel3 = "${http.query.uid";
|
||||||
|
String invalidLabel4 = "$ {http.query.uid}";
|
||||||
|
String invalidLabel5 = "${ http.query.uid}";
|
||||||
|
String invalidLabel6 = "${query.uid}";
|
||||||
|
String invalidLabel7 = "http.query.uid";
|
||||||
|
String invalidLabel8 = "$${http.uri}";
|
||||||
|
String invalidLabel9 = "#{http.uri}";
|
||||||
|
|
||||||
|
ExpressionParserV2 parser = new ExpressionParserV2();
|
||||||
|
|
||||||
|
Assert.assertTrue(parser.isExpressionLabel(validLabel1));
|
||||||
|
Assert.assertTrue(parser.isExpressionLabel(validLabel2));
|
||||||
|
Assert.assertTrue(parser.isExpressionLabel(validLabel3));
|
||||||
|
Assert.assertTrue(parser.isExpressionLabel(validLabel4));
|
||||||
|
Assert.assertTrue(parser.isExpressionLabel(validLabel5));
|
||||||
|
Assert.assertTrue(parser.isExpressionLabel(invalidLabel1));
|
||||||
|
Assert.assertFalse(parser.isExpressionLabel(invalidLabel2));
|
||||||
|
Assert.assertTrue(parser.isExpressionLabel(invalidLabel3));
|
||||||
|
Assert.assertTrue(parser.isExpressionLabel(invalidLabel4));
|
||||||
|
Assert.assertTrue(parser.isExpressionLabel(invalidLabel5));
|
||||||
|
Assert.assertTrue(parser.isExpressionLabel(invalidLabel6));
|
||||||
|
Assert.assertFalse(parser.isExpressionLabel(invalidLabel7));
|
||||||
|
Assert.assertTrue(parser.isExpressionLabel(invalidLabel8));
|
||||||
|
Assert.assertFalse(parser.isExpressionLabel(invalidLabel9));
|
||||||
|
|
||||||
|
Assert.assertFalse(parser.isQueryLabel(validLabel1));
|
||||||
|
Assert.assertFalse(parser.isHeaderLabel(validLabel2));
|
||||||
|
Assert.assertFalse(parser.isCookieLabel(validLabel3));
|
||||||
|
Assert.assertFalse(parser.isMethodLabel(validLabel4));
|
||||||
|
Assert.assertFalse(parser.isUriLabel(validLabel5));
|
||||||
|
|
||||||
|
Assert.assertTrue(parser.isHeaderLabel("$header.userId"));
|
||||||
|
Assert.assertTrue(parser.isMethodLabel("$method"));
|
||||||
|
Assert.assertTrue(parser.isQueryLabel("$query.userId"));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue