From d07cc104fcb248ae35e3e1cb6f40ef65e1166c34 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Tue, 23 Aug 2022 10:22:46 +0200 Subject: [PATCH] Adopt to Spring Framework 6.0 M6 changes. Closes #2675 --- .../data/aot/ClassProxyAssert.java | 45 ------------------- .../data/aot/CodeContributionAssert.java | 15 ------- ...BeanRegistrationAotProcessorUnitTests.java | 9 ++-- ...istrationAotProcessorIntegrationTests.java | 7 +-- 4 files changed, 8 insertions(+), 68 deletions(-) delete mode 100644 src/test/java/org/springframework/data/aot/ClassProxyAssert.java diff --git a/src/test/java/org/springframework/data/aot/ClassProxyAssert.java b/src/test/java/org/springframework/data/aot/ClassProxyAssert.java deleted file mode 100644 index 7f124fa48..000000000 --- a/src/test/java/org/springframework/data/aot/ClassProxyAssert.java +++ /dev/null @@ -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 { - - 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 getProxiedInterfaces() { - return actual.getProxiedInterfaces(); - } -} diff --git a/src/test/java/org/springframework/data/aot/CodeContributionAssert.java b/src/test/java/org/springframework/data/aot/CodeContributionAssert.java index 92857c128..9eb53d084 100644 --- a/src/test/java/org/springframework/data/aot/CodeContributionAssert.java +++ b/src/test/java/org/springframework/data/aot/CodeContributionAssert.java @@ -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... 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 classProxiesFor(Class entryPoint) { - - return this.actual.getRuntimeHints().proxies().classProxies().filter(jdkProxyHint -> jdkProxyHint - .getProxiedInterfaces().get(0).getCanonicalName().equals(entryPoint.getCanonicalName())); - } } diff --git a/src/test/java/org/springframework/data/aot/ManagedTypesBeanRegistrationAotProcessorUnitTests.java b/src/test/java/org/springframework/data/aot/ManagedTypesBeanRegistrationAotProcessorUnitTests.java index 24adc95b2..bd61596a7 100644 --- a/src/test/java/org/springframework/data/aot/ManagedTypesBeanRegistrationAotProcessorUnitTests.java +++ b/src/test/java/org/springframework/data/aot/ManagedTypesBeanRegistrationAotProcessorUnitTests.java @@ -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); diff --git a/src/test/java/org/springframework/data/aot/RepositoryRegistrationAotProcessorIntegrationTests.java b/src/test/java/org/springframework/data/aot/RepositoryRegistrationAotProcessorIntegrationTests.java index 93bec97d0..ac74f1baf 100644 --- a/src/test/java/org/springframework/data/aot/RepositoryRegistrationAotProcessorIntegrationTests.java +++ b/src/test/java/org/springframework/data/aot/RepositoryRegistrationAotProcessorIntegrationTests.java @@ -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);