1 package org.onap.msb.apiroute.wrapper.serviceListener;
3 import java.lang.reflect.InvocationHandler;
4 import java.lang.reflect.Method;
5 import java.util.HashSet;
8 import org.junit.Assert;
9 import org.junit.Before;
10 import org.junit.BeforeClass;
11 import org.junit.Test;
12 import org.junit.runner.RunWith;
13 import org.onap.msb.apiroute.ApiRouteAppConfig;
14 import org.onap.msb.apiroute.api.ApiRouteInfo;
15 import org.onap.msb.apiroute.api.CustomRouteInfo;
16 import org.onap.msb.apiroute.api.DiscoverInfo;
17 import org.onap.msb.apiroute.api.IuiRouteInfo;
18 import org.onap.msb.apiroute.api.MicroServiceFullInfo;
19 import org.onap.msb.apiroute.api.Node;
20 import org.onap.msb.apiroute.api.RouteServer;
21 import org.onap.msb.apiroute.api.exception.ExtendedNotFoundException;
22 import org.onap.msb.apiroute.wrapper.ApiRouteServiceWrapper;
23 import org.onap.msb.apiroute.wrapper.CustomRouteServiceWrapper;
24 import org.onap.msb.apiroute.wrapper.InitRouteServiceWrapper;
25 import org.onap.msb.apiroute.wrapper.IuiRouteServiceWrapper;
26 import org.onap.msb.apiroute.wrapper.dao.RedisAccessWrapper;
27 import org.onap.msb.apiroute.wrapper.serviceListener.RouteNotify;
28 import org.onap.msb.apiroute.wrapper.util.ConfigUtil;
29 import org.onap.msb.apiroute.wrapper.util.HttpClientUtil;
30 import org.onap.msb.apiroute.wrapper.util.JedisUtil;
31 import org.onap.msb.apiroute.wrapper.util.RouteUtil;
32 import org.powermock.api.mockito.PowerMockito;
33 import org.powermock.core.classloader.annotations.PowerMockIgnore;
34 import org.powermock.core.classloader.annotations.PrepareForTest;
35 import org.powermock.modules.junit4.PowerMockRunner;
37 import redis.clients.jedis.JedisPool;
38 import redis.clients.jedis.JedisPoolConfig;
40 import com.fiftyonred.mock_jedis.MockJedisPool;
42 @RunWith(PowerMockRunner.class)
43 @PrepareForTest({JedisUtil.class,ConfigUtil.class,HttpClientUtil.class, RedisAccessWrapper.class,})
44 @PowerMockIgnore({"javax.management.*"})
45 public class MicroServiceChangeListenerTest {
46 private static RouteNotify routeInstance;
47 private static ApiRouteServiceWrapper apiRouteServiceWrapper;
48 private static IuiRouteServiceWrapper iuiRouteServiceWrapper;
49 private static CustomRouteServiceWrapper customRouteServiceWrapper;
53 public static void setUpBeforeClass() throws Exception {
54 InitRouteServiceWrapper.getInstance().registerServiceChangeListener();
55 routeInstance=RouteNotify.getInstance();
56 apiRouteServiceWrapper=ApiRouteServiceWrapper.getInstance();
57 iuiRouteServiceWrapper=IuiRouteServiceWrapper.getInstance();
58 customRouteServiceWrapper=CustomRouteServiceWrapper.getInstance();
60 PowerMockito.mockStatic(System.class);
61 PowerMockito.when(System.getenv("ROUTE_WAY")).thenReturn("ip|domain");
62 ConfigUtil.getInstance().initRouteWay();
66 public void initReidsMock() throws Exception {
67 final JedisPool mockJedisPool = new MockJedisPool(new JedisPoolConfig(), "localhost");
68 PowerMockito.mockStatic(JedisUtil.class);
69 JedisUtil jedisUtil=PowerMockito.mock(JedisUtil.class);
70 PowerMockito.when(jedisUtil.borrowJedisInstance()).thenReturn(mockJedisPool.getResource());
72 PowerMockito.replace(PowerMockito.method(RedisAccessWrapper.class, "filterKeys")).with(new InvocationHandler() {
74 public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
75 return mockJedisPool.getResource().keys((String) args[0]);
81 public void test_noticeRouteListener4Update_api(){
83 routeInstance.noticeRouteListener4Update("apiTest-ns", "v1", buildMicroServiceFullInfo4API());
84 ApiRouteInfo apiRouteInfo=apiRouteServiceWrapper.getApiRouteInstance("apiTest-ns", "v1", "host", "20081", "ip");
86 Assert.assertNotNull(apiRouteInfo);
87 Assert.assertEquals("1", apiRouteInfo.getStatus());
89 routeInstance.noticeUpdateStatusListener(buildMicroServiceFullInfo4API(),"0");
90 apiRouteInfo=apiRouteServiceWrapper.getApiRouteInstance("apiTest-ns", "v1", "host", "20081", "ip");
91 Assert.assertEquals("0", apiRouteInfo.getStatus());
93 } catch (Exception e) {
94 Assert.fail("throw exception means error occured!" + e.getMessage());
99 public void test_noticeRouteListener4Update_iui(){
101 routeInstance.noticeRouteListener4Update("iuiTest-ns", "v1", buildMicroServiceFullInfo4IUI());
102 IuiRouteInfo iuiRouteInfo=iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest-ns", "host", "20081", "ip");
104 Assert.assertNotNull(iuiRouteInfo);
105 Assert.assertEquals("1", iuiRouteInfo.getStatus());
107 routeInstance.noticeUpdateStatusListener(buildMicroServiceFullInfo4IUI(),"0");
108 iuiRouteInfo=iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest-ns", "host", "20081", "ip");
109 Assert.assertEquals("0", iuiRouteInfo.getStatus());
111 } catch (Exception e) {
112 Assert.fail("throw exception means error occured!" + e.getMessage());
117 public void test_noticeRouteListener4Update_http(){
119 routeInstance.noticeRouteListener4Update("httpTest-ns", "v1", buildMicroServiceFullInfo4HTTP());
120 CustomRouteInfo customRouteInfo=customRouteServiceWrapper.getCustomRouteInstance("/httpTest-ns", "host", "20081", "ip");
121 Assert.assertNotNull(customRouteInfo);
122 Assert.assertEquals("1", customRouteInfo.getStatus());
124 routeInstance.noticeUpdateStatusListener(buildMicroServiceFullInfo4HTTP(),"0");
125 customRouteInfo=customRouteServiceWrapper.getCustomRouteInstance("/httpTest-ns", "host", "20081", "ip");
126 Assert.assertEquals("0", customRouteInfo.getStatus());
127 } catch (Exception e) {
128 Assert.fail("throw exception means error occured!" + e.getMessage());
133 public void test_noticeRouteListener4Add_del_api(){
135 MicroServiceFullInfo microServiceInfo =buildMicroServiceFullInfo4API();
136 routeInstance.noticeRouteListener4Add(microServiceInfo);
137 Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "20081", "ip"));
138 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/", "apitest-ns", "", "domain"));
140 routeInstance.noticeRouteListener4Delete(microServiceInfo);
142 } catch (Exception e) {
143 Assert.fail("throw exception means error occured!" + e.getMessage());
147 apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "20081", "ip");
148 Assert.fail("should not process to here.");
151 Assert.assertTrue(e instanceof ExtendedNotFoundException);
155 apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "apitest-ns", "", "domain");
156 Assert.fail("should not process to here.");
159 Assert.assertTrue(e instanceof ExtendedNotFoundException);
166 public void test_noticeRouteListener4Add_del_api_path(){
168 MicroServiceFullInfo microServiceInfo =buildMicroServiceFullInfo4API_path();
169 routeInstance.noticeRouteListener4Add(microServiceInfo);
170 Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "", "10081", "ip"));
171 Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "", "10082", "ip"));
172 Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "host", "", "domain"));
174 routeInstance.noticeRouteListener4Delete(microServiceInfo);
176 } catch (Exception e) {
177 Assert.fail("throw exception means error occured!" + e.getMessage());
181 apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "", "10081", "ip");
182 Assert.fail("should not process to here.");
185 Assert.assertTrue(e instanceof ExtendedNotFoundException);
189 apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "", "10082", "ip");
190 Assert.fail("should not process to here.");
193 Assert.assertTrue(e instanceof ExtendedNotFoundException);
197 apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "host", "", "domain");
198 Assert.fail("should not process to here.");
201 Assert.assertTrue(e instanceof ExtendedNotFoundException);
207 public void test_noticeRouteListener4Add_del_api_mutiPort(){
209 MicroServiceFullInfo microServiceInfo =buildMicroServiceFullInfo4API_path();
210 microServiceInfo.setPath("");
211 microServiceInfo.setHost("");
213 routeInstance.noticeRouteListener4Add(microServiceInfo);
214 Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "10081", "ip"));
215 Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "10082", "ip"));
216 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/", "apitest", "", "domain"));
218 routeInstance.noticeRouteListener4Delete(microServiceInfo);
220 } catch (Exception e) {
221 Assert.fail("throw exception means error occured!" + e.getMessage());
225 apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "10081", "ip");
226 Assert.fail("should not process to here.");
229 Assert.assertTrue(e instanceof ExtendedNotFoundException);
233 apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "10082", "ip");
234 Assert.fail("should not process to here.");
237 Assert.assertTrue(e instanceof ExtendedNotFoundException);
241 apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "apitest", "", "domain");
242 Assert.fail("should not process to here.");
245 Assert.assertTrue(e instanceof ExtendedNotFoundException);
251 public void test_noticeRouteListener4Add_del_iui(){
253 MicroServiceFullInfo microServiceInfo =buildMicroServiceFullInfo4IUI();
254 routeInstance.noticeRouteListener4Add(microServiceInfo);
255 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "20081", "ip"));
256 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/", "iuitest-ns", "", "domain"));
258 routeInstance.noticeRouteListener4Delete(microServiceInfo);
260 } catch (Exception e) {
261 Assert.fail("throw exception means error occured!" + e.getMessage());
265 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "20081", "ip");
266 Assert.fail("should not process to here.");
269 Assert.assertTrue(e instanceof ExtendedNotFoundException);
273 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "iuitest-ns", "", "domain");
274 Assert.fail("should not process to here.");
277 Assert.assertTrue(e instanceof ExtendedNotFoundException);
283 public void test_noticeRouteListener4Add_del_iui_path(){
285 MicroServiceFullInfo microServiceInfo =buildMicroServiceFullInfo4IUI_path();
286 routeInstance.noticeRouteListener4Add(microServiceInfo);
287 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10081", "ip"));
288 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10082", "ip"));
289 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "host", "", "domain"));
291 routeInstance.noticeRouteListener4Delete(microServiceInfo);
292 } catch (Exception e) {
293 Assert.fail("throw exception means error occured!" + e.getMessage());
297 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10081", "ip");
298 Assert.fail("should not process to here.");
301 Assert.assertTrue(e instanceof ExtendedNotFoundException);
305 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10082", "ip");
306 Assert.fail("should not process to here.");
309 Assert.assertTrue(e instanceof ExtendedNotFoundException);
313 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "host", "", "domain");
314 Assert.fail("should not process to here.");
317 Assert.assertTrue(e instanceof ExtendedNotFoundException);
324 public void test_noticeRouteListener4Add_del_iui_mutiPort(){
326 MicroServiceFullInfo microServiceInfo =buildMicroServiceFullInfo4IUI_path();
327 microServiceInfo.setPath("");
328 microServiceInfo.setHost("");
330 routeInstance.noticeRouteListener4Add(microServiceInfo);
331 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10081", "ip"));
332 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10082", "ip"));
333 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/", "iuitest", "", "domain"));
335 routeInstance.noticeRouteListener4Delete(microServiceInfo);
336 } catch (Exception e) {
337 Assert.fail("throw exception means error occured!" + e.getMessage());
341 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10081", "ip");
342 Assert.fail("should not process to here.");
345 Assert.assertTrue(e instanceof ExtendedNotFoundException);
349 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10082", "ip");
350 Assert.fail("should not process to here.");
353 Assert.assertTrue(e instanceof ExtendedNotFoundException);
357 customRouteServiceWrapper.getCustomRouteInstance("/", "iuitest", "", "domain");
358 Assert.fail("should not process to here.");
361 Assert.assertTrue(e instanceof ExtendedNotFoundException);
367 public void test_noticeRouteListener4Add_del_http(){
369 MicroServiceFullInfo microServiceInfo=buildMicroServiceFullInfo4HTTP();
370 routeInstance.noticeRouteListener4Add(microServiceInfo);
371 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "20081", "ip"));
372 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "httptest-ns", "", "domain"));
374 routeInstance.noticeRouteListener4Delete(microServiceInfo);
375 } catch (Exception e) {
376 Assert.fail("throw exception means error occured!" + e.getMessage());
380 customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "20081", "ip");
381 Assert.fail("should not process to here.");
384 Assert.assertTrue(e instanceof ExtendedNotFoundException);
388 customRouteServiceWrapper.getCustomRouteInstance("/httpTest", "httptest-ns", "", "domain");
389 Assert.fail("should not process to here.");
392 Assert.assertTrue(e instanceof ExtendedNotFoundException);
398 public void test_noticeRouteListener4Add_del_http_path(){
400 MicroServiceFullInfo microServiceInfo=buildMicroServiceFullInfo4HTTP_path();
401 routeInstance.noticeRouteListener4Add(microServiceInfo);
402 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10081", "ip"));
403 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10082", "ip"));
404 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "host", "", "domain"));
406 routeInstance.noticeRouteListener4Delete(microServiceInfo);
407 } catch (Exception e) {
408 Assert.fail("throw exception means error occured!" + e.getMessage());
412 customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10081", "ip");
413 Assert.fail("should not process to here.");
416 Assert.assertTrue(e instanceof ExtendedNotFoundException);
420 customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10082", "ip");
421 Assert.fail("should not process to here.");
424 Assert.assertTrue(e instanceof ExtendedNotFoundException);
428 customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "host", "", "domain");
429 Assert.fail("should not process to here.");
432 Assert.assertTrue(e instanceof ExtendedNotFoundException);
439 public void test_noticeRouteListener4Add_del_http_mutiPort(){
441 MicroServiceFullInfo microServiceInfo=buildMicroServiceFullInfo4HTTP_path();
442 microServiceInfo.setPath("");
443 microServiceInfo.setHost("");
445 routeInstance.noticeRouteListener4Add(microServiceInfo);
446 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10081", "ip"));
447 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10082", "ip"));
448 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "httptest", "", "domain"));
450 routeInstance.noticeRouteListener4Delete(microServiceInfo);
451 } catch (Exception e) {
452 Assert.fail("throw exception means error occured!" + e.getMessage());
456 customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10081", "ip");
457 Assert.fail("should not process to here.");
460 Assert.assertTrue(e instanceof ExtendedNotFoundException);
464 customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10082", "ip");
465 Assert.fail("should not process to here.");
468 Assert.assertTrue(e instanceof ExtendedNotFoundException);
472 customRouteServiceWrapper.getCustomRouteInstance("/httpTest", "httptest", "", "domain");
473 Assert.fail("should not process to here.");
476 Assert.assertTrue(e instanceof ExtendedNotFoundException);
483 public void test_noticeRouteListener4Add_portal(){
485 PowerMockito.mockStatic(System.class);
486 PowerMockito.when(System.getenv("SDCLIENT_IP")).thenReturn("127.0.0.1");
487 ApiRouteAppConfig configuration=new ApiRouteAppConfig();
489 DiscoverInfo discoverInfo=new DiscoverInfo();
490 discoverInfo.setEnabled(true);
491 discoverInfo.setIp("127.0.0.2");
492 discoverInfo.setPort(10081);
493 configuration.setDiscoverInfo(discoverInfo);
494 ConfigUtil.getInstance().initDiscoverInfo(configuration);
497 PowerMockito.mockStatic(HttpClientUtil.class);
498 String publishUrl="http://127.0.0.1:10081/api/microservices/v1/services/portalTest/version/v1/allpublishaddress?namespace=&visualRange=0";
499 String resultJson ="[{\"domain\":\"opapi.openpalette.zte.com.cn\",\"port\":\"443\",\"publish_url\":\"/api\",\"visualRange\":\"0\",\"publish_protocol\":\"https\"},{\"ip\":\"10.74.165.246\",\"port\":\"443\",\"publish_url\":\"/opapi\",\"visualRange\":\"0\",\"publish_protocol\":\"https\"},{\"ip\":\"10.74.165.246\",\"port\":\"80\",\"publish_url\":\"/opapi\",\"visualRange\":\"0\",\"publish_protocol\":\"http\"}]";
500 PowerMockito.when(HttpClientUtil.httpGet(publishUrl)).thenReturn(resultJson);
502 MicroServiceFullInfo microServiceInfo=buildMicroServiceFullInfo4PORTAL();
504 routeInstance.noticeRouteListener4Add(microServiceInfo);
506 CustomRouteInfo routeInfo_ip=customRouteServiceWrapper.getCustomRouteInstance("/portalTest/v1", "", "10088", "ip");
507 RouteServer[] servers_ip = new RouteServer[]{new RouteServer("10.74.148.99","8080")};
508 Assert.assertArrayEquals(servers_ip, routeInfo_ip.getServers());
510 CustomRouteInfo routeInfo_domain=customRouteServiceWrapper.getCustomRouteInstance("/portalTest/v1", "host", "", "domain");
511 RouteServer[] servers_domain = new RouteServer[]{new RouteServer("10.74.165.246","443")};
513 Assert.assertArrayEquals(servers_domain, routeInfo_domain.getServers());
515 } catch (Exception e) {
516 Assert.fail("throw exception means error occured!" + e.getMessage());
522 private MicroServiceFullInfo buildMicroServiceFullInfo4API(){
523 MicroServiceFullInfo microServiceInfo=new MicroServiceFullInfo();
524 microServiceInfo.setServiceName("apiTest-ns");
525 microServiceInfo.setVersion("v1");
526 microServiceInfo.setEnable_ssl(false);
527 microServiceInfo.setPublish_port("20081");
528 microServiceInfo.setProtocol("REST");
529 microServiceInfo.setUrl("/api/apiTest/v1");
530 microServiceInfo.setVisualRange("1");
531 microServiceInfo.setStatus("1");
532 microServiceInfo.setNamespace("ns");
533 Set<Node> nodes = new HashSet<Node>();
534 nodes.add(new Node("10.74.148.88","8080"));
535 nodes.add(new Node("10.74.148.89","8080"));
536 microServiceInfo.setNodes(nodes);
538 return microServiceInfo;
541 private MicroServiceFullInfo buildMicroServiceFullInfo4API_path(){
542 MicroServiceFullInfo microServiceInfo=new MicroServiceFullInfo();
543 microServiceInfo.setServiceName("apiTest");
544 microServiceInfo.setVersion("v1");
545 microServiceInfo.setEnable_ssl(true);
546 microServiceInfo.setHost("host");
547 microServiceInfo.setPath("/api/apiTest4Path/v1");
548 microServiceInfo.setPublish_port("10081|10082");
549 microServiceInfo.setProtocol("REST");
550 microServiceInfo.setUrl("/api/apiTest/v1");
551 microServiceInfo.setVisualRange("0");
552 microServiceInfo.setLb_policy("ip_hash");
553 microServiceInfo.setStatus("1");
554 Set<Node> nodes = new HashSet<Node>();
555 nodes.add(new Node("10.74.148.88","8080"));
556 nodes.add(new Node("10.74.148.89","8080"));
557 microServiceInfo.setNodes(nodes);
559 return microServiceInfo;
563 private MicroServiceFullInfo buildMicroServiceFullInfo4PORTAL(){
565 MicroServiceFullInfo microServiceInfo=new MicroServiceFullInfo();
566 microServiceInfo.setServiceName("portalTest");
567 microServiceInfo.setVersion("v1");
568 microServiceInfo.setEnable_ssl(true);
569 microServiceInfo.setHost("host");
570 microServiceInfo.setPublish_port("10088");
571 microServiceInfo.setProtocol("HTTP");
572 microServiceInfo.setUrl("/portalTestUrl/v1");
573 microServiceInfo.setVisualRange("0");
574 microServiceInfo.setLb_policy("ip_hash");
575 microServiceInfo.setStatus("1");
576 microServiceInfo.setCustom(RouteUtil.CUSTOM_PORTAL);
577 Set<Node> nodes = new HashSet<Node>();
578 nodes.add(new Node("10.74.148.99","8080"));
579 microServiceInfo.setNodes(nodes);
581 return microServiceInfo;
584 private MicroServiceFullInfo buildMicroServiceFullInfo4IUI(){
585 MicroServiceFullInfo microServiceInfo=new MicroServiceFullInfo();
586 microServiceInfo.setServiceName("iuiTest-ns");
587 microServiceInfo.setNamespace("ns");
588 microServiceInfo.setVersion("v1");
589 microServiceInfo.setEnable_ssl(false);
590 microServiceInfo.setPublish_port("20081");
591 microServiceInfo.setProtocol("UI");
592 microServiceInfo.setUrl("/iui/iuiTest");
593 microServiceInfo.setVisualRange("1");
594 microServiceInfo.setStatus("1");
595 Set<Node> nodes = new HashSet<Node>();
596 nodes.add(new Node("10.74.148.88","8080"));
597 nodes.add(new Node("10.74.148.89","8080"));
598 microServiceInfo.setNodes(nodes);
600 return microServiceInfo;
603 private MicroServiceFullInfo buildMicroServiceFullInfo4IUI_path(){
604 MicroServiceFullInfo microServiceInfo=new MicroServiceFullInfo();
605 microServiceInfo.setServiceName("iuiTest");
606 microServiceInfo.setVersion("v1");
607 microServiceInfo.setEnable_ssl(true);
608 microServiceInfo.setHost("host");
609 microServiceInfo.setProtocol("UI");
610 microServiceInfo.setUrl("/iui/iuiTest");
611 microServiceInfo.setLb_policy("ip_hash");
612 microServiceInfo.setPublish_port("10081|10082");
613 microServiceInfo.setPath("/iui/iuiTest4Path");
614 microServiceInfo.setVisualRange("0");
615 microServiceInfo.setStatus("1");
616 Set<Node> nodes = new HashSet<Node>();
617 nodes.add(new Node("10.74.148.88","8080"));
618 nodes.add(new Node("10.74.148.89","8080"));
619 microServiceInfo.setNodes(nodes);
621 return microServiceInfo;
624 private MicroServiceFullInfo buildMicroServiceFullInfo4HTTP(){
625 MicroServiceFullInfo microServiceInfo=new MicroServiceFullInfo();
626 microServiceInfo.setServiceName("httpTest-ns");
627 microServiceInfo.setNamespace("ns");
628 microServiceInfo.setVersion("v1");
629 microServiceInfo.setEnable_ssl(false);
630 microServiceInfo.setPublish_port("20081");
631 microServiceInfo.setProtocol("HTTP");
632 microServiceInfo.setUrl("/httpTest");
633 microServiceInfo.setVisualRange("1");
634 microServiceInfo.setStatus("1");
635 Set<Node> nodes = new HashSet<Node>();
636 nodes.add(new Node("10.74.148.88","8080"));
637 nodes.add(new Node("10.74.148.89","8080"));
638 microServiceInfo.setNodes(nodes);
640 return microServiceInfo;
643 private MicroServiceFullInfo buildMicroServiceFullInfo4HTTP_path(){
644 MicroServiceFullInfo microServiceInfo=new MicroServiceFullInfo();
645 microServiceInfo.setServiceName("httpTest");
646 microServiceInfo.setVersion("v1");
647 microServiceInfo.setEnable_ssl(true);
648 microServiceInfo.setHost("host");
649 microServiceInfo.setPublish_port("20081");
650 microServiceInfo.setProtocol("HTTP");
651 microServiceInfo.setUrl("/httpTest");
652 microServiceInfo.setVisualRange("0");
653 microServiceInfo.setStatus("1");
654 microServiceInfo.setLb_policy("ip_hash");
655 microServiceInfo.setPublish_port("10081|10082");
656 microServiceInfo.setPath("/httpTest4Path");
657 Set<Node> nodes = new HashSet<Node>();
658 nodes.add(new Node("10.74.148.88","8080"));
659 nodes.add(new Node("10.74.148.89","8080"));
660 microServiceInfo.setNodes(nodes);
662 return microServiceInfo;