Переглянути джерело

将 mgr.thirdparty 模块放到 ThirdpartyServiceTest 中

reghao 6 місяців тому
батько
коміт
e4a936b6ce

+ 0 - 15
mgr/src/main/java/cn/reghao/devops/mgr/thirdparty/consul/ConsulNode.java

@@ -1,15 +0,0 @@
-package cn.reghao.devops.mgr.thirdparty.consul;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-/**
- * @author reghao
- * @date 2023-02-24 11:46:50
- */
-@AllArgsConstructor
-@Getter
-public class ConsulNode {
-    private String dc;
-    private String address;
-}

+ 18 - 15
mgr/src/main/java/cn/reghao/devops/mgr/thirdparty/consul/ConsulService.java → mgr/src/test/java/cn/reghao/devops/mgr/devops/ThirdpartyServiceTest.java

@@ -1,4 +1,4 @@
-package cn.reghao.devops.mgr.thirdparty.consul;
+package cn.reghao.devops.mgr.devops;
 
 import cn.reghao.jutil.jdk.http.WebClient;
 import cn.reghao.jutil.jdk.http.WebRequest;
@@ -7,7 +7,9 @@ import cn.reghao.jutil.jdk.serializer.JsonConverter;
 import com.google.gson.JsonArray;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
-import org.springframework.stereotype.Service;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import org.junit.Test;
 
 import java.io.IOException;
 import java.net.URI;
@@ -19,12 +21,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-/**
- * @author reghao
- * @date 2023-02-22 17:29:13
- */
-@Service
-public class ConsulService {
+public class ThirdpartyServiceTest {
     private final WebRequest webRequest = new WebClient();
     private final String host = "http://consul.iquizoo.cn";
 
@@ -75,15 +72,21 @@ public class ConsulService {
         String body = httpResponse.body();
     }
 
-    public static void main(String[] args) throws URISyntaxException, IOException, InterruptedException {
-        ConsulService consulService = new ConsulService();
-        List<ConsulNode> consulNodes = consulService.getNodes();
+    @Test
+    public void consulTest() throws Exception {
+        //List<ConsulNode> consulNodes = getNodes();
 
-        List<String> list = consulService.getServices();
-        System.out.println(list);
+        //System.out.println(getServices());
 
         String service = "FileGrpcService_172_16_45_66_8104";
         service = "FileService-WebApi_172_16_45_66_8004";
-        //consulService.deregister(service);
+        //deregister(service);
     }
-}
+
+    @AllArgsConstructor
+    @Getter
+    static class ConsulNode {
+        private String dc;
+        private String address;
+    }
+}