Code cleanup
This commit is contained in:
committed by
Oleg Zhurakousky
parent
1de0e1c690
commit
7fefaa38c0
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
* Copyright 2015-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.
|
||||
@@ -22,7 +22,6 @@ package org.springframework.cloud.stream.binder.rabbit.admin;
|
||||
* @author Gary Russell
|
||||
* @since 1.2
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class RabbitAdminException extends RuntimeException {
|
||||
|
||||
public RabbitAdminException(String message, Throwable cause) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2022-2022 the original author or authors.
|
||||
* Copyright 2022-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.
|
||||
@@ -24,8 +24,12 @@ import org.testcontainers.containers.RabbitMQContainer;
|
||||
* Provides a static {@link RabbitMQContainer} that can be shared across test classes.
|
||||
*
|
||||
* @author Chris Bono
|
||||
* @author Omer Celik
|
||||
*/
|
||||
public class RabbitTestContainer {
|
||||
public final class RabbitTestContainer {
|
||||
|
||||
private RabbitTestContainer() {
|
||||
}
|
||||
|
||||
private static final RabbitMQContainer RABBITMQ;
|
||||
static {
|
||||
|
||||
@@ -193,7 +193,7 @@ class RabbitBinderModuleTests {
|
||||
private void checkCustomizedArgs() throws MalformedURLException, URISyntaxException, InterruptedException {
|
||||
List<Map<String, Object>> bindings = RestUtils.getBindingsBySource(client, uri, "/", "process-in-0");
|
||||
int n = 0;
|
||||
while (n++ < 100 && bindings == null || bindings.size() < 1) {
|
||||
while (n++ < 100 && bindings == null || bindings.isEmpty()) {
|
||||
Thread.sleep(100);
|
||||
bindings = RestUtils.getBindingsBySource(client, uri, "/", "process-in-0");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2023-2023 the original author or authors.
|
||||
* Copyright 2023-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.
|
||||
@@ -21,6 +21,7 @@ import java.time.Duration;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.cloud.stream.provisioning.ConsumerDestination;
|
||||
@@ -44,6 +45,23 @@ public class AbstractMessageChannelBinderTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
void serializeDurationOnObjectMapperInAMCB() throws Exception {
|
||||
|
||||
AbstractMessageChannelBinder<?, ?, ?> binder = createBinderInstance();
|
||||
|
||||
Field objectMapperField = ReflectionUtils.findField(AbstractMessageChannelBinder.class, "objectMapper");
|
||||
assertThat(objectMapperField).isNotNull();
|
||||
ReflectionUtils.makeAccessible(objectMapperField);
|
||||
final ObjectMapper objectMapper = (ObjectMapper) ReflectionUtils.getField(objectMapperField, binder);
|
||||
assertThat(objectMapper).isNotNull();
|
||||
|
||||
Duration duration = Duration.ofHours(1);
|
||||
Map<String, Object> properties = Map.of("foo", duration);
|
||||
final Map<String, Object> convertedMap = objectMapper.convertValue(properties, Map.class);
|
||||
|
||||
assertThat(convertedMap).isNotEmpty();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static AbstractMessageChannelBinder<?, ?, ?> createBinderInstance() throws Exception {
|
||||
AbstractMessageChannelBinder<?, ?, ?> binder = new AbstractMessageChannelBinder<>(null, null) {
|
||||
@Override
|
||||
protected MessageHandler createProducerMessageHandler(ProducerDestination destination, ProducerProperties producerProperties, MessageChannel errorChannel) {
|
||||
@@ -59,17 +77,6 @@ public class AbstractMessageChannelBinderTests {
|
||||
applicationContext.refresh();
|
||||
binder.setApplicationContext(applicationContext);
|
||||
binder.onInit();
|
||||
|
||||
Field objectMapperField = ReflectionUtils.findField(AbstractMessageChannelBinder.class, "objectMapper");
|
||||
assertThat(objectMapperField).isNotNull();
|
||||
ReflectionUtils.makeAccessible(objectMapperField);
|
||||
final ObjectMapper objectMapper = (ObjectMapper) ReflectionUtils.getField(objectMapperField, binder);
|
||||
assertThat(objectMapper).isNotNull();
|
||||
|
||||
Duration duration = Duration.ofHours(1);
|
||||
Map<String, Object> properties = Map.of("foo", duration);
|
||||
final Map<String, Object> convertedMap = objectMapper.convertValue(properties, Map.class);
|
||||
|
||||
assertThat(convertedMap).isNotEmpty();
|
||||
return binder;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2023 the original author or authors.
|
||||
* Copyright 2015-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.
|
||||
@@ -57,7 +57,7 @@ class InputOutputBindingOrderTest {
|
||||
verify(binder).bindConsumer(eq("processor-in-0"), isNull(), Mockito.any(MessageChannel.class),
|
||||
Mockito.any());
|
||||
SomeLifecycle someLifecycle = applicationContext.getBean(SomeLifecycle.class);
|
||||
assertThat(someLifecycle.isRunning());
|
||||
assertThat(someLifecycle.isRunning()).isTrue();
|
||||
applicationContext.close();
|
||||
assertThat(someLifecycle.isRunning()).isFalse();
|
||||
applicationContext.close();
|
||||
|
||||
Reference in New Issue
Block a user