Resolve conflicts .

pull/336/head
misselvexu 3 years ago
commit 3518c51e3e

@ -21,8 +21,9 @@
- [Fix the current limiting effect is that other requests cannot be processed when queuing at a constant speed](https://github.com/Tencent/spring-cloud-tencent/pull/316) - [Fix the current limiting effect is that other requests cannot be processed when queuing at a constant speed](https://github.com/Tencent/spring-cloud-tencent/pull/316)
- [Fix config file format misspell](https://github.com/Tencent/spring-cloud-tencent/pull/319) - [Fix config file format misspell](https://github.com/Tencent/spring-cloud-tencent/pull/319)
- [UT: improve test coverage for load balancer unit test](https://github.com/Tencent/spring-cloud-tencent/pull/325) - [UT: improve test coverage for load balancer unit test](https://github.com/Tencent/spring-cloud-tencent/pull/325)
- [Feature: Optimize polaris load balancer test code format](https://github.com/Tencent/spring-cloud-tencent/pull/333) - [optimize polaris load balancer test code format](https://github.com/Tencent/spring-cloud-tencent/pull/333)
- [feat:Add GitHub action of codecov.yml.](https://github.com/Tencent/spring-cloud-tencent/pull/328) - [feat:Add GitHub action of codecov.yml.](https://github.com/Tencent/spring-cloud-tencent/pull/328)
- [Feature: add spring cloud tencent logo](https://github.com/Tencent/spring-cloud-tencent/pull/329) - [Feature: add spring cloud tencent logo](https://github.com/Tencent/spring-cloud-tencent/pull/329)
- [Feature: Optimize static metadata manager](https://github.com/Tencent/spring-cloud-tencent/pull/327) - [Feature: Optimize static metadata manager](https://github.com/Tencent/spring-cloud-tencent/pull/327)
- [test:update junit of metadata.](https://github.com/Tencent/spring-cloud-tencent/pull/340) - [test:update junit of metadata.](https://github.com/Tencent/spring-cloud-tencent/pull/340)
- [Optimize code style & unit test case](https://github.com/Tencent/spring-cloud-tencent/pull/336)

@ -48,7 +48,7 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = RANDOM_PORT, @SpringBootTest(webEnvironment = RANDOM_PORT,
classes = EncodeTransferMedataScgFilterTest.TestApplication.class, classes = EncodeTransferMedataScgFilterTest.TestApplication.class,
properties = { "spring.config.location = classpath:application-test.yml", "spring.main.web-application-type = reactive" }) properties = {"spring.config.location = classpath:application-test.yml", "spring.main.web-application-type = reactive"})
public class EncodeTransferMedataScgFilterTest { public class EncodeTransferMedataScgFilterTest {
@Autowired @Autowired
@ -60,11 +60,17 @@ public class EncodeTransferMedataScgFilterTest {
@Test @Test
public void testTransitiveMetadataFromApplicationConfig() throws UnsupportedEncodingException { public void testTransitiveMetadataFromApplicationConfig() throws UnsupportedEncodingException {
EncodeTransferMedataScgFilter filter = applicationContext.getBean(EncodeTransferMedataScgFilter.class); EncodeTransferMedataScgFilter filter = applicationContext.getBean(EncodeTransferMedataScgFilter.class);
// Mock Server Http Request
MockServerHttpRequest.BaseBuilder<?> builder = MockServerHttpRequest.get(""); MockServerHttpRequest.BaseBuilder<?> builder = MockServerHttpRequest.get("");
MockServerWebExchange exchange = MockServerWebExchange.from(builder); MockServerWebExchange exchange = MockServerWebExchange.from(builder);
filter.filter(exchange, chain); filter.filter(exchange, chain);
String metadataStr = exchange.getRequest().getHeaders().getFirst(MetadataConstant.HeaderName.CUSTOM_METADATA);
String decode = URLDecoder.decode(metadataStr, StandardCharsets.UTF_8.name()); // Check metadata str
String metadata = exchange.getRequest().getHeaders().getFirst(MetadataConstant.HeaderName.CUSTOM_METADATA);
Assertions.assertThat(metadata).isNotNull();
String decode = URLDecoder.decode(metadata, StandardCharsets.UTF_8.name());
Map<String, String> transitiveMap = JacksonUtils.deserialize2Map(decode); Map<String, String> transitiveMap = JacksonUtils.deserialize2Map(decode);
Assertions.assertThat(transitiveMap.size()).isEqualTo(1); Assertions.assertThat(transitiveMap.size()).isEqualTo(1);
Assertions.assertThat(transitiveMap.get("b")).isEqualTo("2"); Assertions.assertThat(transitiveMap.get("b")).isEqualTo("2");

@ -27,7 +27,6 @@ import com.netflix.zuul.context.RequestContext;
import com.tencent.cloud.common.constant.MetadataConstant; import com.tencent.cloud.common.constant.MetadataConstant;
import com.tencent.cloud.common.util.JacksonUtils; import com.tencent.cloud.common.util.JacksonUtils;
import org.assertj.core.api.Assertions; import org.assertj.core.api.Assertions;
import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -42,19 +41,21 @@ import org.springframework.test.context.junit4.SpringRunner;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
/** /**
* Test for {@link EncodeTransferMetadataZuulFilter}.
*
* @author quan * @author quan
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = RANDOM_PORT, @SpringBootTest(webEnvironment = RANDOM_PORT,
classes = EncodeTransferMetadataZuulFilterTest.TestApplication.class, classes = EncodeTransferMetadataZuulFilterTest.TestApplication.class,
properties = { "spring.config.location = classpath:application-test.yml", "spring.main.web-application-type = reactive" }) properties = {"spring.config.location = classpath:application-test.yml", "spring.main.web-application-type = reactive"})
public class EncodeTransferMetadataZuulFilterTest { public class EncodeTransferMetadataZuulFilterTest {
@Autowired @Autowired
private ApplicationContext applicationContext; private ApplicationContext applicationContext;
private MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest(); private final MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
@Before @Before
public void init() { public void init() {
@ -69,11 +70,13 @@ public class EncodeTransferMetadataZuulFilterTest {
filter.run(); filter.run();
final RequestContext ctx = RequestContext.getCurrentContext(); final RequestContext ctx = RequestContext.getCurrentContext();
Map<String, String> zuulRequestHeaders = ctx.getZuulRequestHeaders(); Map<String, String> zuulRequestHeaders = ctx.getZuulRequestHeaders();
String metaData = zuulRequestHeaders.get(MetadataConstant.HeaderName.CUSTOM_METADATA.toLowerCase()); String metadata = zuulRequestHeaders.get(MetadataConstant.HeaderName.CUSTOM_METADATA.toLowerCase());
String decode = URLDecoder.decode(metaData, StandardCharsets.UTF_8.name()); Assertions.assertThat(metadata).isNotNull();
String decode = URLDecoder.decode(metadata, StandardCharsets.UTF_8.name());
Map<String, String> transitiveMap = JacksonUtils.deserialize2Map(decode); Map<String, String> transitiveMap = JacksonUtils.deserialize2Map(decode);
Assertions.assertThat(transitiveMap.size()).isEqualTo(1); Assertions.assertThat(transitiveMap.size()).isEqualTo(1);
Assert.assertEquals(transitiveMap.get("b"), "2"); Assertions.assertThat(transitiveMap.get("b")).isEqualTo("2");
} }
@SpringBootApplication @SpringBootApplication

@ -47,7 +47,11 @@ public class PolarisRestTemplateResponseErrorHandler implements ResponseErrorHan
private static final Logger LOG = LoggerFactory.getLogger(PolarisRestTemplateResponseErrorHandler.class); private static final Logger LOG = LoggerFactory.getLogger(PolarisRestTemplateResponseErrorHandler.class);
<<<<<<< HEAD
private static final String FILE_NAME = "connection"; private static final String FILE_NAME = "connection";
=======
private static final String FIELD_NAME = "connection";
>>>>>>> origin/improve/pr-322
private final ConsumerAPI consumerAPI; private final ConsumerAPI consumerAPI;
@ -77,7 +81,11 @@ public class PolarisRestTemplateResponseErrorHandler implements ResponseErrorHan
public void handleError(@NonNull URI url, @NonNull HttpMethod method, @NonNull ClientHttpResponse response) throws IOException { public void handleError(@NonNull URI url, @NonNull HttpMethod method, @NonNull ClientHttpResponse response) throws IOException {
ServiceCallResult resultRequest = createServiceCallResult(url); ServiceCallResult resultRequest = createServiceCallResult(url);
try { try {
<<<<<<< HEAD
HttpURLConnection connection = (HttpURLConnection) ReflectionUtils.getFieldValue(response, FILE_NAME); HttpURLConnection connection = (HttpURLConnection) ReflectionUtils.getFieldValue(response, FILE_NAME);
=======
HttpURLConnection connection = (HttpURLConnection) ReflectionUtils.getFieldValue(response, FIELD_NAME);
>>>>>>> origin/improve/pr-322
if (connection != null) { if (connection != null) {
URL realURL = connection.getURL(); URL realURL = connection.getURL();
resultRequest.setHost(realURL.getHost()); resultRequest.setHost(realURL.getHost());

Loading…
Cancel
Save