Skip to content

Commit 579325f

Browse files
authored
Move main to 3.1; Upgrade Depenency Versions
Also some test changes due to Spring, Kafka, Mockito changes.
1 parent 30ee20d commit 579325f

File tree

9 files changed

+50
-46
lines changed

9 files changed

+50
-46
lines changed

build.gradle

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
buildscript {
2-
ext.kotlinVersion = '1.7.20'
2+
ext.kotlinVersion = '1.9.10'
33
ext.isCI = System.getenv('GITHUB_ACTION') || System.getenv('bamboo_buildKey')
44
repositories {
55
mavenCentral()
@@ -59,28 +59,28 @@ ext {
5959
files(grgit.status().unstaged.modified).filter{ f -> f.name.endsWith('.java') || f.name.endsWith('.kt') }
6060
}
6161

62-
assertjVersion = '3.23.1'
62+
assertjVersion = '3.24.2'
6363
awaitilityVersion = '4.2.0'
6464
googleJsr305Version = '3.0.2'
6565
hamcrestVersion = '2.2'
66-
hibernateValidationVersion = '8.0.0.Final'
67-
jacksonBomVersion = '2.14.3'
68-
jaywayJsonPathVersion = '2.7.0'
66+
hibernateValidationVersion = '8.0.1.Final'
67+
jacksonBomVersion = '2.15.2'
68+
jaywayJsonPathVersion = '2.8.0'
6969
junit4Version = '4.13.2'
70-
junitJupiterVersion = '5.9.3'
71-
kafkaVersion = '3.3.2'
72-
log4jVersion = '2.19.0'
70+
junitJupiterVersion = '5.10.0'
71+
kafkaVersion = '3.5.1'
72+
log4jVersion = '2.20.0'
7373
micrometerDocsVersion = "1.0.2"
74-
micrometerVersion = '1.10.10'
75-
micrometerTracingVersion = '1.0.9'
76-
mockitoVersion = '4.8.1'
77-
reactorVersion = '2022.0.10'
74+
micrometerVersion = '1.12.0-SNAPSHOT'
75+
micrometerTracingVersion = '1.2.0-SNAPSHOT'
76+
mockitoVersion = '5.5.0'
77+
reactorVersion = '2023.0.0-SNAPSHOT'
7878
scalaVersion = '2.13'
7979
springBootVersion = '3.0.9' // docs module
80-
springDataVersion = '2022.0.9'
80+
springDataVersion = '2023.1.0-SNAPSHOT'
8181
springRetryVersion = '2.0.2'
82-
springVersion = '6.0.11'
83-
zookeeperVersion = '3.6.3'
82+
springVersion = '6.1.0-SNAPSHOT'
83+
zookeeperVersion = '3.6.4'
8484

8585
idPrefix = 'kafka'
8686

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version=3.0.12-SNAPSHOT
1+
version=3.1.0-SNAPSHOT
22
org.gradle.jvmargs=-Xmx1536M -Dfile.encoding=UTF-8
33
org.gradle.caching=true
44
org.gradle.parallel=true

spring-kafka/src/test/java/org/springframework/kafka/annotation/EnableKafkaIntegrationTests.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,9 @@ public void manyTests() throws Exception {
330330
.getPropertyValue(this.registry.getListenerContainer("qux"), "containers", List.class).get(0),
331331
"listenerConsumer.consumer"));
332332
assertThat(
333-
KafkaTestUtils.getPropertyValue(this.listener.listen4Consumer, "fetcher.maxPollRecords", Integer.class))
334-
.isEqualTo(100);
333+
KafkaTestUtils.getPropertyValue(this.listener.listen4Consumer,
334+
"fetcher.fetchConfig.maxPollRecords", Integer.class))
335+
.isEqualTo(100);
335336
assertThat(this.quxGroup).hasSize(1);
336337
assertThat(this.quxGroup.get(0)).isSameAs(manualContainer);
337338
List<?> containers = KafkaTestUtils.getPropertyValue(manualContainer, "containers", List.class);
@@ -365,9 +366,11 @@ public void manyTests() throws Exception {
365366
.isEqualTo("fiz");
366367
assertThat(KafkaTestUtils.getPropertyValue(fizContainer, "listenerConsumer.consumer.clientId"))
367368
.isEqualTo("clientIdViaAnnotation-0");
368-
assertThat(KafkaTestUtils.getPropertyValue(fizContainer, "listenerConsumer.consumer.fetcher.maxPollRecords"))
369+
assertThat(KafkaTestUtils.getPropertyValue(fizContainer,
370+
"listenerConsumer.consumer.fetcher.fetchConfig.maxPollRecords"))
369371
.isEqualTo(10);
370-
assertThat(KafkaTestUtils.getPropertyValue(fizContainer, "listenerConsumer.consumer.fetcher.minBytes"))
372+
assertThat(KafkaTestUtils.getPropertyValue(fizContainer,
373+
"listenerConsumer.consumer.fetcher.fetchConfig.minBytes"))
371374
.isEqualTo(420000);
372375

373376
MessageListenerContainer rebalanceConcurrentContainer = registry.getListenerContainer("rebalanceListener");
@@ -523,9 +526,11 @@ public void testJson() throws Exception {
523526
assertThat(KafkaTestUtils.getPropertyValue(buzContainer,
524527
"listenerConsumer.consumer.groupId", Optional.class).get())
525528
.isEqualTo("buz.explicitGroupId");
526-
assertThat(KafkaTestUtils.getPropertyValue(buzContainer, "listenerConsumer.consumer.fetcher.maxPollRecords"))
529+
assertThat(KafkaTestUtils.getPropertyValue(buzContainer,
530+
"listenerConsumer.consumer.fetcher.fetchConfig.maxPollRecords"))
527531
.isEqualTo(5);
528-
assertThat(KafkaTestUtils.getPropertyValue(buzContainer, "listenerConsumer.consumer.fetcher.minBytes"))
532+
assertThat(KafkaTestUtils.getPropertyValue(buzContainer,
533+
"listenerConsumer.consumer.fetcher.fetchConfig.minBytes"))
529534
.isEqualTo(123456);
530535
}
531536

spring-kafka/src/test/java/org/springframework/kafka/core/KafkaTemplateTransactionTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import org.junit.jupiter.api.Test;
6363
import org.mockito.InOrder;
6464

65+
import org.springframework.beans.factory.annotation.Qualifier;
6566
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
6667
import org.springframework.context.annotation.Bean;
6768
import org.springframework.context.annotation.Configuration;
@@ -675,7 +676,7 @@ public Producer producer2() {
675676

676677
@SuppressWarnings("rawtypes")
677678
@Bean
678-
public ProducerFactory pf(Producer producer1, Producer producer2) {
679+
public ProducerFactory pf(@Qualifier("producer1") Producer producer1, @Qualifier("producer2") Producer producer2) {
679680
return new MockProducerFactory((tx, id) -> id.equals("default") ? producer1 : producer2, "default");
680681
}
681682

spring-kafka/src/test/java/org/springframework/kafka/listener/KafkaMessageListenerContainerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2963,7 +2963,7 @@ public void onPartitionsAssigned(Map<TopicPartition, Long> assignments, Consumer
29632963
new KafkaMessageListenerContainer<>(cf, containerProps);
29642964
container.start();
29652965
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
2966-
ArgumentCaptor<Collection<TopicPartition>> captor = ArgumentCaptor.forClass(List.class);
2966+
ArgumentCaptor<Collection<TopicPartition>> captor = ArgumentCaptor.forClass(Collection.class);
29672967
verify(consumer).seekToBeginning(captor.capture());
29682968
assertThat(captor.getValue())
29692969
.isEqualTo(new HashSet<>(Arrays.asList(new TopicPartition("foo", 0), new TopicPartition("foo", 4))));

spring-kafka/src/test/java/org/springframework/kafka/listener/ListenerErrorHandlerTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022 the original author or authors.
2+
* Copyright 2022-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -64,7 +64,7 @@ void record() throws Exception {
6464
return null;
6565
});
6666
HandlerAdapter handler = mock(HandlerAdapter.class);
67-
willThrow(new RuntimeException("test")).given(handler).invoke(any(), any());
67+
willThrow(new RuntimeException("test")).given(handler).invoke(any(), any(), any(), any());
6868
adapter.setHandlerMethod(handler);
6969
Acknowledgment ack = mock(Acknowledgment.class);
7070
adapter.onMessage(mock(ConsumerRecord.class), ack, mock(Consumer.class));
@@ -80,7 +80,7 @@ void batch() throws Exception {
8080
return null;
8181
});
8282
HandlerAdapter handler = mock(HandlerAdapter.class);
83-
willThrow(new RuntimeException("test")).given(handler).invoke(any(), any());
83+
willThrow(new RuntimeException("test")).given(handler).invoke(any(), any(), any());
8484
adapter.setHandlerMethod(handler);
8585
Acknowledgment ack = mock(Acknowledgment.class);
8686
adapter.onMessage(Collections.emptyList(), ack, mock(Consumer.class));

spring-kafka/src/test/java/org/springframework/kafka/retrytopic/RetryTopicConfigurationSupportTests.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021-2022 the original author or authors.
2+
* Copyright 2021-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -67,7 +67,7 @@ void testCreateConfigurer() {
6767
KafkaConsumerBackoffManager backoffManager = mock(KafkaConsumerBackoffManager.class);
6868
DestinationTopicResolver resolver = mock(DestinationTopicResolver.class);
6969
DestinationTopicProcessor processor = mock(DestinationTopicProcessor.class);
70-
ListenerContainerFactoryConfigurer lcfc = mock(ListenerContainerFactoryConfigurer.class);
70+
ListenerContainerFactoryConfigurer lcfc = new ListenerContainerFactoryConfigurer(null, null, null);
7171
ListenerContainerFactoryResolver lcfr = mock(ListenerContainerFactoryResolver.class);
7272
RetryTopicNamesProviderFactory namesProviderFactory = mock(RetryTopicNamesProviderFactory.class);
7373
BeanFactory beanFactory = mock(BeanFactory.class);
@@ -146,11 +146,14 @@ protected void configureBlockingRetries(BlockingRetriesConfigurer blockingRetrie
146146
then(componentFactory).should().retryTopicConfigurer(processor, lcfc, lcfr, namesProviderFactory);
147147

148148
then(dlprf).should().setDeadLetterPublishingRecovererCustomizer(dlprCustomizer);
149-
then(lcfc).should().setContainerCustomizer(listenerContainerCustomizer);
150-
then(lcfc).should().setErrorHandlerCustomizer(errorHandlerCustomizer);
149+
assertThat(KafkaTestUtils.getPropertyValue(lcfc, "containerCustomizer"))
150+
.isSameAs(listenerContainerCustomizer);
151+
assertThat(KafkaTestUtils.getPropertyValue(lcfc, "errorHandlerCustomizer"))
152+
.isSameAs(errorHandlerCustomizer);
151153
assertThatThrownBy(lcfc::setBlockingRetryableExceptions).isInstanceOf(IllegalStateException.class);
152-
then(lcfc).should().setBlockingRetriesBackOff(backoff);
153-
then(lcfc).should().setRetainStandardFatal(true);
154+
assertThat(KafkaTestUtils.getPropertyValue(lcfc, "providedBlockingBackOff"))
155+
.isSameAs(backoff);
156+
assertThat(KafkaTestUtils.getPropertyValue(lcfc, "retainStandardFatal", Boolean.class)).isTrue();
154157
then(dlprfCustomizer).should().accept(dlprf);
155158
then(rtconfigurer).should().accept(topicConfigurer);
156159
then(lcfcConsumer).should().accept(lcfc);

spring-kafka/src/test/java/org/springframework/kafka/retrytopic/RetryTopicConfigurerTests.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import static org.mockito.BDDMockito.given;
2424
import static org.mockito.BDDMockito.then;
2525
import static org.mockito.BDDMockito.willReturn;
26-
import static org.mockito.BDDMockito.willThrow;
2726
import static org.mockito.Mockito.mock;
2827
import static org.mockito.Mockito.times;
2928

@@ -44,9 +43,7 @@
4443
import org.mockito.junit.jupiter.MockitoExtension;
4544

4645
import org.springframework.beans.factory.BeanFactory;
47-
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
4846
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
49-
import org.springframework.beans.factory.support.RootBeanDefinition;
5047
import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
5148
import org.springframework.kafka.config.KafkaListenerContainerFactory;
5249
import org.springframework.kafka.config.KafkaListenerEndpointRegistrar;
@@ -76,8 +73,7 @@ class RetryTopicConfigurerTests {
7673
@Mock
7774
private BeanFactory beanFactory;
7875

79-
@Mock
80-
private DefaultListableBeanFactory defaultListableBeanFactory;
76+
private DefaultListableBeanFactory defaultListableBeanFactory = new DefaultListableBeanFactory();
8177

8278
@Mock
8379
private RetryTopicConfigurer.EndpointProcessor endpointProcessor;
@@ -285,8 +281,7 @@ void shouldConfigureRetryEndpoints() {
285281
Consumer<Collection<String>> topicsConsumer = topicsConsumerCaptor.getValue();
286282
topicsConsumer.accept(topics);
287283

288-
then(defaultListableBeanFactory).should(times(2))
289-
.registerSingleton(any(String.class), any(NewTopic.class));
284+
assertThat(this.defaultListableBeanFactory.getBeansOfType(NewTopic.class)).hasSize(2);
290285
}
291286

292287
private void assertTopicNames(String retrySuffix, DestinationTopic.Properties destinationProperties, DestinationTopicProcessor.Context context, int index) {
@@ -346,19 +341,15 @@ void shouldInstantiateIfNotInContainer() {
346341

347342
// setup
348343
String beanName = NoOpsClass.class.getSimpleName() + "-handlerMethod";
349-
given(defaultListableBeanFactory.getBean(beanName)).willReturn(new NoOpsClass());
350-
willThrow(NoSuchBeanDefinitionException.class).given(defaultListableBeanFactory).getBean(NoOpsClass.class);
351344
EndpointHandlerMethod handlerMethod =
352345
RetryTopicConfigurer.createHandlerMethodWith(NoOpsClass.class, noOpsMethodName);
353346

354347
// given
355348
Object resolvedBean = handlerMethod.resolveBean(this.defaultListableBeanFactory);
356349

357350
// then
358-
then(defaultListableBeanFactory).should()
359-
.registerBeanDefinition(eq(beanName), any(RootBeanDefinition.class));
351+
assertThat(this.defaultListableBeanFactory.getBean(NoOpsClass.class)).isNotNull();
360352
assertThat(NoOpsClass.class.isAssignableFrom(resolvedBean.getClass())).isTrue();
361-
362353
}
363354

364355
@LogLevels(classes = RetryTopicConfigurer.class, level = "info")

spring-kafka/src/test/java/org/springframework/kafka/support/micrometer/ObservationTests.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@
3737
import org.junit.jupiter.api.Test;
3838

3939
import org.springframework.beans.factory.annotation.Autowired;
40+
import org.springframework.beans.factory.annotation.Qualifier;
4041
import org.springframework.context.annotation.Bean;
4142
import org.springframework.context.annotation.Configuration;
43+
import org.springframework.context.annotation.Primary;
4244
import org.springframework.kafka.annotation.EnableKafka;
4345
import org.springframework.kafka.annotation.KafkaListener;
4446
import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
@@ -92,7 +94,8 @@ void endToEnd(@Autowired Listener listener, @Autowired KafkaTemplate<Integer, St
9294
@Autowired SimpleTracer tracer, @Autowired KafkaListenerEndpointRegistry rler,
9395
@Autowired MeterRegistry meterRegistry, @Autowired EmbeddedKafkaBroker broker,
9496
@Autowired KafkaListenerEndpointRegistry endpointRegistry, @Autowired KafkaAdmin admin,
95-
@Autowired KafkaTemplate<Integer, String> customTemplate, @Autowired Config config)
97+
@Autowired @Qualifier("customTemplate") KafkaTemplate<Integer, String> customTemplate,
98+
@Autowired Config config)
9699
throws InterruptedException, ExecutionException, TimeoutException {
97100

98101
template.send("observation.testT1", "test").get(10, TimeUnit.SECONDS);
@@ -246,6 +249,7 @@ ConsumerFactory<Integer, String> consumerFactory(EmbeddedKafkaBroker broker) {
246249
}
247250

248251
@Bean
252+
@Primary
249253
KafkaTemplate<Integer, String> template(ProducerFactory<Integer, String> pf) {
250254
KafkaTemplate<Integer, String> template = new KafkaTemplate<>(pf);
251255
template.setObservationEnabled(true);

0 commit comments

Comments
 (0)