Skip to content

Commit 7fefaa3

Browse files
omercelikcengolegz
authored andcommitted
Code cleanup
1 parent 1de0e1c commit 7fefaa3

File tree

5 files changed

+30
-20
lines changed

5 files changed

+30
-20
lines changed

binders/rabbit-binder/spring-cloud-stream-binder-rabbit-core/src/main/java/org/springframework/cloud/stream/binder/rabbit/admin/RabbitAdminException.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2019 the original author or authors.
2+
* Copyright 2015-2024 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.
@@ -22,7 +22,6 @@
2222
* @author Gary Russell
2323
* @since 1.2
2424
*/
25-
@SuppressWarnings("serial")
2625
public class RabbitAdminException extends RuntimeException {
2726

2827
public RabbitAdminException(String message, Throwable cause) {

binders/rabbit-binder/spring-cloud-stream-binder-rabbit/src/test/java/org/springframework/cloud/stream/binder/rabbit/RabbitTestContainer.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022-2022 the original author or authors.
2+
* Copyright 2022-2024 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.
@@ -24,8 +24,12 @@
2424
* Provides a static {@link RabbitMQContainer} that can be shared across test classes.
2525
*
2626
* @author Chris Bono
27+
* @author Omer Celik
2728
*/
28-
public class RabbitTestContainer {
29+
public final class RabbitTestContainer {
30+
31+
private RabbitTestContainer() {
32+
}
2933

3034
private static final RabbitMQContainer RABBITMQ;
3135
static {

binders/rabbit-binder/spring-cloud-stream-binder-rabbit/src/test/java/org/springframework/cloud/stream/binder/rabbit/integration/RabbitBinderModuleTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ void parentConnectionFactoryInheritedByDefault() throws Exception {
193193
private void checkCustomizedArgs() throws MalformedURLException, URISyntaxException, InterruptedException {
194194
List<Map<String, Object>> bindings = RestUtils.getBindingsBySource(client, uri, "/", "process-in-0");
195195
int n = 0;
196-
while (n++ < 100 && bindings == null || bindings.size() < 1) {
196+
while (n++ < 100 && bindings == null || bindings.isEmpty()) {
197197
Thread.sleep(100);
198198
bindings = RestUtils.getBindingsBySource(client, uri, "/", "process-in-0");
199199
}

core/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/AbstractMessageChannelBinderTests.java

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2023 the original author or authors.
2+
* Copyright 2023-2024 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.
@@ -21,6 +21,7 @@
2121
import java.util.Map;
2222

2323
import com.fasterxml.jackson.databind.ObjectMapper;
24+
import jakarta.validation.constraints.NotNull;
2425
import org.junit.jupiter.api.Test;
2526

2627
import org.springframework.cloud.stream.provisioning.ConsumerDestination;
@@ -44,6 +45,23 @@ public class AbstractMessageChannelBinderTests {
4445
@SuppressWarnings("unchecked")
4546
void serializeDurationOnObjectMapperInAMCB() throws Exception {
4647

48+
AbstractMessageChannelBinder<?, ?, ?> binder = createBinderInstance();
49+
50+
Field objectMapperField = ReflectionUtils.findField(AbstractMessageChannelBinder.class, "objectMapper");
51+
assertThat(objectMapperField).isNotNull();
52+
ReflectionUtils.makeAccessible(objectMapperField);
53+
final ObjectMapper objectMapper = (ObjectMapper) ReflectionUtils.getField(objectMapperField, binder);
54+
assertThat(objectMapper).isNotNull();
55+
56+
Duration duration = Duration.ofHours(1);
57+
Map<String, Object> properties = Map.of("foo", duration);
58+
final Map<String, Object> convertedMap = objectMapper.convertValue(properties, Map.class);
59+
60+
assertThat(convertedMap).isNotEmpty();
61+
}
62+
63+
@NotNull
64+
private static AbstractMessageChannelBinder<?, ?, ?> createBinderInstance() throws Exception {
4765
AbstractMessageChannelBinder<?, ?, ?> binder = new AbstractMessageChannelBinder<>(null, null) {
4866
@Override
4967
protected MessageHandler createProducerMessageHandler(ProducerDestination destination, ProducerProperties producerProperties, MessageChannel errorChannel) {
@@ -59,17 +77,6 @@ protected MessageProducer createConsumerEndpoint(ConsumerDestination destination
5977
applicationContext.refresh();
6078
binder.setApplicationContext(applicationContext);
6179
binder.onInit();
62-
63-
Field objectMapperField = ReflectionUtils.findField(AbstractMessageChannelBinder.class, "objectMapper");
64-
assertThat(objectMapperField).isNotNull();
65-
ReflectionUtils.makeAccessible(objectMapperField);
66-
final ObjectMapper objectMapper = (ObjectMapper) ReflectionUtils.getField(objectMapperField, binder);
67-
assertThat(objectMapper).isNotNull();
68-
69-
Duration duration = Duration.ofHours(1);
70-
Map<String, Object> properties = Map.of("foo", duration);
71-
final Map<String, Object> convertedMap = objectMapper.convertValue(properties, Map.class);
72-
73-
assertThat(convertedMap).isNotEmpty();
80+
return binder;
7481
}
7582
}

core/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/InputOutputBindingOrderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2023 the original author or authors.
2+
* Copyright 2015-2024 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.
@@ -57,7 +57,7 @@ void inputOutputBindingOrder() {
5757
verify(binder).bindConsumer(eq("processor-in-0"), isNull(), Mockito.any(MessageChannel.class),
5858
Mockito.any());
5959
SomeLifecycle someLifecycle = applicationContext.getBean(SomeLifecycle.class);
60-
assertThat(someLifecycle.isRunning());
60+
assertThat(someLifecycle.isRunning()).isTrue();
6161
applicationContext.close();
6262
assertThat(someLifecycle.isRunning()).isFalse();
6363
applicationContext.close();

0 commit comments

Comments
 (0)