This is an automated email from the ASF dual-hosted git repository.

min pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-ops.git


The following commit(s) were added to refs/heads/develop by this push:
     new e559efb  fix ci failure (#281)
e559efb is described below

commit e559efb87c2723071e1d6f687a288997ac37d591
Author: kezhenxu94 <[email protected]>
AuthorDate: Wed Jan 30 10:51:52 2019 +0800

    fix ci failure (#281)
    
    * fix ci failure
    
    * use LocalServerPort shortcut and re-trigger ci build
---
 .../dubbo/admin/AbstractSpringIntegrationTest.java | 46 ++++++++++------------
 1 file changed, 21 insertions(+), 25 deletions(-)

diff --git 
a/dubbo-admin-backend/src/test/java/org/apache/dubbo/admin/AbstractSpringIntegrationTest.java
 
b/dubbo-admin-backend/src/test/java/org/apache/dubbo/admin/AbstractSpringIntegrationTest.java
index 5640c30..074373f 100644
--- 
a/dubbo-admin-backend/src/test/java/org/apache/dubbo/admin/AbstractSpringIntegrationTest.java
+++ 
b/dubbo-admin-backend/src/test/java/org/apache/dubbo/admin/AbstractSpringIntegrationTest.java
@@ -21,42 +21,38 @@ import org.apache.curator.framework.CuratorFramework;
 import org.apache.curator.framework.CuratorFrameworkFactory;
 import org.apache.curator.retry.RetryOneTime;
 import org.apache.curator.test.TestingServer;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
 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.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
 import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.web.client.RestTemplate;
-
-import java.io.IOException;
 
 @ActiveProfiles("test")
 @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 {
-  protected RestTemplate restTemplate = (new 
TestRestTemplate()).getRestTemplate();
-
-  protected static TestingServer zkServer;
-  protected static CuratorFramework zkClient;
-
-  @Value("${local.server.port}")
-  protected int port;
-
-  @BeforeClass
-  public static void beforeClass() throws Exception {
-    zkServer = new TestingServer(2182, true);
-    zkClient = CuratorFrameworkFactory.newClient(zkServer.getConnectString(), 
new RetryOneTime(2000));
-    zkClient.start();
+  @Autowired
+  protected TestRestTemplate restTemplate;
+
+  protected static final TestingServer zkServer;
+  protected static final CuratorFramework zkClient;
+
+  static {
+    try {
+      zkServer = new TestingServer(2182, true);
+      zkClient = 
CuratorFrameworkFactory.newClient(zkServer.getConnectString(), new 
RetryOneTime(2000));
+      zkClient.start();
+    } catch (Exception e) {
+      throw new ExceptionInInitializerError(e);
+    }
   }
 
-  @AfterClass
-  public static void afterClass() throws IOException {
-    zkClient.close();
-    zkServer.stop();
-  }
+  @LocalServerPort
+  protected int port;
 
   protected String url(final String path) {
     return "http://localhost:"; + port + path;

Reply via email to