GH-1126 Fixed default app port in Tests

Ensured AggregateApplicationTests, AggregateWithMainTest and AggregationTest arn't using default 8080 port
This commit is contained in:
Oleg Zhurakousky
2017-11-08 13:06:40 -05:00
parent b9884ae71a
commit 4e69ead7b4
3 changed files with 22 additions and 0 deletions

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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")