add non-0 port check to test
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package org.springframework.cloud.consul.discovery;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -27,14 +28,13 @@ import org.junit.runner.RunWith;
|
||||
import org.junit.runners.MethodSorters;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
import org.springframework.cloud.consul.ConsulAutoConfiguration;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import com.ecwid.consul.v1.ConsulClient;
|
||||
import com.ecwid.consul.v1.Response;
|
||||
@@ -46,8 +46,7 @@ import com.ecwid.consul.v1.agent.model.Service;
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
@SpringApplicationConfiguration(classes = TestConfig.class)
|
||||
@IntegrationTest({ "server.port=0", "spring.application.name=myTestService" })
|
||||
@WebAppConfiguration
|
||||
@WebIntegrationTest(value = "spring.application.name=myTestService", randomPort = true)
|
||||
public class ConsulLifecycleTests {
|
||||
|
||||
@Autowired
|
||||
@@ -65,8 +64,9 @@ public class ConsulLifecycleTests {
|
||||
Map<String, Service> services = response.getValue();
|
||||
Service service = services.get(context.getId());
|
||||
assertNotNull("service was null", service);
|
||||
assertEquals("service id was wrong", service.getId(), context.getId());
|
||||
assertEquals("service name was wrong", service.getService(), "myTestService");
|
||||
assertNotEquals("service port is 0", 0, service.getPort().intValue());
|
||||
assertEquals("service id was wrong", context.getId(), service.getId());
|
||||
assertEquals("service name was wrong", "myTestService", service.getService());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user