Updated all Junit tests to 5.x
resolves TASK-675
This commit is contained in:
committed by
Michael Minella
parent
f3bbc37293
commit
59c9adf047
@@ -20,13 +20,12 @@ import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.assertj.core.api.BDDAssertions;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.testcontainers.containers.GenericContainer;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.cloud.stream.annotation.EnableBinding;
|
||||
import org.springframework.cloud.stream.annotation.StreamListener;
|
||||
import org.springframework.cloud.stream.binder.test.junit.rabbit.RabbitTestSupport;
|
||||
import org.springframework.cloud.stream.messaging.Sink;
|
||||
import org.springframework.cloud.task.batch.listener.support.JobExecutionEvent;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -36,12 +35,20 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class BatchEventsApplicationTests {
|
||||
|
||||
@ClassRule
|
||||
public static RabbitTestSupport rabbitTestSupport = new RabbitTestSupport();
|
||||
static {
|
||||
GenericContainer rabbitmq = new GenericContainer("rabbitmq:3.5.3")
|
||||
.withExposedPorts(5672);
|
||||
rabbitmq.start();
|
||||
final Integer mappedPort = rabbitmq.getMappedPort(5672);
|
||||
System.setProperty("spring.rabbitmq.test.port", mappedPort.toString());
|
||||
rabbitPort = mappedPort.toString();
|
||||
}
|
||||
|
||||
// Count for two job execution events per task
|
||||
static CountDownLatch jobExecutionLatch = new CountDownLatch(2);
|
||||
|
||||
private static String rabbitPort;
|
||||
|
||||
@Test
|
||||
public void testExecution() throws Exception {
|
||||
SpringApplication
|
||||
@@ -49,7 +56,8 @@ public class BatchEventsApplicationTests {
|
||||
SpringApplication.run(BatchEventsApplication.class, "--server.port=0",
|
||||
"--spring.cloud.stream.bindings.output.producer.requiredGroups=testgroup",
|
||||
"--spring.jmx.default-domain=fakedomain",
|
||||
"--spring.main.webEnvironment=false");
|
||||
"--spring.main.webEnvironment=false",
|
||||
"--spring.rabbitmq.port=" + rabbitPort);
|
||||
assertThat(jobExecutionLatch.await(60, TimeUnit.SECONDS))
|
||||
.as("The latch did not count down to zero before timeout").isTrue();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user