Compare commits
26
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3bba08931d | ||
|
|
0853ccc1e5 | ||
|
|
13f91320b1 | ||
|
|
7af0efd569 | ||
|
|
70a9002002 | ||
|
|
ad892a23f0 | ||
|
|
c0f314a5f0 | ||
|
|
56dc4e07e4 | ||
|
|
9167752bfb | ||
|
|
127c866616 | ||
|
|
0e6b33f480 | ||
|
|
17d0161faf | ||
|
|
d6783a6f1e | ||
|
|
548e4d55ef | ||
|
|
55ceafae4d | ||
|
|
0c87527ea5 | ||
|
|
1275875ddb | ||
|
|
c4b9492a9b | ||
|
|
3acf5f9e92 | ||
|
|
e9e38d0274 | ||
|
|
28b50401c5 | ||
|
|
6479db0a54 | ||
|
|
f7e490c466 | ||
|
|
d60cda824d | ||
|
|
190f5a9083 | ||
|
|
1005749eb5 |
@@ -20,17 +20,12 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Set up JDK 1.8
|
- name: Set up JDK ${{ matrix.java }}
|
||||||
uses: actions/setup-java@v1
|
uses: actions/setup-java@v2
|
||||||
with:
|
with:
|
||||||
java-version: 1.8
|
distribution: 'zulu'
|
||||||
- name: Cache local Maven repository
|
java-version: ${{ matrix.java }}
|
||||||
uses: actions/cache@v2
|
cache: 'maven'
|
||||||
with:
|
|
||||||
path: ~/.m2/repository
|
|
||||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-maven-
|
|
||||||
- name: Build with Maven
|
- name: Build with Maven
|
||||||
run: ./mvnw clean install -B -U -P sonar
|
run: ./mvnw clean install -B -U -P sonar
|
||||||
- uses: codecov/codecov-action@v1
|
- uses: codecov/codecov-action@v1
|
||||||
|
|||||||
+2
-16
@@ -66,23 +66,9 @@ the `.mvn` configuration, so if you find you have to do it to make a
|
|||||||
build succeed, please raise a ticket to get the settings added to
|
build succeed, please raise a ticket to get the settings added to
|
||||||
source control.
|
source control.
|
||||||
|
|
||||||
For hints on how to build the project look in `.travis.yml` if there
|
The projects that require middleware (i.e. Redis) for testing generally
|
||||||
is one. There should be a "script" and maybe "install" command. Also
|
require that a local instance of [Docker](https://www.docker.com/get-started) is installed and running.
|
||||||
look at the "services" section to see if any services need to be
|
|
||||||
running locally (e.g. mongo or rabbit). Ignore the git-related bits
|
|
||||||
that you might find in "before_install" since they're related to setting git
|
|
||||||
credentials and you already have those.
|
|
||||||
|
|
||||||
The projects that require middleware generally include a
|
|
||||||
`docker-compose.yml`, so consider using
|
|
||||||
https://docs.docker.com/compose/[Docker Compose] to run the middeware servers
|
|
||||||
in Docker containers. See the README in the
|
|
||||||
https://github.com/spring-cloud-samples/scripts[scripts demo
|
|
||||||
repository] for specific instructions about the common cases of mongo,
|
|
||||||
rabbit and redis.
|
|
||||||
|
|
||||||
NOTE: If all else fails, build with the command from `.travis.yml` (usually
|
|
||||||
`./mvnw install`).
|
|
||||||
|
|
||||||
=== Documentation
|
=== Documentation
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-openfeign</artifactId>
|
<artifactId>spring-cloud-openfeign</artifactId>
|
||||||
<version>3.0.4</version>
|
<version>3.0.7-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>spring-cloud-openfeign-docs</artifactId>
|
<artifactId>spring-cloud-openfeign-docs</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|||||||
@@ -491,10 +491,7 @@ public interface UserClient extends UserService {
|
|||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
NOTE: It is generally not advisable to share an interface between a
|
WARNING: `@FeignClient` interfaces should not be shared between server and client and annotating `@FeignClient` interfaces with `@RequestMapping` on class level is no longer supported.
|
||||||
server and a client. It introduces tight coupling, and is also not supported by
|
|
||||||
all the maintained Spring MVC versions (method parameter
|
|
||||||
mapping is not inherited in some versions).
|
|
||||||
|
|
||||||
=== Feign request/response compression
|
=== Feign request/response compression
|
||||||
|
|
||||||
|
|||||||
@@ -4,14 +4,14 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>spring-cloud-openfeign</artifactId>
|
<artifactId>spring-cloud-openfeign</artifactId>
|
||||||
<version>3.0.4</version>
|
<version>3.0.7-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>Spring Cloud OpenFeign</name>
|
<name>Spring Cloud OpenFeign</name>
|
||||||
<description>Spring Cloud OpenFeign</description>
|
<description>Spring Cloud OpenFeign</description>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-build</artifactId>
|
<artifactId>spring-cloud-build</artifactId>
|
||||||
<version>3.0.4</version>
|
<version>3.0.5</version>
|
||||||
<relativePath/>
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
<scm>
|
<scm>
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<main.basedir>${basedir}</main.basedir>
|
<main.basedir>${basedir}</main.basedir>
|
||||||
<jackson.version>2.11.3</jackson.version>
|
<jackson.version>2.11.3</jackson.version>
|
||||||
<spring-cloud-commons.version>3.0.4</spring-cloud-commons.version>
|
<spring-cloud-commons.version>3.0.6-SNAPSHOT</spring-cloud-commons.version>
|
||||||
|
|
||||||
<!-- Plugin versions -->
|
<!-- Plugin versions -->
|
||||||
<maven-eclipse-plugin.version>2.10</maven-eclipse-plugin.version>
|
<maven-eclipse-plugin.version>2.10</maven-eclipse-plugin.version>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-openfeign</artifactId>
|
<artifactId>spring-cloud-openfeign</artifactId>
|
||||||
<version>3.0.4</version>
|
<version>3.0.7-SNAPSHOT</version>
|
||||||
<relativePath>..</relativePath> <!-- lookup parent from repository -->
|
<relativePath>..</relativePath> <!-- lookup parent from repository -->
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>spring-cloud-openfeign-core</artifactId>
|
<artifactId>spring-cloud-openfeign-core</artifactId>
|
||||||
@@ -183,13 +183,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.protobuf</groupId>
|
<groupId>com.google.protobuf</groupId>
|
||||||
<artifactId>protobuf-java</artifactId>
|
<artifactId>protobuf-java</artifactId>
|
||||||
<version>3.14.0</version>
|
<version>3.19.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.vavr</groupId>
|
<groupId>io.vavr</groupId>
|
||||||
<artifactId>vavr</artifactId>
|
<artifactId>vavr</artifactId>
|
||||||
<version>0.10.3</version>
|
<version>0.10.4</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
+1
-1
@@ -169,7 +169,7 @@ public class FeignAutoConfiguration {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String resolveCircuitBreakerName(String feignClientName, Target<?> target, Method method) {
|
public String resolveCircuitBreakerName(String feignClientName, Target<?> target, Method method) {
|
||||||
return Feign.configKey(target.getClass(), method);
|
return Feign.configKey(target.type(), method);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -70,7 +70,7 @@ import static org.springframework.cloud.openfeign.loadbalancer.LoadBalancerUtils
|
|||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
public class RetryableFeignBlockingLoadBalancerClient implements Client {
|
public class RetryableFeignBlockingLoadBalancerClient implements Client {
|
||||||
|
|
||||||
private static final Log LOG = LogFactory.getLog(FeignBlockingLoadBalancerClient.class);
|
private static final Log LOG = LogFactory.getLog(RetryableFeignBlockingLoadBalancerClient.class);
|
||||||
|
|
||||||
private final Client delegate;
|
private final Client delegate;
|
||||||
|
|
||||||
|
|||||||
+23
-5
@@ -38,6 +38,8 @@ import org.springframework.data.domain.Sort;
|
|||||||
*
|
*
|
||||||
* @author Pascal Büttiker
|
* @author Pascal Büttiker
|
||||||
* @author Olga Maciaszek-Sharma
|
* @author Olga Maciaszek-Sharma
|
||||||
|
* @author Pedro Mendes
|
||||||
|
* @author Nikita Konev
|
||||||
*/
|
*/
|
||||||
public class PageJacksonModule extends Module {
|
public class PageJacksonModule extends Module {
|
||||||
|
|
||||||
@@ -69,6 +71,7 @@ public class PageJacksonModule extends Module {
|
|||||||
@JsonProperty("size") int size, @JsonProperty("totalElements") @JsonAlias({ "total-elements",
|
@JsonProperty("size") int size, @JsonProperty("totalElements") @JsonAlias({ "total-elements",
|
||||||
"total_elements", "totalelements", "TotalElements" }) long totalElements,
|
"total_elements", "totalelements", "TotalElements" }) long totalElements,
|
||||||
@JsonProperty("sort") Sort sort) {
|
@JsonProperty("sort") Sort sort) {
|
||||||
|
if (size > 0) {
|
||||||
PageRequest pageRequest;
|
PageRequest pageRequest;
|
||||||
if (sort != null) {
|
if (sort != null) {
|
||||||
pageRequest = PageRequest.of(number, size, sort);
|
pageRequest = PageRequest.of(number, size, sort);
|
||||||
@@ -77,10 +80,13 @@ public class PageJacksonModule extends Module {
|
|||||||
pageRequest = PageRequest.of(number, size);
|
pageRequest = PageRequest.of(number, size);
|
||||||
}
|
}
|
||||||
delegate = new PageImpl<>(content, pageRequest, totalElements);
|
delegate = new PageImpl<>(content, pageRequest, totalElements);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
delegate = new PageImpl<>(content);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonProperty
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public int getTotalPages() {
|
public int getTotalPages() {
|
||||||
return delegate.getTotalPages();
|
return delegate.getTotalPages();
|
||||||
@@ -104,7 +110,7 @@ public class PageJacksonModule extends Module {
|
|||||||
return delegate.getSize();
|
return delegate.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonProperty
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public int getNumberOfElements() {
|
public int getNumberOfElements() {
|
||||||
return delegate.getNumberOfElements();
|
return delegate.getNumberOfElements();
|
||||||
@@ -128,13 +134,13 @@ public class PageJacksonModule extends Module {
|
|||||||
return delegate.getSort();
|
return delegate.getSort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonProperty
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public boolean isFirst() {
|
public boolean isFirst() {
|
||||||
return delegate.isFirst();
|
return delegate.isFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonProperty
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public boolean isLast() {
|
public boolean isLast() {
|
||||||
return delegate.isLast();
|
return delegate.isLast();
|
||||||
@@ -176,6 +182,18 @@ public class PageJacksonModule extends Module {
|
|||||||
return delegate.iterator();
|
return delegate.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public Pageable getPageable() {
|
||||||
|
return delegate.getPageable();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return delegate.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-33
@@ -35,6 +35,8 @@ import feign.Feign;
|
|||||||
import feign.MethodMetadata;
|
import feign.MethodMetadata;
|
||||||
import feign.Param;
|
import feign.Param;
|
||||||
import feign.Request;
|
import feign.Request;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import org.springframework.cloud.openfeign.AnnotatedParameterProcessor;
|
import org.springframework.cloud.openfeign.AnnotatedParameterProcessor;
|
||||||
import org.springframework.cloud.openfeign.CollectionFormat;
|
import org.springframework.cloud.openfeign.CollectionFormat;
|
||||||
@@ -82,6 +84,8 @@ import static org.springframework.core.annotation.AnnotatedElementUtils.findMerg
|
|||||||
*/
|
*/
|
||||||
public class SpringMvcContract extends Contract.BaseContract implements ResourceLoaderAware {
|
public class SpringMvcContract extends Contract.BaseContract implements ResourceLoaderAware {
|
||||||
|
|
||||||
|
private static final Log LOG = LogFactory.getLog(SpringMvcContract.class);
|
||||||
|
|
||||||
private static final String ACCEPT = "Accept";
|
private static final String ACCEPT = "Accept";
|
||||||
|
|
||||||
private static final String CONTENT_TYPE = "Content-Type";
|
private static final String CONTENT_TYPE = "Content-Type";
|
||||||
@@ -169,47 +173,18 @@ public class SpringMvcContract extends Contract.BaseContract implements Resource
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void processAnnotationOnClass(MethodMetadata data, Class<?> clz) {
|
protected void processAnnotationOnClass(MethodMetadata data, Class<?> clz) {
|
||||||
if (clz.getInterfaces().length == 0) {
|
|
||||||
RequestMapping classAnnotation = findMergedAnnotation(clz, RequestMapping.class);
|
RequestMapping classAnnotation = findMergedAnnotation(clz, RequestMapping.class);
|
||||||
if (classAnnotation != null) {
|
if (classAnnotation != null) {
|
||||||
// Prepend path from class annotation if specified
|
LOG.error("Cannot process class: " + clz.getName()
|
||||||
if (classAnnotation.value().length > 0) {
|
+ ". @RequestMapping annotation is not allowed on @FeignClient interfaces.");
|
||||||
String pathValue = emptyToNull(classAnnotation.value()[0]);
|
throw new IllegalArgumentException("@RequestMapping annotation not allowed on @FeignClient interfaces");
|
||||||
pathValue = resolve(pathValue);
|
|
||||||
if (!pathValue.startsWith("/")) {
|
|
||||||
pathValue = "/" + pathValue;
|
|
||||||
}
|
|
||||||
data.template().uri(pathValue);
|
|
||||||
if (data.template().decodeSlash() != decodeSlash) {
|
|
||||||
data.template().decodeSlash(decodeSlash);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MethodMetadata parseAndValidateMetadata(Class<?> targetType, Method method) {
|
public MethodMetadata parseAndValidateMetadata(Class<?> targetType, Method method) {
|
||||||
processedMethods.put(Feign.configKey(targetType, method), method);
|
processedMethods.put(Feign.configKey(targetType, method), method);
|
||||||
MethodMetadata md = super.parseAndValidateMetadata(targetType, method);
|
return super.parseAndValidateMetadata(targetType, method);
|
||||||
|
|
||||||
RequestMapping classAnnotation = findMergedAnnotation(targetType, RequestMapping.class);
|
|
||||||
if (classAnnotation != null) {
|
|
||||||
// produces - use from class annotation only if method has not specified this
|
|
||||||
if (!md.template().headers().containsKey(ACCEPT)) {
|
|
||||||
parseProduces(md, method, classAnnotation);
|
|
||||||
}
|
|
||||||
|
|
||||||
// consumes -- use from class annotation only if method has not specified this
|
|
||||||
if (!md.template().headers().containsKey(CONTENT_TYPE)) {
|
|
||||||
parseConsumes(md, method, classAnnotation);
|
|
||||||
}
|
|
||||||
|
|
||||||
// headers -- class annotation is inherited to methods, always write these if
|
|
||||||
// present
|
|
||||||
parseHeaders(md, method, classAnnotation);
|
|
||||||
}
|
|
||||||
return md;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+44
@@ -16,13 +16,18 @@
|
|||||||
|
|
||||||
package org.springframework.cloud.openfeign.support;
|
package org.springframework.cloud.openfeign.support;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.ValueSource;
|
import org.junit.jupiter.params.provider.ValueSource;
|
||||||
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageImpl;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@@ -31,6 +36,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
*
|
*
|
||||||
* @author Ruben Vervaeke
|
* @author Ruben Vervaeke
|
||||||
* @author Olga Maciaszek-Sharma
|
* @author Olga Maciaszek-Sharma
|
||||||
|
* @author Pedro Mendes
|
||||||
|
* @author Nikita Konev
|
||||||
*/
|
*/
|
||||||
public class PageJacksonModuleTests {
|
public class PageJacksonModuleTests {
|
||||||
|
|
||||||
@@ -40,6 +47,7 @@ public class PageJacksonModuleTests {
|
|||||||
public static void initialize() {
|
public static void initialize() {
|
||||||
objectMapper = new ObjectMapper();
|
objectMapper = new ObjectMapper();
|
||||||
objectMapper.registerModule(new PageJacksonModule());
|
objectMapper.registerModule(new PageJacksonModule());
|
||||||
|
objectMapper.registerModule(new SortJacksonModule());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@@ -58,4 +66,40 @@ public class PageJacksonModuleTests {
|
|||||||
assertThat(result.getPageable().getPageNumber()).isEqualTo(1);
|
assertThat(result.getPageable().getPageNumber()).isEqualTo(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void serializeAndDeserializeEmpty() throws JsonProcessingException {
|
||||||
|
// Given
|
||||||
|
PageImpl<Object> objects = new PageImpl<>(new ArrayList<>());
|
||||||
|
String pageJson = objectMapper.writeValueAsString(objects);
|
||||||
|
// When
|
||||||
|
Page<?> result = objectMapper.readValue(pageJson, Page.class);
|
||||||
|
// Then
|
||||||
|
assertThat(result).isNotNull();
|
||||||
|
assertThat(result.getTotalElements()).isEqualTo(0);
|
||||||
|
assertThat(result.getContent()).hasSize(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void serializeAndDeserializeFilledMultiple() throws JsonProcessingException {
|
||||||
|
// Given
|
||||||
|
ArrayList<Object> strings0 = new ArrayList<>();
|
||||||
|
strings0.add("first element");
|
||||||
|
strings0.add("second element");
|
||||||
|
PageImpl<Object> objects = new PageImpl<>(strings0, PageRequest.of(6, 2), 100);
|
||||||
|
assertThat(objects.getContent()).hasSize(2);
|
||||||
|
assertThat(objects.getPageable().getPageSize()).isEqualTo(2);
|
||||||
|
|
||||||
|
String pageJson = objectMapper.writeValueAsString(objects);
|
||||||
|
// When
|
||||||
|
Page<?> result = objectMapper.readValue(pageJson, Page.class);
|
||||||
|
// Then
|
||||||
|
assertThat(result).isNotNull();
|
||||||
|
assertThat(result.getTotalElements()).isEqualTo(100);
|
||||||
|
assertThat(result.getContent()).hasSize(2);
|
||||||
|
assertThat(result.getContent().get(0)).isEqualTo("first element");
|
||||||
|
assertThat(result.getContent().get(1)).isEqualTo("second element");
|
||||||
|
assertThat(result.getPageable().getPageSize()).isEqualTo(2);
|
||||||
|
assertThat(result.getPageable().getPageNumber()).isEqualTo(6);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-44
@@ -63,6 +63,7 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY;
|
|||||||
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
|
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
|
||||||
import static feign.CollectionFormat.SSV;
|
import static feign.CollectionFormat.SSV;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||||
import static org.junit.Assume.assumeTrue;
|
import static org.junit.Assume.assumeTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -169,16 +170,12 @@ public class SpringMvcContractTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testProcessAnnotations_Class_AnnotationsGetSpecificTest() throws Exception {
|
public void testProcessAnnotations_Class_Annotations_RequestMapping() {
|
||||||
Method method = TestTemplate_Class_Annotations.class.getDeclaredMethod("getSpecificTest", String.class,
|
assertThatIllegalArgumentException().isThrownBy(() -> {
|
||||||
|
Method method = TestTemplate_Class_RequestMapping.class.getDeclaredMethod("getSpecificTest", String.class,
|
||||||
String.class);
|
String.class);
|
||||||
MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method);
|
contract.parseAndValidateMetadata(method.getDeclaringClass(), method);
|
||||||
|
});
|
||||||
assertThat(data.template().url()).isEqualTo("/prepend/{classId}/test/{testId}");
|
|
||||||
assertThat(data.template().method()).isEqualTo("GET");
|
|
||||||
|
|
||||||
assertThat(data.indexToName().get(0).iterator().next()).isEqualTo("classId");
|
|
||||||
assertThat(data.indexToName().get(1).iterator().next()).isEqualTo("testId");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -186,25 +183,13 @@ public class SpringMvcContractTests {
|
|||||||
Method method = TestTemplate_Class_Annotations.class.getDeclaredMethod("getAllTests", String.class);
|
Method method = TestTemplate_Class_Annotations.class.getDeclaredMethod("getAllTests", String.class);
|
||||||
MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method);
|
MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method);
|
||||||
|
|
||||||
assertThat(data.template().url()).isEqualTo("/prepend/{classId}");
|
assertThat(data.template().url()).isEqualTo("/");
|
||||||
assertThat(data.template().method()).isEqualTo("GET");
|
assertThat(data.template().method()).isEqualTo("GET");
|
||||||
|
|
||||||
assertThat(data.indexToName().get(0).iterator().next()).isEqualTo("classId");
|
assertThat(data.indexToName().get(0).iterator().next()).isEqualTo("classId");
|
||||||
assertThat(data.template().decodeSlash()).isTrue();
|
assertThat(data.template().decodeSlash()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testProcessAnnotations_Class_AnnotationsGetAllTests_EncodeSlash() throws Exception {
|
|
||||||
contract = new SpringMvcContract(Collections.emptyList(), getConversionService(), false);
|
|
||||||
|
|
||||||
Method method = TestTemplate_Class_Annotations.class.getDeclaredMethod("getAllTests", String.class);
|
|
||||||
MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method);
|
|
||||||
|
|
||||||
assertThat(data.template().url()).isEqualTo("/prepend/{classId}");
|
|
||||||
|
|
||||||
assertThat(data.template().decodeSlash()).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testProcessAnnotations_ExtendedInterface() throws Exception {
|
public void testProcessAnnotations_ExtendedInterface() throws Exception {
|
||||||
Method extendedMethod = TestTemplate_Extended.class.getMethod("getAllTests", String.class);
|
Method extendedMethod = TestTemplate_Extended.class.getMethod("getAllTests", String.class);
|
||||||
@@ -221,22 +206,6 @@ public class SpringMvcContractTests {
|
|||||||
assertThat(data.template().decodeSlash()).isTrue();
|
assertThat(data.template().decodeSlash()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testProcessAnnotations_ExtendedInterface_EncodeSlash() throws Exception {
|
|
||||||
contract = new SpringMvcContract(Collections.emptyList(), getConversionService(), false);
|
|
||||||
|
|
||||||
Method extendedMethod = TestTemplate_Extended.class.getMethod("getAllTests", String.class);
|
|
||||||
MethodMetadata extendedData = contract.parseAndValidateMetadata(extendedMethod.getDeclaringClass(),
|
|
||||||
extendedMethod);
|
|
||||||
|
|
||||||
Method method = TestTemplate_Class_Annotations.class.getDeclaredMethod("getAllTests", String.class);
|
|
||||||
MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method);
|
|
||||||
|
|
||||||
assertThat(data.template().url()).isEqualTo(extendedData.template().url());
|
|
||||||
assertThat(data.template().method()).isEqualTo(extendedData.template().method());
|
|
||||||
assertThat(data.template().decodeSlash()).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testProcessAnnotations_SimplePost() throws Exception {
|
public void testProcessAnnotations_SimplePost() throws Exception {
|
||||||
Method method = TestTemplate_Simple.class.getDeclaredMethod("postTest", TestObject.class);
|
Method method = TestTemplate_Simple.class.getDeclaredMethod("postTest", TestObject.class);
|
||||||
@@ -267,7 +236,7 @@ public class SpringMvcContractTests {
|
|||||||
Integer.class);
|
Integer.class);
|
||||||
MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method);
|
MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method);
|
||||||
|
|
||||||
assertThat(data.template().url()).isEqualTo("/advanced/test/{id}?amount=" + "{amount}");
|
assertThat(data.template().url()).isEqualTo("/test/{id}?amount=" + "{amount}");
|
||||||
assertThat(data.template().method()).isEqualTo("PUT");
|
assertThat(data.template().method()).isEqualTo("PUT");
|
||||||
assertThat(data.template().headers().get("Accept").iterator().next())
|
assertThat(data.template().headers().get("Accept").iterator().next())
|
||||||
.isEqualTo(MediaType.APPLICATION_JSON_VALUE);
|
.isEqualTo(MediaType.APPLICATION_JSON_VALUE);
|
||||||
@@ -297,7 +266,7 @@ public class SpringMvcContractTests {
|
|||||||
Integer.class);
|
Integer.class);
|
||||||
MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method);
|
MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method);
|
||||||
|
|
||||||
assertThat(data.template().url()).isEqualTo("/advanced/test/{id}?amount=" + "{amount}");
|
assertThat(data.template().url()).isEqualTo("/test/{id}?amount=" + "{amount}");
|
||||||
assertThat(data.template().method()).isEqualTo("PUT");
|
assertThat(data.template().method()).isEqualTo("PUT");
|
||||||
assertThat(data.template().headers().get("Accept").iterator().next())
|
assertThat(data.template().headers().get("Accept").iterator().next())
|
||||||
.isEqualTo(MediaType.APPLICATION_JSON_VALUE);
|
.isEqualTo(MediaType.APPLICATION_JSON_VALUE);
|
||||||
@@ -316,7 +285,7 @@ public class SpringMvcContractTests {
|
|||||||
Method method = TestTemplate_Advanced.class.getDeclaredMethod("getTest2", String.class, Integer.class);
|
Method method = TestTemplate_Advanced.class.getDeclaredMethod("getTest2", String.class, Integer.class);
|
||||||
MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method);
|
MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method);
|
||||||
|
|
||||||
assertThat(data.template().url()).isEqualTo("/advanced/test2?amount=" + "{amount}");
|
assertThat(data.template().url()).isEqualTo("/test2?amount=" + "{amount}");
|
||||||
assertThat(data.template().method()).isEqualTo("PUT");
|
assertThat(data.template().method()).isEqualTo("PUT");
|
||||||
assertThat(data.template().headers().get("Accept").iterator().next())
|
assertThat(data.template().headers().get("Accept").iterator().next())
|
||||||
.isEqualTo(MediaType.APPLICATION_JSON_VALUE);
|
.isEqualTo(MediaType.APPLICATION_JSON_VALUE);
|
||||||
@@ -368,7 +337,7 @@ public class SpringMvcContractTests {
|
|||||||
Method method = TestTemplate_Advanced.class.getDeclaredMethod("getTest");
|
Method method = TestTemplate_Advanced.class.getDeclaredMethod("getTest");
|
||||||
MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method);
|
MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method);
|
||||||
|
|
||||||
assertThat(data.template().url()).isEqualTo("/advanced");
|
assertThat(data.template().url()).isEqualTo("/");
|
||||||
assertThat(data.template().method()).isEqualTo("GET");
|
assertThat(data.template().method()).isEqualTo("GET");
|
||||||
assertThat(data.template().headers().get("Accept").iterator().next())
|
assertThat(data.template().headers().get("Accept").iterator().next())
|
||||||
.isEqualTo(MediaType.APPLICATION_JSON_VALUE);
|
.isEqualTo(MediaType.APPLICATION_JSON_VALUE);
|
||||||
@@ -460,7 +429,7 @@ public class SpringMvcContractTests {
|
|||||||
|
|
||||||
MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method);
|
MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method);
|
||||||
|
|
||||||
assertThat(data.template().url()).isEqualTo("/advanced/testfallback/{id}?amount=" + "{amount}");
|
assertThat(data.template().url()).isEqualTo("/testfallback/{id}?amount=" + "{amount}");
|
||||||
assertThat(data.template().method()).isEqualTo("PUT");
|
assertThat(data.template().method()).isEqualTo("PUT");
|
||||||
assertThat(data.template().headers().get("Accept").iterator().next())
|
assertThat(data.template().headers().get("Accept").iterator().next())
|
||||||
.isEqualTo(MediaType.APPLICATION_JSON_VALUE);
|
.isEqualTo(MediaType.APPLICATION_JSON_VALUE);
|
||||||
@@ -603,6 +572,13 @@ public class SpringMvcContractTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/prepend/{classId}")
|
@RequestMapping("/prepend/{classId}")
|
||||||
|
public interface TestTemplate_Class_RequestMapping {
|
||||||
|
|
||||||
|
@RequestMapping(value = "/test/{testId}", method = RequestMethod.GET)
|
||||||
|
TestObject getSpecificTest(@PathVariable("classId") String classId, @PathVariable("testId") String testId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public interface TestTemplate_Class_Annotations {
|
public interface TestTemplate_Class_Annotations {
|
||||||
|
|
||||||
@GetMapping("/test/{testId}")
|
@GetMapping("/test/{testId}")
|
||||||
@@ -700,7 +676,6 @@ public class SpringMvcContractTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JsonAutoDetect
|
@JsonAutoDetect
|
||||||
@RequestMapping("/advanced")
|
|
||||||
public interface TestTemplate_Advanced {
|
public interface TestTemplate_Advanced {
|
||||||
|
|
||||||
@CollectionFormat(SSV)
|
@CollectionFormat(SSV)
|
||||||
|
|||||||
@@ -6,11 +6,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>spring-cloud-dependencies-parent</artifactId>
|
<artifactId>spring-cloud-dependencies-parent</artifactId>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<version>3.0.4</version>
|
<version>3.0.6-SNAPSHOT</version>
|
||||||
<relativePath/>
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>spring-cloud-openfeign-dependencies</artifactId>
|
<artifactId>spring-cloud-openfeign-dependencies</artifactId>
|
||||||
<version>3.0.4</version>
|
<version>3.0.7-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>spring-cloud-openfeign-dependencies</name>
|
<name>spring-cloud-openfeign-dependencies</name>
|
||||||
<description>Spring Cloud OpenFeign Dependencies</description>
|
<description>Spring Cloud OpenFeign Dependencies</description>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-openfeign</artifactId>
|
<artifactId>spring-cloud-openfeign</artifactId>
|
||||||
<version>3.0.4</version>
|
<version>3.0.7-SNAPSHOT</version>
|
||||||
<relativePath>..</relativePath>
|
<relativePath>..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
|
|||||||
Reference in New Issue
Block a user