Fix formatting

This commit is contained in:
Oleg Zhurakousky
2025-04-11 13:22:50 +02:00
committed by Ryan Baxter
parent 50d5ae512e
commit c643bd3ae1
7 changed files with 40 additions and 104 deletions

View File

@@ -30,8 +30,8 @@ import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.streams.KafkaStreams;
import org.apache.kafka.streams.errors.StreamsUncaughtExceptionHandler;
import org.apache.kafka.streams.kstream.KStream;
import org.assertj.core.api.Assertions;
import org.assertj.core.util.Lists;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

View File

@@ -20,12 +20,12 @@ package org.springframework.cloud.stream.binder.test.junit.rabbit;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.springframework.util.Assert;
import static org.junit.jupiter.api.Assertions.fail;
/**
* Abstract base class for JUnit {@link Rule}s that detect the presence of some external
@@ -64,68 +64,10 @@ public abstract class AbstractExternalResourceTestSupport<R> implements BeforeEa
catch (Exception e) {
maybeCleanup();
// failOrSkip(e);
fail();
Assertions.fail();
}
}
// @Override
// public Statement apply(final Statement base, Description description) {
// try {
// obtainResource();
// }
// catch (Exception e) {
// maybeCleanup();
//
// return failOrSkip(e);
// }
//
// return new Statement() {
//
// @Override
// public void evaluate() throws Throwable {
// try {
// base.evaluate();
// }
// finally {
// try {
// cleanupResource();
// }
// catch (Exception ignored) {
// AbstractExternalResourceTestSupport.this.logger.warn(
// "Exception while trying to cleanup proper resource",
// ignored);
// }
// }
// }
//
// };
// }
// private Statement failOrSkip(final Exception e) {
// String serversRequired = System.getenv(SCS_EXTERNAL_SERVERS_REQUIRED);
// if ("true".equalsIgnoreCase(serversRequired)) {
// this.logger.error(this.resourceDescription + " IS REQUIRED BUT NOT AVAILABLE",
// e);
// fail(this.resourceDescription + " IS NOT AVAILABLE");
// // Never reached, here to satisfy method signature
// return null;
// }
// else {
// this.logger.error(
// this.resourceDescription + " IS NOT AVAILABLE, SKIPPING TESTS", e);
// return new Statement() {
//
// @Override
// public void evaluate() throws Throwable {
// Assume.assumeTrue("Skipping test due to "
// + AbstractExternalResourceTestSupport.this.resourceDescription
// + " not being available " + e, false);
// }
// };
// }
// }
private void maybeCleanup() {
if (this.resource != null) {
try {

View File

@@ -18,7 +18,6 @@ package org.springframework.cloud.stream.binder.rabbit;
import java.util.List;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.amqp.AmqpRejectAndDontRequeueException;
@@ -41,13 +40,15 @@ class BatchCapableRejectAndDontRequeueRecovererTest {
Throwable expectedThrowable = new RuntimeException("test");
ListenerExecutionFailedException exception = Assertions.assertThrows(ListenerExecutionFailedException.class,
() -> messageBatchRecoverer.recover(messages, expectedThrowable));
assertThat(exception.getFailedMessages()).contains(expectedMessage1);
assertThat(exception.getFailedMessages()).contains(expectedMessage2);
assertThat(exception.getCause()).isInstanceOf(AmqpRejectAndDontRequeueException.class);
assertThat(expectedThrowable).isEqualTo(exception.getCause().getCause());
try {
messageBatchRecoverer.recover(messages, expectedThrowable);
}
catch (ListenerExecutionFailedException exception) {
assertThat(exception.getFailedMessages()).contains(expectedMessage1);
assertThat(exception.getFailedMessages()).contains(expectedMessage2);
assertThat(exception.getCause()).isInstanceOf(AmqpRejectAndDontRequeueException.class);
assertThat(expectedThrowable).isEqualTo(exception.getCause().getCause());
}
}
@Test
@@ -58,11 +59,13 @@ class BatchCapableRejectAndDontRequeueRecovererTest {
Throwable expectedThrowable = new RuntimeException("test");
ListenerExecutionFailedException exception = Assertions.assertThrows(ListenerExecutionFailedException.class,
() -> messageBatchRecoverer.recover(expectedMessage, expectedThrowable));
assertThat(expectedMessage).isEqualTo(exception.getFailedMessage());
assertThat(exception.getCause()).isInstanceOf(AmqpRejectAndDontRequeueException.class);
assertThat(expectedThrowable).isEqualTo(exception.getCause().getCause());
try {
messageBatchRecoverer.recover(expectedMessage, expectedThrowable);
}
catch (ListenerExecutionFailedException exception) {
assertThat(expectedMessage).isEqualTo(exception.getFailedMessage());
assertThat(exception.getCause()).isInstanceOf(AmqpRejectAndDontRequeueException.class);
assertThat(expectedThrowable).isEqualTo(exception.getCause().getCause());
}
}
}

View File

@@ -26,6 +26,7 @@ import java.util.UUID;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DefaultConsumer;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.testcontainers.containers.RabbitMQContainer;
@@ -48,7 +49,6 @@ import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.util.UriUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
/**
* @author Gary Russell
@@ -127,7 +127,7 @@ class RabbitBinderCleanerTests {
try {
waitForConsumerState(queueName, 1);
doClean(cleaner, stream1, false);
fail("Expected exception");
Assertions.fail("Expected exception");
}
catch (RabbitAdminException e) {
assertThat(e)
@@ -137,7 +137,7 @@ class RabbitBinderCleanerTests {
waitForConsumerState(queueName, 0);
try {
doClean(cleaner, stream1, false);
fail("Expected exception");
Assertions.fail("Expected exception");
}
catch (RabbitAdminException e) {
assertThat(e).hasMessageContaining("Cannot delete exchange ");