DATACMNS-1341 - ProxyUtils now detects JDK proxy target classes.

This commit is contained in:
Oliver Gierke
2018-06-14 11:50:58 +02:00
parent f03ee7fd34
commit 37ab0a5d8f
2 changed files with 17 additions and 1 deletions

View File

@@ -17,6 +17,8 @@ package org.springframework.data.util;
import static org.assertj.core.api.Assertions.*;
import java.io.Serializable;
import org.junit.Test;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.data.util.ProxyUtils.ProxyDetector;
@@ -50,6 +52,17 @@ public class ProxyUtilsUnitTests {
assertThat(ProxyUtils.getUserClass(proxy)).isEqualTo(UserType.class);
}
@Test // DATACMNS-1341
public void detectsTargetTypeOfJdkProxy() {
ProxyFactory factory = new ProxyFactory();
factory.setTarget(new SomeTypeWithInterface());
factory.setInterfaces(Serializable.class);
Object proxy = factory.getProxy();
assertThat(ProxyUtils.getUserClass(proxy)).isEqualTo(SomeTypeWithInterface.class);
}
static class SampleProxyDetector implements ProxyDetector {
/*
@@ -67,4 +80,6 @@ public class ProxyUtilsUnitTests {
static class UserType {}
static class AnotherSample {}
static class SomeTypeWithInterface implements Serializable {}
}