1 /*******************************************************************************
2 * Copyright 2016-2017 ZTE, Inc. and others.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 ******************************************************************************/
16 package org.onap.msb.apiroute.wrapper.serviceListener;
18 import java.lang.reflect.InvocationHandler;
19 import java.lang.reflect.Method;
20 import java.util.HashSet;
23 import org.junit.Assert;
24 import org.junit.Before;
25 import org.junit.BeforeClass;
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 import org.onap.msb.apiroute.ApiRouteAppConfig;
29 import org.onap.msb.apiroute.api.ApiRouteInfo;
30 import org.onap.msb.apiroute.api.CustomRouteInfo;
31 import org.onap.msb.apiroute.api.DiscoverInfo;
32 import org.onap.msb.apiroute.api.IuiRouteInfo;
33 import org.onap.msb.apiroute.api.MicroServiceFullInfo;
34 import org.onap.msb.apiroute.api.Node;
35 import org.onap.msb.apiroute.api.RouteServer;
36 import org.onap.msb.apiroute.api.exception.ExtendedNotFoundException;
37 import org.onap.msb.apiroute.wrapper.ApiRouteServiceWrapper;
38 import org.onap.msb.apiroute.wrapper.CustomRouteServiceWrapper;
39 import org.onap.msb.apiroute.wrapper.InitRouteServiceWrapper;
40 import org.onap.msb.apiroute.wrapper.IuiRouteServiceWrapper;
41 import org.onap.msb.apiroute.wrapper.dao.RedisAccessWrapper;
42 import org.onap.msb.apiroute.wrapper.serviceListener.RouteNotify;
43 import org.onap.msb.apiroute.wrapper.util.ConfigUtil;
44 import org.onap.msb.apiroute.wrapper.util.HttpClientUtil;
45 import org.onap.msb.apiroute.wrapper.util.JedisUtil;
46 import org.onap.msb.apiroute.wrapper.util.RouteUtil;
47 import org.powermock.api.mockito.PowerMockito;
48 import org.powermock.core.classloader.annotations.PowerMockIgnore;
49 import org.powermock.core.classloader.annotations.PrepareForTest;
50 import org.powermock.modules.junit4.PowerMockRunner;
52 import redis.clients.jedis.JedisPool;
53 import redis.clients.jedis.JedisPoolConfig;
55 import com.fiftyonred.mock_jedis.MockJedisPool;
57 @RunWith(PowerMockRunner.class)
58 @PrepareForTest({JedisUtil.class,ConfigUtil.class,HttpClientUtil.class, RedisAccessWrapper.class,})
59 @PowerMockIgnore({"javax.management.*"})
60 public class MicroServiceChangeListenerTest {
61 private static RouteNotify routeInstance;
62 private static ApiRouteServiceWrapper apiRouteServiceWrapper;
63 private static IuiRouteServiceWrapper iuiRouteServiceWrapper;
64 private static CustomRouteServiceWrapper customRouteServiceWrapper;
68 public static void setUpBeforeClass() throws Exception {
69 InitRouteServiceWrapper.getInstance().registerServiceChangeListener();
70 routeInstance=RouteNotify.getInstance();
71 apiRouteServiceWrapper=ApiRouteServiceWrapper.getInstance();
72 iuiRouteServiceWrapper=IuiRouteServiceWrapper.getInstance();
73 customRouteServiceWrapper=CustomRouteServiceWrapper.getInstance();
75 PowerMockito.mockStatic(System.class);
76 PowerMockito.when(System.getenv("ROUTE_WAY")).thenReturn("ip|domain");
77 ConfigUtil.getInstance().initRouteWay();
81 public void initReidsMock() throws Exception {
82 final JedisPool mockJedisPool = new MockJedisPool(new JedisPoolConfig(), "localhost");
83 PowerMockito.mockStatic(JedisUtil.class);
84 JedisUtil jedisUtil=PowerMockito.mock(JedisUtil.class);
85 PowerMockito.when(jedisUtil.borrowJedisInstance()).thenReturn(mockJedisPool.getResource());
87 PowerMockito.replace(PowerMockito.method(RedisAccessWrapper.class, "filterKeys")).with(new InvocationHandler() {
89 public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
90 return mockJedisPool.getResource().keys((String) args[0]);
96 public void test_noticeRouteListener4Update_api(){
98 routeInstance.noticeRouteListener4Update("apiTest-ns", "v1", buildMicroServiceFullInfo4API());
99 ApiRouteInfo apiRouteInfo=apiRouteServiceWrapper.getApiRouteInstance("apiTest-ns", "v1", "host", "20081", "ip");
101 Assert.assertNotNull(apiRouteInfo);
102 Assert.assertEquals("1", apiRouteInfo.getStatus());
104 routeInstance.noticeUpdateStatusListener(buildMicroServiceFullInfo4API(),"0");
105 apiRouteInfo=apiRouteServiceWrapper.getApiRouteInstance("apiTest-ns", "v1", "host", "20081", "ip");
106 Assert.assertEquals("0", apiRouteInfo.getStatus());
108 } catch (Exception e) {
109 Assert.fail("throw exception means error occured!" + e.getMessage());
114 public void test_noticeRouteListener4Update_iui(){
116 routeInstance.noticeRouteListener4Update("iuiTest-ns", "v1", buildMicroServiceFullInfo4IUI());
117 IuiRouteInfo iuiRouteInfo=iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest-ns", "host", "20081", "ip");
119 Assert.assertNotNull(iuiRouteInfo);
120 Assert.assertEquals("1", iuiRouteInfo.getStatus());
122 routeInstance.noticeUpdateStatusListener(buildMicroServiceFullInfo4IUI(),"0");
123 iuiRouteInfo=iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest-ns", "host", "20081", "ip");
124 Assert.assertEquals("0", iuiRouteInfo.getStatus());
126 } catch (Exception e) {
127 Assert.fail("throw exception means error occured!" + e.getMessage());
132 public void test_noticeRouteListener4Update_http(){
134 routeInstance.noticeRouteListener4Update("httpTest-ns", "v1", buildMicroServiceFullInfo4HTTP());
135 CustomRouteInfo customRouteInfo=customRouteServiceWrapper.getCustomRouteInstance("/httpTest-ns", "host", "20081", "ip");
136 Assert.assertNotNull(customRouteInfo);
137 Assert.assertEquals("1", customRouteInfo.getStatus());
139 routeInstance.noticeUpdateStatusListener(buildMicroServiceFullInfo4HTTP(),"0");
140 customRouteInfo=customRouteServiceWrapper.getCustomRouteInstance("/httpTest-ns", "host", "20081", "ip");
141 Assert.assertEquals("0", customRouteInfo.getStatus());
142 } catch (Exception e) {
143 Assert.fail("throw exception means error occured!" + e.getMessage());
148 public void test_noticeRouteListener4Add_del_api(){
150 MicroServiceFullInfo microServiceInfo =buildMicroServiceFullInfo4API();
151 routeInstance.noticeRouteListener4Add(microServiceInfo);
152 Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "20081", "ip"));
153 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/", "apitest-ns", "", "domain"));
155 routeInstance.noticeRouteListener4Delete(microServiceInfo);
157 } catch (Exception e) {
158 Assert.fail("throw exception means error occured!" + e.getMessage());
162 apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "20081", "ip");
163 Assert.fail("should not process to here.");
166 Assert.assertTrue(e instanceof ExtendedNotFoundException);
170 apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "apitest-ns", "", "domain");
171 Assert.fail("should not process to here.");
174 Assert.assertTrue(e instanceof ExtendedNotFoundException);
181 public void test_noticeRouteListener4Add_del_api_path(){
183 MicroServiceFullInfo microServiceInfo =buildMicroServiceFullInfo4API_path();
184 routeInstance.noticeRouteListener4Add(microServiceInfo);
185 Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "", "10081", "ip"));
186 Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "", "10082", "ip"));
187 Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "host", "", "domain"));
189 routeInstance.noticeRouteListener4Delete(microServiceInfo);
191 } catch (Exception e) {
192 Assert.fail("throw exception means error occured!" + e.getMessage());
196 apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "", "10081", "ip");
197 Assert.fail("should not process to here.");
200 Assert.assertTrue(e instanceof ExtendedNotFoundException);
204 apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "", "10082", "ip");
205 Assert.fail("should not process to here.");
208 Assert.assertTrue(e instanceof ExtendedNotFoundException);
212 apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "host", "", "domain");
213 Assert.fail("should not process to here.");
216 Assert.assertTrue(e instanceof ExtendedNotFoundException);
222 public void test_noticeRouteListener4Add_del_api_mutiPort(){
224 MicroServiceFullInfo microServiceInfo =buildMicroServiceFullInfo4API_path();
225 microServiceInfo.setPath("");
226 microServiceInfo.setHost("");
228 routeInstance.noticeRouteListener4Add(microServiceInfo);
229 Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "10081", "ip"));
230 Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "10082", "ip"));
231 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/", "apitest", "", "domain"));
233 routeInstance.noticeRouteListener4Delete(microServiceInfo);
235 } catch (Exception e) {
236 Assert.fail("throw exception means error occured!" + e.getMessage());
240 apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "10081", "ip");
241 Assert.fail("should not process to here.");
244 Assert.assertTrue(e instanceof ExtendedNotFoundException);
248 apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "10082", "ip");
249 Assert.fail("should not process to here.");
252 Assert.assertTrue(e instanceof ExtendedNotFoundException);
256 apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "apitest", "", "domain");
257 Assert.fail("should not process to here.");
260 Assert.assertTrue(e instanceof ExtendedNotFoundException);
266 public void test_noticeRouteListener4Add_del_iui(){
268 MicroServiceFullInfo microServiceInfo =buildMicroServiceFullInfo4IUI();
269 routeInstance.noticeRouteListener4Add(microServiceInfo);
270 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "20081", "ip"));
271 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/", "iuitest-ns", "", "domain"));
273 routeInstance.noticeRouteListener4Delete(microServiceInfo);
275 } catch (Exception e) {
276 Assert.fail("throw exception means error occured!" + e.getMessage());
280 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "20081", "ip");
281 Assert.fail("should not process to here.");
284 Assert.assertTrue(e instanceof ExtendedNotFoundException);
288 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "iuitest-ns", "", "domain");
289 Assert.fail("should not process to here.");
292 Assert.assertTrue(e instanceof ExtendedNotFoundException);
298 public void test_noticeRouteListener4Add_del_iui_path(){
300 MicroServiceFullInfo microServiceInfo =buildMicroServiceFullInfo4IUI_path();
301 routeInstance.noticeRouteListener4Add(microServiceInfo);
302 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10081", "ip"));
303 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10082", "ip"));
304 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "host", "", "domain"));
306 routeInstance.noticeRouteListener4Delete(microServiceInfo);
307 } catch (Exception e) {
308 Assert.fail("throw exception means error occured!" + e.getMessage());
312 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10081", "ip");
313 Assert.fail("should not process to here.");
316 Assert.assertTrue(e instanceof ExtendedNotFoundException);
320 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10082", "ip");
321 Assert.fail("should not process to here.");
324 Assert.assertTrue(e instanceof ExtendedNotFoundException);
328 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "host", "", "domain");
329 Assert.fail("should not process to here.");
332 Assert.assertTrue(e instanceof ExtendedNotFoundException);
339 public void test_noticeRouteListener4Add_del_iui_mutiPort(){
341 MicroServiceFullInfo microServiceInfo =buildMicroServiceFullInfo4IUI_path();
342 microServiceInfo.setPath("");
343 microServiceInfo.setHost("");
345 routeInstance.noticeRouteListener4Add(microServiceInfo);
346 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10081", "ip"));
347 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10082", "ip"));
348 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/", "iuitest", "", "domain"));
350 routeInstance.noticeRouteListener4Delete(microServiceInfo);
351 } catch (Exception e) {
352 Assert.fail("throw exception means error occured!" + e.getMessage());
356 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10081", "ip");
357 Assert.fail("should not process to here.");
360 Assert.assertTrue(e instanceof ExtendedNotFoundException);
364 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10082", "ip");
365 Assert.fail("should not process to here.");
368 Assert.assertTrue(e instanceof ExtendedNotFoundException);
372 customRouteServiceWrapper.getCustomRouteInstance("/", "iuitest", "", "domain");
373 Assert.fail("should not process to here.");
376 Assert.assertTrue(e instanceof ExtendedNotFoundException);
382 public void test_noticeRouteListener4Add_del_http(){
384 MicroServiceFullInfo microServiceInfo=buildMicroServiceFullInfo4HTTP();
385 routeInstance.noticeRouteListener4Add(microServiceInfo);
386 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "20081", "ip"));
387 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "httptest-ns", "", "domain"));
389 routeInstance.noticeRouteListener4Delete(microServiceInfo);
390 } catch (Exception e) {
391 Assert.fail("throw exception means error occured!" + e.getMessage());
395 customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "20081", "ip");
396 Assert.fail("should not process to here.");
399 Assert.assertTrue(e instanceof ExtendedNotFoundException);
403 customRouteServiceWrapper.getCustomRouteInstance("/httpTest", "httptest-ns", "", "domain");
404 Assert.fail("should not process to here.");
407 Assert.assertTrue(e instanceof ExtendedNotFoundException);
413 public void test_noticeRouteListener4Add_del_http_path(){
415 MicroServiceFullInfo microServiceInfo=buildMicroServiceFullInfo4HTTP_path();
416 routeInstance.noticeRouteListener4Add(microServiceInfo);
417 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10081", "ip"));
418 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10082", "ip"));
419 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "host", "", "domain"));
421 routeInstance.noticeRouteListener4Delete(microServiceInfo);
422 } catch (Exception e) {
423 Assert.fail("throw exception means error occured!" + e.getMessage());
427 customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10081", "ip");
428 Assert.fail("should not process to here.");
431 Assert.assertTrue(e instanceof ExtendedNotFoundException);
435 customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10082", "ip");
436 Assert.fail("should not process to here.");
439 Assert.assertTrue(e instanceof ExtendedNotFoundException);
443 customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "host", "", "domain");
444 Assert.fail("should not process to here.");
447 Assert.assertTrue(e instanceof ExtendedNotFoundException);
454 public void test_noticeRouteListener4Add_del_http_mutiPort(){
456 MicroServiceFullInfo microServiceInfo=buildMicroServiceFullInfo4HTTP_path();
457 microServiceInfo.setPath("");
458 microServiceInfo.setHost("");
460 routeInstance.noticeRouteListener4Add(microServiceInfo);
461 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10081", "ip"));
462 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10082", "ip"));
463 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "httptest", "", "domain"));
465 routeInstance.noticeRouteListener4Delete(microServiceInfo);
466 } catch (Exception e) {
467 Assert.fail("throw exception means error occured!" + e.getMessage());
471 customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10081", "ip");
472 Assert.fail("should not process to here.");
475 Assert.assertTrue(e instanceof ExtendedNotFoundException);
479 customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10082", "ip");
480 Assert.fail("should not process to here.");
483 Assert.assertTrue(e instanceof ExtendedNotFoundException);
487 customRouteServiceWrapper.getCustomRouteInstance("/httpTest", "httptest", "", "domain");
488 Assert.fail("should not process to here.");
491 Assert.assertTrue(e instanceof ExtendedNotFoundException);
498 public void test_noticeRouteListener4Add_portal(){
500 PowerMockito.mockStatic(System.class);
501 PowerMockito.when(System.getenv("SDCLIENT_IP")).thenReturn("127.0.0.1");
502 ApiRouteAppConfig configuration=new ApiRouteAppConfig();
504 DiscoverInfo discoverInfo=new DiscoverInfo();
505 discoverInfo.setEnabled(true);
506 discoverInfo.setIp("127.0.0.2");
507 discoverInfo.setPort(10081);
508 configuration.setDiscoverInfo(discoverInfo);
509 ConfigUtil.getInstance().initDiscoverInfo(configuration);
512 PowerMockito.mockStatic(HttpClientUtil.class);
513 String publishUrl="http://127.0.0.1:10081/api/microservices/v1/services/portalTest/version/v1/allpublishaddress?namespace=&visualRange=0";
514 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\"}]";
515 PowerMockito.when(HttpClientUtil.httpGet(publishUrl)).thenReturn(resultJson);
517 MicroServiceFullInfo microServiceInfo=buildMicroServiceFullInfo4PORTAL();
519 routeInstance.noticeRouteListener4Add(microServiceInfo);
521 CustomRouteInfo routeInfo_ip=customRouteServiceWrapper.getCustomRouteInstance("/portalTest/v1", "", "10088", "ip");
522 RouteServer[] servers_ip = new RouteServer[]{new RouteServer("10.74.148.99","8080")};
523 Assert.assertArrayEquals(servers_ip, routeInfo_ip.getServers());
525 CustomRouteInfo routeInfo_domain=customRouteServiceWrapper.getCustomRouteInstance("/portalTest/v1", "host", "", "domain");
526 RouteServer[] servers_domain = new RouteServer[]{new RouteServer("10.74.165.246","443")};
528 Assert.assertArrayEquals(servers_domain, routeInfo_domain.getServers());
530 } catch (Exception e) {
531 Assert.fail("throw exception means error occured!" + e.getMessage());
537 private MicroServiceFullInfo buildMicroServiceFullInfo4API(){
538 MicroServiceFullInfo microServiceInfo=new MicroServiceFullInfo();
539 microServiceInfo.setServiceName("apiTest-ns");
540 microServiceInfo.setVersion("v1");
541 microServiceInfo.setEnable_ssl(false);
542 microServiceInfo.setPublish_port("20081");
543 microServiceInfo.setProtocol("REST");
544 microServiceInfo.setUrl("/api/apiTest/v1");
545 microServiceInfo.setVisualRange("1");
546 microServiceInfo.setStatus("1");
547 microServiceInfo.setNamespace("ns");
548 Set<Node> nodes = new HashSet<Node>();
549 nodes.add(new Node("10.74.148.88","8080"));
550 nodes.add(new Node("10.74.148.89","8080"));
551 microServiceInfo.setNodes(nodes);
553 return microServiceInfo;
556 private MicroServiceFullInfo buildMicroServiceFullInfo4API_path(){
557 MicroServiceFullInfo microServiceInfo=new MicroServiceFullInfo();
558 microServiceInfo.setServiceName("apiTest");
559 microServiceInfo.setVersion("v1");
560 microServiceInfo.setEnable_ssl(true);
561 microServiceInfo.setHost("host");
562 microServiceInfo.setPath("/api/apiTest4Path/v1");
563 microServiceInfo.setPublish_port("10081|10082");
564 microServiceInfo.setProtocol("REST");
565 microServiceInfo.setUrl("/api/apiTest/v1");
566 microServiceInfo.setVisualRange("0");
567 microServiceInfo.setLb_policy("ip_hash");
568 microServiceInfo.setStatus("1");
569 Set<Node> nodes = new HashSet<Node>();
570 nodes.add(new Node("10.74.148.88","8080"));
571 nodes.add(new Node("10.74.148.89","8080"));
572 microServiceInfo.setNodes(nodes);
574 return microServiceInfo;
578 private MicroServiceFullInfo buildMicroServiceFullInfo4PORTAL(){
580 MicroServiceFullInfo microServiceInfo=new MicroServiceFullInfo();
581 microServiceInfo.setServiceName("portalTest");
582 microServiceInfo.setVersion("v1");
583 microServiceInfo.setEnable_ssl(true);
584 microServiceInfo.setHost("host");
585 microServiceInfo.setPublish_port("10088");
586 microServiceInfo.setProtocol("HTTP");
587 microServiceInfo.setUrl("/portalTestUrl/v1");
588 microServiceInfo.setVisualRange("0");
589 microServiceInfo.setLb_policy("ip_hash");
590 microServiceInfo.setStatus("1");
591 microServiceInfo.setCustom(RouteUtil.CUSTOM_PORTAL);
592 Set<Node> nodes = new HashSet<Node>();
593 nodes.add(new Node("10.74.148.99","8080"));
594 microServiceInfo.setNodes(nodes);
596 return microServiceInfo;
599 private MicroServiceFullInfo buildMicroServiceFullInfo4IUI(){
600 MicroServiceFullInfo microServiceInfo=new MicroServiceFullInfo();
601 microServiceInfo.setServiceName("iuiTest-ns");
602 microServiceInfo.setNamespace("ns");
603 microServiceInfo.setVersion("v1");
604 microServiceInfo.setEnable_ssl(false);
605 microServiceInfo.setPublish_port("20081");
606 microServiceInfo.setProtocol("UI");
607 microServiceInfo.setUrl("/iui/iuiTest");
608 microServiceInfo.setVisualRange("1");
609 microServiceInfo.setStatus("1");
610 Set<Node> nodes = new HashSet<Node>();
611 nodes.add(new Node("10.74.148.88","8080"));
612 nodes.add(new Node("10.74.148.89","8080"));
613 microServiceInfo.setNodes(nodes);
615 return microServiceInfo;
618 private MicroServiceFullInfo buildMicroServiceFullInfo4IUI_path(){
619 MicroServiceFullInfo microServiceInfo=new MicroServiceFullInfo();
620 microServiceInfo.setServiceName("iuiTest");
621 microServiceInfo.setVersion("v1");
622 microServiceInfo.setEnable_ssl(true);
623 microServiceInfo.setHost("host");
624 microServiceInfo.setProtocol("UI");
625 microServiceInfo.setUrl("/iui/iuiTest");
626 microServiceInfo.setLb_policy("ip_hash");
627 microServiceInfo.setPublish_port("10081|10082");
628 microServiceInfo.setPath("/iui/iuiTest4Path");
629 microServiceInfo.setVisualRange("0");
630 microServiceInfo.setStatus("1");
631 Set<Node> nodes = new HashSet<Node>();
632 nodes.add(new Node("10.74.148.88","8080"));
633 nodes.add(new Node("10.74.148.89","8080"));
634 microServiceInfo.setNodes(nodes);
636 return microServiceInfo;
639 private MicroServiceFullInfo buildMicroServiceFullInfo4HTTP(){
640 MicroServiceFullInfo microServiceInfo=new MicroServiceFullInfo();
641 microServiceInfo.setServiceName("httpTest-ns");
642 microServiceInfo.setNamespace("ns");
643 microServiceInfo.setVersion("v1");
644 microServiceInfo.setEnable_ssl(false);
645 microServiceInfo.setPublish_port("20081");
646 microServiceInfo.setProtocol("HTTP");
647 microServiceInfo.setUrl("/httpTest");
648 microServiceInfo.setVisualRange("1");
649 microServiceInfo.setStatus("1");
650 Set<Node> nodes = new HashSet<Node>();
651 nodes.add(new Node("10.74.148.88","8080"));
652 nodes.add(new Node("10.74.148.89","8080"));
653 microServiceInfo.setNodes(nodes);
655 return microServiceInfo;
658 private MicroServiceFullInfo buildMicroServiceFullInfo4HTTP_path(){
659 MicroServiceFullInfo microServiceInfo=new MicroServiceFullInfo();
660 microServiceInfo.setServiceName("httpTest");
661 microServiceInfo.setVersion("v1");
662 microServiceInfo.setEnable_ssl(true);
663 microServiceInfo.setHost("host");
664 microServiceInfo.setPublish_port("20081");
665 microServiceInfo.setProtocol("HTTP");
666 microServiceInfo.setUrl("/httpTest");
667 microServiceInfo.setVisualRange("0");
668 microServiceInfo.setStatus("1");
669 microServiceInfo.setLb_policy("ip_hash");
670 microServiceInfo.setPublish_port("10081|10082");
671 microServiceInfo.setPath("/httpTest4Path");
672 Set<Node> nodes = new HashSet<Node>();
673 nodes.add(new Node("10.74.148.88","8080"));
674 nodes.add(new Node("10.74.148.89","8080"));
675 microServiceInfo.setNodes(nodes);
677 return microServiceInfo;