提交 e559efb8 编写于 作者: K kezhenxu94 提交者: min

fix ci failure (#281)

* fix ci failure

* use LocalServerPort shortcut and re-trigger ci build
上级 06946925
...@@ -21,42 +21,38 @@ import org.apache.curator.framework.CuratorFramework; ...@@ -21,42 +21,38 @@ import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.RetryOneTime; import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.TestingServer; import org.apache.curator.test.TestingServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.client.RestTemplate;
import java.io.IOException;
@ActiveProfiles("test") @ActiveProfiles("test")
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @SpringBootTest(classes = DubboAdminApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ContextConfiguration(classes = DubboAdminApplication.class)
public abstract class AbstractSpringIntegrationTest { public abstract class AbstractSpringIntegrationTest {
protected RestTemplate restTemplate = (new TestRestTemplate()).getRestTemplate(); @Autowired
protected TestRestTemplate restTemplate;
protected static TestingServer zkServer;
protected static CuratorFramework zkClient; protected static final TestingServer zkServer;
protected static final CuratorFramework zkClient;
@Value("${local.server.port}")
protected int port; static {
try {
@BeforeClass zkServer = new TestingServer(2182, true);
public static void beforeClass() throws Exception { zkClient = CuratorFrameworkFactory.newClient(zkServer.getConnectString(), new RetryOneTime(2000));
zkServer = new TestingServer(2182, true); zkClient.start();
zkClient = CuratorFrameworkFactory.newClient(zkServer.getConnectString(), new RetryOneTime(2000)); } catch (Exception e) {
zkClient.start(); throw new ExceptionInInitializerError(e);
}
} }
@AfterClass @LocalServerPort
public static void afterClass() throws IOException { protected int port;
zkClient.close();
zkServer.stop();
}
protected String url(final String path) { protected String url(final String path) {
return "http://localhost:" + port + path; return "http://localhost:" + port + path;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册