Polishing
This commit is contained in:
@@ -322,8 +322,8 @@ class ConfigurationClassPostProcessorTests {
|
||||
ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor();
|
||||
pp.setEnvironment(new StandardEnvironment());
|
||||
pp.postProcessBeanFactory(beanFactory);
|
||||
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() ->
|
||||
beanFactory.getBean(SimpleComponent.class));
|
||||
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
|
||||
.isThrownBy(() -> beanFactory.getBean(SimpleComponent.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -373,11 +373,11 @@ class ConfigurationClassPostProcessorTests {
|
||||
beanFactory.registerBeanDefinition("config", new RootBeanDefinition(SingletonBeanConfig.class));
|
||||
beanFactory.setAllowBeanDefinitionOverriding(false);
|
||||
ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor();
|
||||
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() ->
|
||||
pp.postProcessBeanFactory(beanFactory))
|
||||
.withMessageContaining("bar")
|
||||
.withMessageContaining("SingletonBeanConfig")
|
||||
.withMessageContaining(TestBean.class.getName());
|
||||
assertThatExceptionOfType(BeanDefinitionStoreException.class)
|
||||
.isThrownBy(() -> pp.postProcessBeanFactory(beanFactory))
|
||||
.withMessageContaining("bar")
|
||||
.withMessageContaining("SingletonBeanConfig")
|
||||
.withMessageContaining(TestBean.class.getName());
|
||||
}
|
||||
|
||||
@Test // gh-25430
|
||||
@@ -430,12 +430,12 @@ class ConfigurationClassPostProcessorTests {
|
||||
ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor();
|
||||
pp.postProcessBeanFactory(beanFactory);
|
||||
|
||||
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
|
||||
beanFactory.getBean(Bar.class))
|
||||
.withMessageContaining("OverridingSingletonBeanConfig.foo")
|
||||
.withMessageContaining(ExtendedFoo.class.getName())
|
||||
.withMessageContaining(Foo.class.getName())
|
||||
.withMessageContaining("InvalidOverridingSingletonBeanConfig");
|
||||
assertThatExceptionOfType(BeanCreationException.class)
|
||||
.isThrownBy(() -> beanFactory.getBean(Bar.class))
|
||||
.withMessageContaining("OverridingSingletonBeanConfig.foo")
|
||||
.withMessageContaining(ExtendedFoo.class.getName())
|
||||
.withMessageContaining(Foo.class.getName())
|
||||
.withMessageContaining("InvalidOverridingSingletonBeanConfig");
|
||||
}
|
||||
|
||||
@Test // SPR-15384
|
||||
@@ -986,16 +986,16 @@ class ConfigurationClassPostProcessorTests {
|
||||
beanFactory.registerBeanDefinition("configClass1", new RootBeanDefinition(A.class));
|
||||
beanFactory.registerBeanDefinition("configClass2", new RootBeanDefinition(AStrich.class));
|
||||
new ConfigurationClassPostProcessor().postProcessBeanFactory(beanFactory);
|
||||
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(
|
||||
beanFactory::preInstantiateSingletons)
|
||||
.withMessageContaining("Circular reference");
|
||||
assertThatExceptionOfType(BeanCreationException.class)
|
||||
.isThrownBy(beanFactory::preInstantiateSingletons)
|
||||
.withMessageContaining("Circular reference");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCircularDependencyWithApplicationContext() {
|
||||
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
|
||||
new AnnotationConfigApplicationContext(A.class, AStrich.class))
|
||||
.withMessageContaining("Circular reference");
|
||||
assertThatExceptionOfType(BeanCreationException.class)
|
||||
.isThrownBy(() -> new AnnotationConfigApplicationContext(A.class, AStrich.class))
|
||||
.withMessageContaining("Circular reference");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1103,7 +1103,7 @@ class ConfigurationClassPostProcessorTests {
|
||||
@Test
|
||||
void testNameClashBetweenConfigurationClassAndBean() {
|
||||
assertThatExceptionOfType(BeanDefinitionStoreException.class)
|
||||
.isThrownBy(() -> new AnnotationConfigApplicationContext(MyTestBean.class).getBean("myTestBean", TestBean.class));
|
||||
.isThrownBy(() -> new AnnotationConfigApplicationContext(MyTestBean.class).getBean("myTestBean", TestBean.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1749,7 +1749,6 @@ class ConfigurationClassPostProcessorTests {
|
||||
}
|
||||
|
||||
public interface DefaultMethodsConfig extends BaseDefaultMethods {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -619,15 +619,15 @@ class ConfigurationClassProcessingTests {
|
||||
void register(GenericApplicationContext ctx) {
|
||||
ctx.registerBean("spouse", TestBean.class,
|
||||
() -> new TestBean("functional"));
|
||||
Supplier<TestBean> testBeanSupplier = () -> new TestBean(ctx.getBean("spouse", TestBean.class));
|
||||
ctx.registerBean(TestBean.class,
|
||||
testBeanSupplier,
|
||||
Supplier<TestBean> testBeanSupplier =
|
||||
() -> new TestBean(ctx.getBean("spouse", TestBean.class));
|
||||
ctx.registerBean(TestBean.class, testBeanSupplier,
|
||||
bd -> bd.setPrimary(true));
|
||||
}
|
||||
|
||||
@Bean
|
||||
public NestedTestBean nestedTestBean(TestBean testBean) {
|
||||
return new NestedTestBean(testBean.getSpouse().getName());
|
||||
public NestedTestBean nestedTestBean(TestBean spouse) {
|
||||
return new NestedTestBean(spouse.getSpouse().getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.validation.beanvalidation;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import jakarta.validation.ConstraintViolation;
|
||||
@@ -95,11 +96,18 @@ class MethodValidationProxyReactorTests {
|
||||
}
|
||||
|
||||
private static MyService initProxy(Object target, boolean adaptViolations) {
|
||||
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
|
||||
MethodValidationInterceptor interceptor = new MethodValidationInterceptor(() -> validator, adaptViolations);
|
||||
ProxyFactory factory = new ProxyFactory(target);
|
||||
factory.addAdvice(interceptor);
|
||||
return (MyService) factory.getProxy();
|
||||
Locale oldDefault = Locale.getDefault();
|
||||
Locale.setDefault(Locale.US);
|
||||
try {
|
||||
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
|
||||
MethodValidationInterceptor interceptor = new MethodValidationInterceptor(() -> validator, adaptViolations);
|
||||
ProxyFactory factory = new ProxyFactory(target);
|
||||
factory.addAdvice(interceptor);
|
||||
return (MyService) factory.getProxy();
|
||||
}
|
||||
finally {
|
||||
Locale.setDefault(oldDefault);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -38,7 +38,7 @@ public abstract class OrderUtils {
|
||||
/** Cache marker for a non-annotated Class. */
|
||||
private static final Object NOT_ANNOTATED = new Object();
|
||||
|
||||
private static final String JAVAX_PRIORITY_ANNOTATION = "jakarta.annotation.Priority";
|
||||
private static final String JAKARTA_PRIORITY_ANNOTATION = "jakarta.annotation.Priority";
|
||||
|
||||
/** Cache for @Order value (or NOT_ANNOTATED marker) per Class. */
|
||||
static final Map<AnnotatedElement, Object> orderCache = new ConcurrentReferenceHashMap<>(64);
|
||||
@@ -124,7 +124,7 @@ public abstract class OrderUtils {
|
||||
if (orderAnnotation.isPresent()) {
|
||||
return orderAnnotation.getInt(MergedAnnotation.VALUE);
|
||||
}
|
||||
MergedAnnotation<?> priorityAnnotation = annotations.get(JAVAX_PRIORITY_ANNOTATION);
|
||||
MergedAnnotation<?> priorityAnnotation = annotations.get(JAKARTA_PRIORITY_ANNOTATION);
|
||||
if (priorityAnnotation.isPresent()) {
|
||||
return priorityAnnotation.getInt(MergedAnnotation.VALUE);
|
||||
}
|
||||
@@ -139,7 +139,7 @@ public abstract class OrderUtils {
|
||||
*/
|
||||
@Nullable
|
||||
public static Integer getPriority(Class<?> type) {
|
||||
return MergedAnnotations.from(type, SearchStrategy.TYPE_HIERARCHY).get(JAVAX_PRIORITY_ANNOTATION)
|
||||
return MergedAnnotations.from(type, SearchStrategy.TYPE_HIERARCHY).get(JAKARTA_PRIORITY_ANNOTATION)
|
||||
.getValue(MergedAnnotation.VALUE, Integer.class).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -589,8 +589,7 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
|
||||
if (this.taskExecutor == null) {
|
||||
this.taskExecutor = createDefaultTaskExecutor();
|
||||
}
|
||||
else if (this.taskExecutor instanceof SchedulingTaskExecutor ste &&
|
||||
ste.prefersShortLivedTasks() &&
|
||||
else if (this.taskExecutor instanceof SchedulingTaskExecutor ste && ste.prefersShortLivedTasks() &&
|
||||
this.maxMessagesPerTask == Integer.MIN_VALUE) {
|
||||
// TaskExecutor indicated a preference for short-lived tasks. According to
|
||||
// setMaxMessagesPerTask javadoc, we'll use 10 message per task in this case
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -105,8 +105,7 @@ class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
|
||||
void containerAreStartedByDefault() {
|
||||
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
EnableJmsDefaultContainerFactoryConfig.class, DefaultBean.class);
|
||||
JmsListenerContainerTestFactory factory =
|
||||
context.getBean(JmsListenerContainerTestFactory.class);
|
||||
JmsListenerContainerTestFactory factory = context.getBean(JmsListenerContainerTestFactory.class);
|
||||
MessageListenerTestContainer container = factory.getListenerContainers().get(0);
|
||||
assertThat(container.isAutoStartup()).isTrue();
|
||||
assertThat(container.isStarted()).isTrue();
|
||||
@@ -116,8 +115,7 @@ class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
|
||||
void containerCanBeStarterViaTheRegistry() {
|
||||
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
EnableJmsAutoStartupFalseConfig.class, DefaultBean.class);
|
||||
JmsListenerContainerTestFactory factory =
|
||||
context.getBean(JmsListenerContainerTestFactory.class);
|
||||
JmsListenerContainerTestFactory factory = context.getBean(JmsListenerContainerTestFactory.class);
|
||||
MessageListenerTestContainer container = factory.getListenerContainers().get(0);
|
||||
assertThat(container.isAutoStartup()).isFalse();
|
||||
assertThat(container.isStarted()).isFalse();
|
||||
@@ -132,9 +130,9 @@ class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
|
||||
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
EnableJmsHandlerMethodFactoryConfig.class, ValidationBean.class);
|
||||
|
||||
assertThatExceptionOfType(ListenerExecutionFailedException.class).isThrownBy(() ->
|
||||
testJmsHandlerMethodFactoryConfiguration(context))
|
||||
.withCauseInstanceOf(MethodArgumentNotValidException.class);
|
||||
assertThatExceptionOfType(ListenerExecutionFailedException.class)
|
||||
.isThrownBy(() -> testJmsHandlerMethodFactoryConfiguration(context))
|
||||
.withCauseInstanceOf(MethodArgumentNotValidException.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -156,19 +154,20 @@ class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
|
||||
@Test
|
||||
void composedJmsListeners() {
|
||||
try (ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
EnableJmsDefaultContainerFactoryConfig.class, ComposedJmsListenersBean.class)) {
|
||||
JmsListenerContainerTestFactory simpleFactory = context.getBean("jmsListenerContainerFactory",
|
||||
JmsListenerContainerTestFactory.class);
|
||||
EnableJmsDefaultContainerFactoryConfig.class, ComposedJmsListenersBean.class)) {
|
||||
|
||||
JmsListenerContainerTestFactory simpleFactory =
|
||||
context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class);
|
||||
assertThat(simpleFactory.getListenerContainers()).hasSize(2);
|
||||
|
||||
MethodJmsListenerEndpoint first = (MethodJmsListenerEndpoint) simpleFactory.getListenerContainer(
|
||||
"first").getEndpoint();
|
||||
MethodJmsListenerEndpoint first = (MethodJmsListenerEndpoint)
|
||||
simpleFactory.getListenerContainer("first").getEndpoint();
|
||||
assertThat(first.getId()).isEqualTo("first");
|
||||
assertThat(first.getDestination()).isEqualTo("orderQueue");
|
||||
assertThat(first.getConcurrency()).isNull();
|
||||
|
||||
MethodJmsListenerEndpoint second = (MethodJmsListenerEndpoint) simpleFactory.getListenerContainer(
|
||||
"second").getEndpoint();
|
||||
MethodJmsListenerEndpoint second = (MethodJmsListenerEndpoint)
|
||||
simpleFactory.getListenerContainer("second").getEndpoint();
|
||||
assertThat(second.getId()).isEqualTo("second");
|
||||
assertThat(second.getDestination()).isEqualTo("billingQueue");
|
||||
assertThat(second.getConcurrency()).isEqualTo("2-10");
|
||||
@@ -178,9 +177,9 @@ class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
|
||||
@Test
|
||||
void unknownFactory() {
|
||||
// not found
|
||||
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
|
||||
new AnnotationConfigApplicationContext(EnableJmsSampleConfig.class, CustomBean.class))
|
||||
.withMessageContaining("customFactory");
|
||||
assertThatExceptionOfType(BeanCreationException.class)
|
||||
.isThrownBy(() -> new AnnotationConfigApplicationContext(EnableJmsSampleConfig.class, CustomBean.class))
|
||||
.withMessageContaining("customFactory");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -28,15 +28,13 @@ public class JmsListenerContainerTestFactory implements JmsListenerContainerFact
|
||||
|
||||
private boolean autoStartup = true;
|
||||
|
||||
private final Map<String, MessageListenerTestContainer> listenerContainers =
|
||||
new LinkedHashMap<>();
|
||||
private final Map<String, MessageListenerTestContainer> listenerContainers = new LinkedHashMap<>();
|
||||
|
||||
|
||||
public void setAutoStartup(boolean autoStartup) {
|
||||
this.autoStartup = autoStartup;
|
||||
}
|
||||
|
||||
|
||||
public List<MessageListenerTestContainer> getListenerContainers() {
|
||||
return new ArrayList<>(this.listenerContainers.values());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -42,6 +42,7 @@ import static org.junit.jupiter.params.provider.Arguments.arguments;
|
||||
|
||||
/**
|
||||
* Observation tests for {@link AbstractMessageListenerContainer} implementations.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
class MessageListenerContainerObservationTests {
|
||||
@@ -75,8 +76,8 @@ class MessageListenerContainerObservationTests {
|
||||
assertThat(registry).hasObservationWithNameEqualTo("jms.message.process")
|
||||
.that()
|
||||
.hasHighCardinalityKeyValue("messaging.destination.name", "spring.test.observation");
|
||||
listenerContainer.shutdown();
|
||||
listenerContainer.stop();
|
||||
listenerContainer.shutdown();
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] {0}")
|
||||
@@ -103,8 +104,8 @@ class MessageListenerContainerObservationTests {
|
||||
assertThat(registry).hasObservationWithNameEqualTo("jms.message.process")
|
||||
.that()
|
||||
.hasHighCardinalityKeyValue("messaging.destination.name", "spring.test.observation");
|
||||
listenerContainer.shutdown();
|
||||
listenerContainer.stop();
|
||||
listenerContainer.shutdown();
|
||||
}
|
||||
|
||||
static Stream<Arguments> listenerContainers() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -70,13 +70,15 @@ public class SingleConnectionFactory extends DelegatingConnectionFactory
|
||||
private boolean suppressClose;
|
||||
|
||||
/** Override auto-commit state?. */
|
||||
private @Nullable Boolean autoCommit;
|
||||
@Nullable
|
||||
private Boolean autoCommit;
|
||||
|
||||
/** Wrapped Connection. */
|
||||
private final AtomicReference<Connection> target = new AtomicReference<>();
|
||||
|
||||
/** Proxy Connection. */
|
||||
private @Nullable Connection connection;
|
||||
@Nullable
|
||||
private Connection connection;
|
||||
|
||||
private final Mono<? extends Connection> connectionEmitter;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user