From 0cdf19a4cba7ce8a0b3c37472b81da933f4d3afc Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 7 Oct 2015 14:51:45 +0100 Subject: [PATCH] Update test to align with more precise information about target class The latest Spring Framework 4.2.2 snapshots have reworked EventListenerMethodProcessor so that it no longer queries a proxies target class. Previously, when this was happening, it happened early in the context's lifecycle when the bean's concrete type was unknown. The led to the target class being set as the proxied interface. With the latest 4.2.2 snapshots, the first call to AopUtils.getTargetClass() happens in the test, by which time the actual concrete type of the bean is known. This commit updates the test so that its expectations match the more precise result. --- .../security/oauth2/OAuth2AutoConfigurationTests.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2AutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2AutoConfigurationTests.java index c890f150ed..470870c6b4 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2AutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2AutoConfigurationTests.java @@ -76,6 +76,7 @@ import org.springframework.security.oauth2.provider.approval.ApprovalStoreUserAp import org.springframework.security.oauth2.provider.approval.TokenApprovalStore; import org.springframework.security.oauth2.provider.approval.UserApprovalHandler; import org.springframework.security.oauth2.provider.client.BaseClientDetails; +import org.springframework.security.oauth2.provider.client.InMemoryClientDetailsService; import org.springframework.security.oauth2.provider.endpoint.AuthorizationEndpoint; import org.springframework.security.oauth2.provider.expression.OAuth2MethodSecurityExpressionHandler; import org.springframework.security.oauth2.provider.token.DefaultTokenServices; @@ -92,6 +93,7 @@ import org.springframework.web.client.RestTemplate; import com.fasterxml.jackson.databind.JsonNode; import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; /** @@ -129,8 +131,8 @@ public class OAuth2AutoConfigurationTests { ClientDetails clientDetails = clientDetailsService.loadClientByClientId(config .getClientId()); assertThat(AopUtils.isJdkDynamicProxy(clientDetailsService), equalTo(true)); - assertThat(AopUtils.getTargetClass(clientDetailsService).getName(), - equalTo(ClientDetailsService.class.getName())); + assertThat(AopUtils.getTargetClass(clientDetailsService), + is(equalTo(InMemoryClientDetailsService.class))); assertThat(handler instanceof ApprovalStoreUserApprovalHandler, equalTo(true)); assertThat(clientDetails, equalTo(config)); verifyAuthentication(config);