@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright 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.data.aot;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.assertj.core.api.AbstractAssert;
|
||||
import org.springframework.aot.hint.ClassProxyHint;
|
||||
import org.springframework.aot.hint.TypeReference;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
* @since 2022/04
|
||||
*/
|
||||
public class ClassProxyAssert extends AbstractAssert<ClassProxyAssert, ClassProxyHint> {
|
||||
|
||||
protected ClassProxyAssert(ClassProxyHint classProxyHint) {
|
||||
super(classProxyHint, ClassProxyAssert.class);
|
||||
}
|
||||
|
||||
public void matches(Class<?>... proxyInterfaces) {
|
||||
assertThat(actual.getProxiedInterfaces().stream().map(TypeReference::getCanonicalName))
|
||||
.containsExactly(Arrays.stream(proxyInterfaces).map(Class::getCanonicalName).toArray(String[]::new));
|
||||
}
|
||||
|
||||
public List<TypeReference> getProxiedInterfaces() {
|
||||
return actual.getProxiedInterfaces();
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,6 @@ import java.util.stream.Stream;
|
||||
import org.assertj.core.api.AbstractAssert;
|
||||
|
||||
import org.springframework.aot.generate.GenerationContext;
|
||||
import org.springframework.aot.hint.ClassProxyHint;
|
||||
import org.springframework.aot.hint.JdkProxyHint;
|
||||
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||
|
||||
@@ -102,18 +101,4 @@ public class CodeContributionAssert extends AbstractAssert<CodeContributionAsser
|
||||
.getProxiedInterfaces().get(0).getCanonicalName().equals(entryPoint.getCanonicalName()));
|
||||
}
|
||||
|
||||
public CodeContributionAssert contributesClassProxy(Class<?>... proxyInterfaces) {
|
||||
|
||||
assertThat(classProxiesFor(proxyInterfaces[0]))
|
||||
.describedAs("Unable to find JDK proxy matching [%s]", Arrays.asList(proxyInterfaces))
|
||||
.anySatisfy(it -> new ClassProxyAssert(it).matches(proxyInterfaces));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private Stream<ClassProxyHint> classProxiesFor(Class<?> entryPoint) {
|
||||
|
||||
return this.actual.getRuntimeHints().proxies().classProxies().filter(jdkProxyHint -> jdkProxyHint
|
||||
.getProxiedInterfaces().get(0).getCanonicalName().equals(entryPoint.getCanonicalName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@ import java.util.function.Consumer;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.aot.generate.ClassNameGenerator;
|
||||
import org.springframework.aot.generate.DefaultGenerationContext;
|
||||
import org.springframework.aot.generate.GeneratedClasses;
|
||||
import org.springframework.aot.generate.InMemoryGeneratedFiles;
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||
@@ -86,8 +86,7 @@ class ManagedTypesBeanRegistrationAotProcessorUnitTests {
|
||||
BeanRegistrationAotContribution contribution = createPostProcessor("commons")
|
||||
.processAheadOfTime(RegisteredBean.of(beanFactory, "commons.managed-types"));
|
||||
|
||||
DefaultGenerationContext generationContext = new DefaultGenerationContext(
|
||||
new GeneratedClasses(new ClassNameGenerator(Object.class)),
|
||||
DefaultGenerationContext generationContext = new DefaultGenerationContext(new ClassNameGenerator(Object.class),
|
||||
new InMemoryGeneratedFiles(), new RuntimeHints());
|
||||
|
||||
contribution.applyTo(generationContext, null);
|
||||
@@ -151,8 +150,8 @@ class ManagedTypesBeanRegistrationAotProcessorUnitTests {
|
||||
BeanRegistrationAotContribution contribution = createPostProcessor("commons")
|
||||
.processAheadOfTime(RegisteredBean.of(beanFactory, "commons.managed-types"));
|
||||
|
||||
DefaultGenerationContext generationContext = new DefaultGenerationContext(
|
||||
new GeneratedClasses(new ClassNameGenerator(Object.class)), new InMemoryGeneratedFiles(), new RuntimeHints());
|
||||
DefaultGenerationContext generationContext = new DefaultGenerationContext(new ClassNameGenerator(Object.class),
|
||||
new InMemoryGeneratedFiles(), new RuntimeHints());
|
||||
|
||||
contribution.applyTo(generationContext, null);
|
||||
|
||||
|
||||
@@ -24,8 +24,9 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.aop.SpringProxy;
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.beans.factory.aot.BeanRegistrationAotContribution;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.RegisteredBean;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.core.DecoratingProxy;
|
||||
@@ -299,7 +300,7 @@ public class RepositoryRegistrationAotProcessorIntegrationTests {
|
||||
AnnotationConfigApplicationContext applicationContext) {
|
||||
|
||||
applicationContext.register(configuration);
|
||||
applicationContext.refreshForAotProcessing();
|
||||
applicationContext.refreshForAotProcessing(new RuntimeHints());
|
||||
|
||||
return repositoryType -> {
|
||||
|
||||
@@ -311,7 +312,7 @@ public class RepositoryRegistrationAotProcessorIntegrationTests {
|
||||
|
||||
String repositoryBeanName = repositoryBeanNames[0];
|
||||
|
||||
ConfigurableBeanFactory beanFactory = applicationContext.getDefaultListableBeanFactory();
|
||||
ConfigurableListableBeanFactory beanFactory = applicationContext.getDefaultListableBeanFactory();
|
||||
|
||||
RepositoryRegistrationAotProcessor repositoryAotProcessor = applicationContext
|
||||
.getBean(RepositoryRegistrationAotProcessor.class);
|
||||
|
||||
Reference in New Issue
Block a user