diff --git a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/aggregate/AggregateApplicationTests.java b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/aggregate/AggregateApplicationTests.java index d5deab0e0..19c32dd49 100644 --- a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/aggregate/AggregateApplicationTests.java +++ b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/aggregate/AggregateApplicationTests.java @@ -19,6 +19,7 @@ package org.springframework.cloud.stream.config.aggregate; import java.util.concurrent.TimeUnit; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -42,6 +43,11 @@ import static org.hamcrest.Matchers.notNullValue; @RunWith(SpringJUnit4ClassRunner.class) public class AggregateApplicationTests { + @Before + public void before() { + System.setProperty("server.port", "0"); + } + @Test @SuppressWarnings("unchecked") public void testAggregateApplication() throws Exception { diff --git a/spring-cloud-stream-test-support/src/test/java/org/springframework/cloud/stream/test/aggregate/main/AggregateWithMainTest.java b/spring-cloud-stream-test-support/src/test/java/org/springframework/cloud/stream/test/aggregate/main/AggregateWithMainTest.java index 8f0fbe9d5..74a951330 100644 --- a/spring-cloud-stream-test-support/src/test/java/org/springframework/cloud/stream/test/aggregate/main/AggregateWithMainTest.java +++ b/spring-cloud-stream-test-support/src/test/java/org/springframework/cloud/stream/test/aggregate/main/AggregateWithMainTest.java @@ -18,6 +18,7 @@ package org.springframework.cloud.stream.test.aggregate.main; import java.util.concurrent.TimeUnit; +import org.junit.Before; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -42,6 +43,11 @@ import static org.assertj.core.api.Assertions.assertThat; */ public class AggregateWithMainTest { + @Before + public void before() { + System.setProperty("server.port", "0"); + } + @SuppressWarnings("unchecked") @Test public void testAggregateApplication() throws InterruptedException { diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/aggregation/AggregationTest.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/aggregation/AggregationTest.java index 18c6cb39f..af32d5352 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/aggregation/AggregationTest.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/aggregation/AggregationTest.java @@ -24,6 +24,7 @@ import java.util.Map; import org.junit.After; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import org.springframework.beans.DirectFieldAccessor; @@ -50,6 +51,8 @@ import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; + + /** * @author Marius Bogoevici * @author Ilayaperumal Gopinathan @@ -61,6 +64,11 @@ public class AggregationTest { private ConfigurableApplicationContext aggregatedApplicationContext; + @Before + public void before() { + System.setProperty("server.port", "0"); + } + @After public void closeContext() { System.clearProperty("a.foo-value"); @@ -245,6 +253,7 @@ public class AggregationTest { MockBinderRegistryConfiguration.class); System.setProperty("a.foo-value", "sysbara"); System.setProperty("c.fooValue", "sysbarc"); + System.setProperty("server.port", "0"); aggregatedApplicationContext = aggregateApplicationBuilder.parent(DummyConfig.class).from(TestSource.class) .namespace("a").args("--foo-value=bar") .via(TestProcessor.class).namespace("b").args("--fooValue=argbarb") @@ -278,6 +287,7 @@ public class AggregationTest { MockBinderRegistryConfiguration.class); System.setProperty("a.foo-value", "sysbara"); System.setProperty("c.fooValue", "sysbarc"); + System.setProperty("server.port", "0"); aggregatedApplicationContext = aggregateApplicationBuilder.parent(DummyConfig.class).from(TestSource.class) .namespace("a").args("--foo-value=bar") .via(TestProcessor.class).namespace("b").args("--fooValue=argbarb")