Remove support for declaring class proxies hints
Closes gh-28972
This commit is contained in:
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.aot.hint;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.Serializable;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Properties;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.aot.hint.JdkProxyHint.Builder;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link ClassProxyHint}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
class ClassProxyHintTests {
|
||||
|
||||
@Test
|
||||
void equalsWithSameInstanceIsTrue() {
|
||||
ClassProxyHint hint = ClassProxyHint.of(Properties.class).build();
|
||||
assertThat(hint).isEqualTo(hint);
|
||||
}
|
||||
|
||||
@Test
|
||||
void equalsWithSameTargetClassIsTrue() {
|
||||
ClassProxyHint first = ClassProxyHint.of(Properties.class).build();
|
||||
ClassProxyHint second = ClassProxyHint.of(TypeReference.of(Properties.class)).build();
|
||||
assertThat(first).isEqualTo(second);
|
||||
}
|
||||
|
||||
@Test
|
||||
void equalsWithSameProxiedInterfacesIsTrue() {
|
||||
ClassProxyHint first = ClassProxyHint.of(Properties.class)
|
||||
.proxiedInterfaces(Serializable.class).build();
|
||||
ClassProxyHint second = ClassProxyHint.of(Properties.class)
|
||||
.proxiedInterfaces(TypeReference.of(Serializable.class)).build();
|
||||
assertThat(first).isEqualTo(second);
|
||||
}
|
||||
|
||||
@Test
|
||||
void equalsWithDifferentTargetClassIsFalse() {
|
||||
ClassProxyHint first = ClassProxyHint.of(Properties.class).build();
|
||||
ClassProxyHint second = ClassProxyHint.of(Hashtable.class).build();
|
||||
assertThat(first).isNotEqualTo(second);
|
||||
}
|
||||
|
||||
@Test
|
||||
void equalsWithSameProxiedInterfacesDifferentOrderIsFalse() {
|
||||
ClassProxyHint first = ClassProxyHint.of(Properties.class)
|
||||
.proxiedInterfaces(Serializable.class, Closeable.class).build();
|
||||
ClassProxyHint second = ClassProxyHint.of(Properties.class)
|
||||
.proxiedInterfaces(TypeReference.of(Closeable.class), TypeReference.of(Serializable.class))
|
||||
.build();
|
||||
assertThat(first).isNotEqualTo(second);
|
||||
}
|
||||
|
||||
@Test
|
||||
void equalsWithDifferentProxiedInterfacesIsFalse() {
|
||||
ClassProxyHint first = ClassProxyHint.of(Properties.class)
|
||||
.proxiedInterfaces(Serializable.class).build();
|
||||
ClassProxyHint second = ClassProxyHint.of(Properties.class)
|
||||
.proxiedInterfaces(TypeReference.of(Closeable.class)).build();
|
||||
assertThat(first).isNotEqualTo(second);
|
||||
}
|
||||
|
||||
@Test
|
||||
void equalsWithNonClassProxyHintIsFalse() {
|
||||
ClassProxyHint first = ClassProxyHint.of(Properties.class).build();
|
||||
JdkProxyHint second = new Builder().proxiedInterfaces(Function.class).build();
|
||||
assertThat(first).isNotEqualTo(second);
|
||||
}
|
||||
|
||||
@Test
|
||||
void equalsWithDifferentConditionIsFalse() {
|
||||
ClassProxyHint first = ClassProxyHint.of(Properties.class).build();
|
||||
ClassProxyHint second = ClassProxyHint.of(Properties.class).onReachableType(TypeReference.of("org.example.test")).build();
|
||||
assertThat(first).isNotEqualTo(second);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,9 +16,7 @@
|
||||
|
||||
package org.springframework.aot.hint;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Properties;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -82,33 +80,6 @@ class ProxyHintsTests {
|
||||
assertThat(this.proxyHints.jdkProxies()).singleElement().satisfies(proxiedInterfaces(Function.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerClassProxyWithTargetClassName() {
|
||||
this.proxyHints.registerClassProxy(TypeReference.of(Properties.class.getName()), classProxyHint ->
|
||||
classProxyHint.proxiedInterfaces(Serializable.class));
|
||||
assertThat(this.proxyHints.classProxies()).singleElement().satisfies(classProxyHint -> {
|
||||
assertThat(classProxyHint.getTargetClass()).isEqualTo(TypeReference.of(Properties.class));
|
||||
assertThat(classProxyHint.getProxiedInterfaces()).containsOnly(TypeReference.of(Serializable.class));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerClassProxyWithTargetClass() {
|
||||
this.proxyHints.registerClassProxy(Properties.class, classProxyHint ->
|
||||
classProxyHint.proxiedInterfaces(Serializable.class));
|
||||
assertThat(this.proxyHints.classProxies()).singleElement().satisfies(classProxyHint -> {
|
||||
assertThat(classProxyHint.getTargetClass()).isEqualTo(TypeReference.of(Properties.class));
|
||||
assertThat(classProxyHint.getProxiedInterfaces()).containsOnly(TypeReference.of(Serializable.class));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerClassProxyWithTargetInterface() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> this.proxyHints.registerClassProxy(Serializable.class, classProxyHint -> {}))
|
||||
.withMessageContaining(Serializable.class.getName());
|
||||
}
|
||||
|
||||
|
||||
private static Consumer<JdkProxyHint.Builder> springProxy(String proxiedInterface) {
|
||||
return builder -> builder.proxiedInterfaces(toTypeReferences(
|
||||
@@ -140,6 +111,7 @@ class ProxyHintsTests {
|
||||
sealed interface SealedInterface {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
static final class SealedClass implements SealedInterface {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user