Compare commits

...
Author SHA1 Message Date
buildmaster e8eb5c3d08 Bumping versions 2022-07-27 10:47:29 +00:00
buildmaster f3bf53acd6 Bumping versions to 3.0.9-SNAPSHOT after release 2022-07-27 10:27:42 +00:00
buildmaster a1115f6044 Going back to snapshots 2022-07-27 10:27:42 +00:00
buildmaster d111204007 Update SNAPSHOT to 3.0.8 2022-07-27 10:26:03 +00:00
fml2 b4c9567de5 Update spring-cloud-openfeign.adoc 2022-07-25 16:00:28 +02:00
Nikita Konev 8fdb488697 fix cascading deserialization Spring Data's Page by setting @JsonIgnoreProperties(ignoreUnknown = true), revert ignoring getTotalPages(), getNumberOfElements(), isFirst(), isLast() (#653) 2022-07-25 15:12:22 +02:00
buildmaster 7e01355317 Bumping versions to 3.0.8-SNAPSHOT after release 2022-06-29 22:15:46 +00:00
buildmaster fc459044b5 Going back to snapshots 2022-06-29 22:15:46 +00:00
buildmaster e321e72e3d Update SNAPSHOT to 3.0.7 2022-06-29 22:14:15 +00:00
Olga Maciaszek-Sharma ae63aae6eb Add deprecations for OAuth2. 2022-06-29 17:40:23 +02:00
Olga Maciaszek-Sharma 10fefea29b Remove incompatible test. 2022-06-28 15:46:11 +02:00
Olga MaciaszekSharma 24d9b08d5c Backport bugfix and resolve conflicts. 2022-06-28 15:36:06 +02:00
Olga Maciaszek-Sharma d4832788f6 Resolve conflicts for backport. 2022-06-28 15:02:16 +02:00
Olga Maciaszek-Sharma ff96850ec0 Wrap underlying checked exception with IllegalStateException. Add tests. 2022-06-28 14:53:37 +02:00
Olga Maciaszek-Sharma 9023cc2dc5 Unwarap InvocationTargetException and NoFallbackAvailableException. 2022-06-28 14:53:27 +02:00
Olga Maciaszek-Sharma 6c3b8c257e Fixes gh-680. 2022-06-28 14:44:00 +02:00
buildmaster fe43b6c52b Bumping versions 2022-02-24 10:52:51 +00:00
16 changed files with 257 additions and 21 deletions
+53 -1
View File
@@ -40,7 +40,8 @@ and binding to the Spring Environment and other Spring programming model idioms.
== Building == Building
:jdkversion: 1.8
:jdkversion: 17
=== Basic Compile and Test === Basic Compile and Test
@@ -303,6 +304,57 @@ Go to `File` -> `Settings` -> `Other settings` -> `Checkstyle`. There click on t
IMPORTANT: Remember to set the `Scan Scope` to `All sources` since we apply checkstyle rules for production and test sources. IMPORTANT: Remember to set the `Scan Scope` to `All sources` since we apply checkstyle rules for production and test sources.
=== Duplicate Finder
Spring Cloud Build brings along the `basepom:duplicate-finder-maven-plugin`, that enables flagging duplicate and conflicting classes and resources on the java classpath.
==== Duplicate Finder configuration
Duplicate finder is *enabled by default* and will run in the `verify` phase of your Maven build, but it will only take effect in your project if you add the `duplicate-finder-maven-plugin` to the `build` section of the projecst's `pom.xml`.
.pom.xml
[source,xml]
----
<build>
<plugins>
<plugin>
<groupId>org.basepom.maven</groupId>
<artifactId>duplicate-finder-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
----
For other properties, we have set defaults as listed in the https://github.com/basepom/duplicate-finder-maven-plugin/wiki[plugin documentation].
You can easily override them but setting the value of the selected property prefixed with `duplicate-finder-maven-plugin`. For example, set `duplicate-finder-maven-plugin.skip` to `true` in order to skip duplicates check in your build.
If you need to add `ignoredClassPatterns` or `ignoredResourcePatterns` to your setup, make sure to add them in the plugin configuration section of your project:
[source,xml]
----
<build>
<plugins>
<plugin>
<groupId>org.basepom.maven</groupId>
<artifactId>duplicate-finder-maven-plugin</artifactId>
<configuration>
<ignoredClassPatterns>
<ignoredClassPattern>org.joda.time.base.BaseDateTime</ignoredClassPattern>
<ignoredClassPattern>.*module-info</ignoredClassPattern>
</ignoredClassPatterns>
<ignoredResourcePatterns>
<ignoredResourcePattern>changelog.txt</ignoredResourcePattern>
</ignoredResourcePatterns>
</configuration>
</plugin>
</plugins>
</build>
----
== License == License
The project license file is available https://raw.githubusercontent.com/spring-cloud/spring-cloud-openfeign/main/LICENSE.txt[here]. The project license file is available https://raw.githubusercontent.com/spring-cloud/spring-cloud-openfeign/main/LICENSE.txt[here].
+1 -1
View File
@@ -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.7-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
</parent> </parent>
<artifactId>spring-cloud-openfeign-docs</artifactId> <artifactId>spring-cloud-openfeign-docs</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
@@ -197,7 +197,7 @@ feign:
Default configurations can be specified in the `@EnableFeignClients` attribute `defaultConfiguration` in a similar manner as described above. The difference is that this configuration will apply to _all_ feign clients. Default configurations can be specified in the `@EnableFeignClients` attribute `defaultConfiguration` in a similar manner as described above. The difference is that this configuration will apply to _all_ feign clients.
If you prefer using configuration properties to configured all `@FeignClient`, you can create configuration properties with `default` feign name. If you prefer using configuration properties to configure all `@FeignClient`, you can create configuration properties with `default` feign name.
You can use `feign.client.config.feignName.defaultQueryParameters` and `feign.client.config.feignName.defaultRequestHeaders` to specify query parameters and headers that will be sent with every request of the client named `feignName`. You can use `feign.client.config.feignName.defaultQueryParameters` and `feign.client.config.feignName.defaultRequestHeaders` to specify query parameters and headers that will be sent with every request of the client named `feignName`.
+2 -2
View File
@@ -4,7 +4,7 @@
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.7-SNAPSHOT</version> <version>3.0.8-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>
@@ -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.6-SNAPSHOT</spring-cloud-commons.version> <spring-cloud-commons.version>3.0.7-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>
+1 -1
View File
@@ -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.7-SNAPSHOT</version> <version>3.0.8-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>
@@ -312,6 +312,7 @@ public class FeignAutoConfiguration {
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnClass(OAuth2ClientContext.class) @ConditionalOnClass(OAuth2ClientContext.class)
@ConditionalOnProperty("feign.oauth2.enabled") @ConditionalOnProperty("feign.oauth2.enabled")
@Deprecated // spring-security-oauth2 reached EOL
protected static class Oauth2FeignConfiguration { protected static class Oauth2FeignConfiguration {
@Bean @Bean
@@ -17,6 +17,7 @@
package org.springframework.cloud.openfeign; package org.springframework.cloud.openfeign;
import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Proxy; import java.lang.reflect.Proxy;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@@ -29,6 +30,7 @@ import feign.Target;
import org.springframework.cloud.client.circuitbreaker.CircuitBreaker; import org.springframework.cloud.client.circuitbreaker.CircuitBreaker;
import org.springframework.cloud.client.circuitbreaker.CircuitBreakerFactory; import org.springframework.cloud.client.circuitbreaker.CircuitBreakerFactory;
import org.springframework.cloud.client.circuitbreaker.NoFallbackAvailableException;
import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
@@ -95,15 +97,29 @@ class FeignCircuitBreakerInvocationHandler implements InvocationHandler {
try { try {
return this.fallbackMethodMap.get(method).invoke(fallback, args); return this.fallbackMethodMap.get(method).invoke(fallback, args);
} }
catch (Exception e) { catch (Exception exception) {
throw new IllegalStateException(e); unwrapAndRethrow(exception);
} }
return null;
}; };
return circuitBreaker.run(supplier, fallbackFunction); return circuitBreaker.run(supplier, fallbackFunction);
} }
return circuitBreaker.run(supplier); return circuitBreaker.run(supplier);
} }
private void unwrapAndRethrow(Exception exception) {
if (exception instanceof InvocationTargetException || exception instanceof NoFallbackAvailableException) {
Throwable underlyingException = exception.getCause();
if (underlyingException instanceof RuntimeException) {
throw (RuntimeException) underlyingException;
}
if (underlyingException != null) {
throw new IllegalStateException(underlyingException);
}
throw new IllegalStateException(exception);
}
}
private Supplier<Object> asSupplier(final Method method, final Object[] args) { private Supplier<Object> asSupplier(final Method method, final Object[] args) {
final RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); final RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
return () -> { return () -> {
@@ -443,6 +443,9 @@ public class FeignClientFactoryBean
} }
private String cleanPath() { private String cleanPath() {
if (path == null) {
return "";
}
String path = this.path.trim(); String path = this.path.trim();
if (StringUtils.hasLength(path)) { if (StringUtils.hasLength(path)) {
if (!path.startsWith("/")) { if (!path.startsWith("/")) {
@@ -302,7 +302,11 @@ class FeignClientsRegistrar implements ImportBeanDefinitionRegistrar, ResourceLo
if (resolver == null) { if (resolver == null) {
return resolved; return resolved;
} }
return String.valueOf(resolver.evaluate(resolved, new BeanExpressionContext(beanFactory, null))); Object evaluateValue = resolver.evaluate(resolved, new BeanExpressionContext(beanFactory, null));
if (evaluateValue != null) {
return String.valueOf(evaluateValue);
}
return null;
} }
return value; return value;
} }
@@ -43,6 +43,7 @@ import org.springframework.security.oauth2.common.OAuth2AccessToken;
* @author Tim Ysewyn * @author Tim Ysewyn
* @since 3.0.0 * @since 3.0.0
*/ */
@Deprecated // spring-security-oauth2 reached EOL
public class OAuth2FeignRequestInterceptor implements RequestInterceptor { public class OAuth2FeignRequestInterceptor implements RequestInterceptor {
/** /**
@@ -22,6 +22,7 @@ import java.util.function.Function;
import com.fasterxml.jackson.annotation.JsonAlias; import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.Version; import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.Module; import com.fasterxml.jackson.databind.Module;
@@ -59,6 +60,7 @@ public class PageJacksonModule extends Module {
} }
@JsonDeserialize(as = SimplePageImpl.class) @JsonDeserialize(as = SimplePageImpl.class)
@JsonIgnoreProperties(ignoreUnknown = true)
private interface PageMixIn { private interface PageMixIn {
} }
@@ -86,7 +88,7 @@ public class PageJacksonModule extends Module {
} }
} }
@JsonIgnore @JsonProperty
@Override @Override
public int getTotalPages() { public int getTotalPages() {
return delegate.getTotalPages(); return delegate.getTotalPages();
@@ -110,7 +112,7 @@ public class PageJacksonModule extends Module {
return delegate.getSize(); return delegate.getSize();
} }
@JsonIgnore @JsonProperty
@Override @Override
public int getNumberOfElements() { public int getNumberOfElements() {
return delegate.getNumberOfElements(); return delegate.getNumberOfElements();
@@ -134,13 +136,13 @@ public class PageJacksonModule extends Module {
return delegate.getSort(); return delegate.getSort();
} }
@JsonIgnore @JsonProperty
@Override @Override
public boolean isFirst() { public boolean isFirst() {
return delegate.isFirst(); return delegate.isFirst();
} }
@JsonIgnore @JsonProperty
@Override @Override
public boolean isLast() { public boolean isLast() {
return delegate.isLast(); return delegate.isLast();
@@ -194,6 +196,21 @@ public class PageJacksonModule extends Module {
return delegate.isEmpty(); return delegate.isEmpty();
} }
@Override
public int hashCode() {
return delegate.hashCode();
}
@Override
public boolean equals(Object obj) {
return delegate.equals(obj);
}
@Override
public String toString() {
return delegate.toString();
}
} }
} }
@@ -29,11 +29,14 @@ import org.springframework.web.bind.annotation.GetMapping;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
/** /**
* @author Spencer Gibb * @author Spencer Gibb
* @author Gang Li * @author Gang Li
* @author Michal Domagala * @author Michal Domagala
* @author Szymon Linowski
* @author Olga Maciaszek-Sharma
*/ */
public class FeignClientsRegistrarTests { public class FeignClientsRegistrarTests {
@@ -101,6 +104,15 @@ public class FeignClientsRegistrarTests {
.doesNotThrowAnyException(); .doesNotThrowAnyException();
} }
@Test
public void shouldResolveAndValidateNullName() {
assertThatIllegalStateException().isThrownBy(() -> {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
context.register(NullExpressionNameFeignClientTestConfig.class);
context.refresh();
});
}
@FeignClient(name = "fallbackTestClient", url = "http://localhost:8080/", fallback = FallbackClient.class) @FeignClient(name = "fallbackTestClient", url = "http://localhost:8080/", fallback = FallbackClient.class)
protected interface FallbackClient { protected interface FallbackClient {
@@ -118,6 +130,16 @@ public class FeignClientsRegistrarTests {
} }
@FeignClient(name = "nullUrlFeignClient", url = "${test.url:#{null}}", path = "${test.path:#{null}}")
protected interface NullUrlFeignClient {
}
@FeignClient(name = "${test.name:#{null}}")
protected interface NullExpressionNameFeignClient {
}
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@EnableAutoConfiguration @EnableAutoConfiguration
@EnableFeignClients(clients = { FeignClientsRegistrarTests.FallbackClient.class }) @EnableFeignClients(clients = { FeignClientsRegistrarTests.FallbackClient.class })
@@ -138,4 +160,18 @@ public class FeignClientsRegistrarTests {
} }
@Configuration(proxyBeanMethods = false)
@EnableAutoConfiguration
@EnableFeignClients(clients = NullUrlFeignClient.class)
protected static class NullUrlFeignClientTestConfig {
}
@Configuration(proxyBeanMethods = false)
@EnableAutoConfiguration
@EnableFeignClients(clients = NullExpressionNameFeignClient.class)
protected static class NullExpressionNameFeignClientTestConfig {
}
} }
@@ -16,6 +16,7 @@
package org.springframework.cloud.openfeign.circuitbreaker; package org.springframework.cloud.openfeign.circuitbreaker;
import java.io.IOException;
import java.util.function.Function; import java.util.function.Function;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@@ -49,6 +50,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/** /**
* @author Spencer Gibb * @author Spencer Gibb
@@ -65,6 +67,9 @@ public class CircuitBreakerTests {
@Autowired @Autowired
TestClient testClient; TestClient testClient;
@Autowired
ExceptionClient exceptionClient;
@Autowired @Autowired
TestClientWithFactory testClientWithFactory; TestClientWithFactory testClientWithFactory;
@@ -111,6 +116,17 @@ public class CircuitBreakerTests {
assertThat(testClientWithFactory.getException()).isEqualTo("Fixed response"); assertThat(testClientWithFactory.getException()).isEqualTo("Fixed response");
} }
@Test
public void testRuntimeExceptionUnwrapped() {
assertThatExceptionOfType(UnsupportedOperationException.class)
.isThrownBy(() -> exceptionClient.getRuntimeException());
}
@Test
public void testCheckedExceptionWrapped() {
assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> exceptionClient.getCheckedException());
}
@FeignClient(name = "test", url = "http://localhost:${server.port}/", fallback = Fallback.class) @FeignClient(name = "test", url = "http://localhost:${server.port}/", fallback = Fallback.class)
protected interface TestClient { protected interface TestClient {
@@ -122,6 +138,18 @@ public class CircuitBreakerTests {
} }
@FeignClient(name = "exceptionClient", url = "http://localhost:${server.port}/",
fallbackFactory = ExceptionThrowingFallbackFactory.class)
protected interface ExceptionClient {
@GetMapping("/runtimeException")
Hello getRuntimeException();
@GetMapping("/runtimeException")
Hello getCheckedException() throws IOException;
}
@Component @Component
static class Fallback implements TestClient { static class Fallback implements TestClient {
@@ -159,6 +187,25 @@ public class CircuitBreakerTests {
} }
static class ExceptionThrowingFallbackFactory implements FallbackFactory<ExceptionClient> {
@Override
public ExceptionClient create(Throwable cause) {
return new ExceptionClient() {
@Override
public Hello getRuntimeException() {
throw new UnsupportedOperationException("Not implemented!");
}
@Override
public Hello getCheckedException() throws IOException {
throw new IOException();
}
};
}
}
static class FallbackWithFactory implements TestClientWithFactory { static class FallbackWithFactory implements TestClientWithFactory {
@Override @Override
@@ -176,7 +223,7 @@ public class CircuitBreakerTests {
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@EnableAutoConfiguration @EnableAutoConfiguration
@RestController @RestController
@EnableFeignClients(clients = { TestClient.class, TestClientWithFactory.class }) @EnableFeignClients(clients = { TestClient.class, TestClientWithFactory.class, ExceptionClient.class })
@Import(NoSecurityConfiguration.class) @Import(NoSecurityConfiguration.class)
protected static class Application implements TestClient { protected static class Application implements TestClient {
@@ -228,6 +275,11 @@ public class CircuitBreakerTests {
return new TestFallbackFactory(); return new TestFallbackFactory();
} }
@Bean
ExceptionThrowingFallbackFactory exceptionThrowingFallbackFactory() {
return new ExceptionThrowingFallbackFactory();
}
} }
} }
@@ -82,10 +82,10 @@ public class PageJacksonModuleTests {
@Test @Test
public void serializeAndDeserializeFilledMultiple() throws JsonProcessingException { public void serializeAndDeserializeFilledMultiple() throws JsonProcessingException {
// Given // Given
ArrayList<Object> strings0 = new ArrayList<>(); ArrayList<Object> pageElements = new ArrayList<>();
strings0.add("first element"); pageElements.add("first element");
strings0.add("second element"); pageElements.add("second element");
PageImpl<Object> objects = new PageImpl<>(strings0, PageRequest.of(6, 2), 100); PageImpl<Object> objects = new PageImpl<>(pageElements, PageRequest.of(6, 2), 100);
assertThat(objects.getContent()).hasSize(2); assertThat(objects.getContent()).hasSize(2);
assertThat(objects.getPageable().getPageSize()).isEqualTo(2); assertThat(objects.getPageable().getPageSize()).isEqualTo(2);
@@ -102,4 +102,57 @@ public class PageJacksonModuleTests {
assertThat(result.getPageable().getPageNumber()).isEqualTo(6); assertThat(result.getPageable().getPageNumber()).isEqualTo(6);
} }
@Test
public void serializeAndDeserializeEmptyCascade() 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);
String cascadedPageJson = objectMapper.writeValueAsString(result);
Page<?> cascadedResult = objectMapper.readValue(cascadedPageJson, Page.class);
assertThat(cascadedResult).isNotNull();
assertThat(cascadedResult.getTotalElements()).isEqualTo(0);
assertThat(cascadedResult.getContent()).hasSize(0);
}
@Test
public void serializeAndDeserializeFilledMultipleCascade() throws JsonProcessingException {
// Given
ArrayList<Object> pageElements = new ArrayList<>();
pageElements.add("first element in cascaded serialization");
pageElements.add("second element in cascaded serialization");
PageImpl<Object> objects = new PageImpl<>(pageElements, 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 in cascaded serialization");
assertThat(result.getContent().get(1)).isEqualTo("second element in cascaded serialization");
assertThat(result.getPageable().getPageSize()).isEqualTo(2);
assertThat(result.getPageable().getPageNumber()).isEqualTo(6);
String cascadedPageJson = objectMapper.writeValueAsString(result);
Page<?> cascadedResult = objectMapper.readValue(cascadedPageJson, Page.class);
// Then
assertThat(cascadedResult).isNotNull();
assertThat(cascadedResult.getTotalElements()).isEqualTo(100);
assertThat(cascadedResult.getContent()).hasSize(2);
assertThat(cascadedResult.getContent().get(0)).isEqualTo("first element in cascaded serialization");
assertThat(cascadedResult.getContent().get(1)).isEqualTo("second element in cascaded serialization");
assertThat(cascadedResult.getPageable().getPageSize()).isEqualTo(2);
assertThat(cascadedResult.getPageable().getPageNumber()).isEqualTo(6);
}
} }
+3 -2
View File
@@ -10,14 +10,15 @@
<relativePath/> <relativePath/>
</parent> </parent>
<artifactId>spring-cloud-openfeign-dependencies</artifactId> <artifactId>spring-cloud-openfeign-dependencies</artifactId>
<version>3.0.7-SNAPSHOT</version> <version>3.0.8-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>
<properties> <properties>
<feign.version>10.12</feign.version> <feign.version>10.12</feign.version>
<feign-form.version>3.8.0</feign-form.version> <feign-form.version>3.8.0</feign-form.version>
<spring-security-oauth2-autoconfigure.version>2.1.2.RELEASE</spring-security-oauth2-autoconfigure.version> <!-- Deprecated - reached EOL -->
<spring-security-oauth2-autoconfigure.version>2.5.2</spring-security-oauth2-autoconfigure.version>
</properties> </properties>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
+1 -1
View File
@@ -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.7-SNAPSHOT</version> <version>3.0.8-SNAPSHOT</version>
<relativePath>..</relativePath> <relativePath>..</relativePath>
</parent> </parent>
<artifactId>spring-cloud-starter-openfeign</artifactId> <artifactId>spring-cloud-starter-openfeign</artifactId>