1 /*******************************************************************************
2 * Copyright 2016-2017 ZTE, Inc. and others.
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 * in compliance with the License. You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software distributed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 * or implied. See the License for the specific language governing permissions and limitations under
13 ******************************************************************************/
14 package org.onap.msb.apiroute.wrapper.serviceListener;
16 import java.lang.reflect.InvocationHandler;
17 import java.lang.reflect.Method;
18 import java.util.HashSet;
21 import org.junit.Assert;
22 import org.junit.Before;
23 import org.junit.BeforeClass;
24 import org.junit.Test;
25 import org.junit.runner.RunWith;
26 import org.onap.msb.apiroute.ApiRouteAppConfig;
27 import org.onap.msb.apiroute.api.ApiRouteInfo;
28 import org.onap.msb.apiroute.api.CustomRouteInfo;
29 import org.onap.msb.apiroute.api.DiscoverInfo;
30 import org.onap.msb.apiroute.api.IuiRouteInfo;
31 import org.onap.msb.apiroute.api.MicroServiceFullInfo;
32 import org.onap.msb.apiroute.api.Node;
33 import org.onap.msb.apiroute.api.RouteServer;
34 import org.onap.msb.apiroute.api.exception.ExtendedNotFoundException;
35 import org.onap.msb.apiroute.wrapper.ApiRouteServiceWrapper;
36 import org.onap.msb.apiroute.wrapper.CustomRouteServiceWrapper;
37 import org.onap.msb.apiroute.wrapper.InitRouteServiceWrapper;
38 import org.onap.msb.apiroute.wrapper.IuiRouteServiceWrapper;
39 import org.onap.msb.apiroute.wrapper.dao.RedisAccessWrapper;
40 import org.onap.msb.apiroute.wrapper.util.ConfigUtil;
41 import org.onap.msb.apiroute.wrapper.util.HttpClientUtil;
42 import org.onap.msb.apiroute.wrapper.util.JedisUtil;
43 import org.onap.msb.apiroute.wrapper.util.RouteUtil;
44 import org.powermock.api.mockito.PowerMockito;
45 import org.powermock.core.classloader.annotations.PowerMockIgnore;
46 import org.powermock.core.classloader.annotations.PrepareForTest;
47 import org.powermock.modules.junit4.PowerMockRunner;
49 import com.fiftyonred.mock_jedis.MockJedisPool;
51 import redis.clients.jedis.JedisPool;
52 import redis.clients.jedis.JedisPoolConfig;
54 @RunWith(PowerMockRunner.class)
55 @PrepareForTest({JedisUtil.class, ConfigUtil.class, HttpClientUtil.class, RedisAccessWrapper.class,})
56 @PowerMockIgnore({"javax.management.*"})
57 public class MicroServiceChangeListenerTest {
58 private static RouteNotify routeInstance;
59 private static ApiRouteServiceWrapper apiRouteServiceWrapper;
60 private static IuiRouteServiceWrapper iuiRouteServiceWrapper;
61 private static CustomRouteServiceWrapper customRouteServiceWrapper;
65 public static void setUpBeforeClass() throws Exception {
66 InitRouteServiceWrapper.getInstance().registerServiceChangeListener();
67 routeInstance = RouteNotify.getInstance();
68 apiRouteServiceWrapper = ApiRouteServiceWrapper.getInstance();
69 iuiRouteServiceWrapper = IuiRouteServiceWrapper.getInstance();
70 customRouteServiceWrapper = CustomRouteServiceWrapper.getInstance();
72 PowerMockito.mockStatic(System.class);
73 PowerMockito.when(System.getenv("ROUTE_WAY")).thenReturn("ip|domain");
74 ConfigUtil.getInstance().initRouteWay();
78 public void initReidsMock() throws Exception {
79 final JedisPool mockJedisPool = new MockJedisPool(new JedisPoolConfig(), "localhost");
80 PowerMockito.mockStatic(JedisUtil.class);
81 JedisUtil jedisUtil = PowerMockito.mock(JedisUtil.class);
82 PowerMockito.when(jedisUtil.borrowJedisInstance()).thenReturn(mockJedisPool.getResource());
84 PowerMockito.replace(PowerMockito.method(RedisAccessWrapper.class, "filterKeys")).with(new InvocationHandler() {
86 public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
87 return mockJedisPool.getResource().keys((String) args[0]);
93 public void test_noticeRouteListener4Update_api() {
95 routeInstance.noticeRouteListener4Update("apiTest-ns", "v1", buildMicroServiceFullInfo4API());
96 ApiRouteInfo apiRouteInfo =
97 apiRouteServiceWrapper.getApiRouteInstance("apiTest-ns", "v1", "host", "20081", "ip");
99 Assert.assertNotNull(apiRouteInfo);
100 Assert.assertEquals("1", apiRouteInfo.getStatus());
102 routeInstance.noticeUpdateStatusListener(buildMicroServiceFullInfo4API(), "0");
103 apiRouteInfo = apiRouteServiceWrapper.getApiRouteInstance("apiTest-ns", "v1", "host", "20081", "ip");
104 Assert.assertEquals("0", apiRouteInfo.getStatus());
106 } catch (Exception e) {
107 Assert.fail("throw exception means error occured!" + e.getMessage());
112 public void test_noticeRouteListener4Update_iui() {
114 routeInstance.noticeRouteListener4Update("iuiTest-ns", "v1", buildMicroServiceFullInfo4IUI());
115 IuiRouteInfo iuiRouteInfo = iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest-ns", "host", "20081", "ip");
117 Assert.assertNotNull(iuiRouteInfo);
118 Assert.assertEquals("1", iuiRouteInfo.getStatus());
120 routeInstance.noticeUpdateStatusListener(buildMicroServiceFullInfo4IUI(), "0");
121 iuiRouteInfo = iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest-ns", "host", "20081", "ip");
122 Assert.assertEquals("0", iuiRouteInfo.getStatus());
124 } catch (Exception e) {
125 Assert.fail("throw exception means error occured!" + e.getMessage());
130 public void test_noticeRouteListener4Update_http() {
132 routeInstance.noticeRouteListener4Update("httpTest-ns", "v1", buildMicroServiceFullInfo4HTTP());
133 CustomRouteInfo customRouteInfo =
134 customRouteServiceWrapper.getCustomRouteInstance("/httpTest-ns", "host", "20081", "ip");
135 Assert.assertNotNull(customRouteInfo);
136 Assert.assertEquals("1", customRouteInfo.getStatus());
138 routeInstance.noticeUpdateStatusListener(buildMicroServiceFullInfo4HTTP(), "0");
139 customRouteInfo = customRouteServiceWrapper.getCustomRouteInstance("/httpTest-ns", "host", "20081", "ip");
140 Assert.assertEquals("0", customRouteInfo.getStatus());
141 } catch (Exception e) {
142 Assert.fail("throw exception means error occured!" + e.getMessage());
147 public void test_noticeRouteListener4Add_del_api() {
149 MicroServiceFullInfo microServiceInfo = buildMicroServiceFullInfo4API();
150 routeInstance.noticeRouteListener4Add(microServiceInfo);
151 Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "20081", "ip"));
152 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/", "apitest-ns", "", "domain"));
154 routeInstance.noticeRouteListener4Delete(microServiceInfo);
156 } catch (Exception e) {
157 Assert.fail("throw exception means error occured!" + e.getMessage());
161 apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "20081", "ip");
162 Assert.fail("should not process to here.");
163 } catch (Exception e) {
164 Assert.assertTrue(e instanceof ExtendedNotFoundException);
168 apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "apitest-ns", "", "domain");
169 Assert.fail("should not process to here.");
170 } catch (Exception e) {
171 Assert.assertTrue(e instanceof ExtendedNotFoundException);
178 public void test_noticeRouteListener4Add_del_api_path() {
180 MicroServiceFullInfo microServiceInfo = buildMicroServiceFullInfo4API_path();
181 routeInstance.noticeRouteListener4Add(microServiceInfo);
182 Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "", "10081", "ip"));
183 Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "", "10082", "ip"));
184 Assert.assertNotNull(
185 apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "host", "", "domain"));
187 routeInstance.noticeRouteListener4Delete(microServiceInfo);
189 } catch (Exception e) {
190 Assert.fail("throw exception means error occured!" + e.getMessage());
194 apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "", "10081", "ip");
195 Assert.fail("should not process to here.");
196 } catch (Exception e) {
197 Assert.assertTrue(e instanceof ExtendedNotFoundException);
201 apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "", "10082", "ip");
202 Assert.fail("should not process to here.");
203 } catch (Exception e) {
204 Assert.assertTrue(e instanceof ExtendedNotFoundException);
208 apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "host", "", "domain");
209 Assert.fail("should not process to here.");
210 } catch (Exception e) {
211 Assert.assertTrue(e instanceof ExtendedNotFoundException);
217 public void test_noticeRouteListener4Add_del_api_mutiPort() {
219 MicroServiceFullInfo microServiceInfo = buildMicroServiceFullInfo4API_path();
220 microServiceInfo.setPath("");
221 microServiceInfo.setHost("");
223 routeInstance.noticeRouteListener4Add(microServiceInfo);
224 Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "10081", "ip"));
225 Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "10082", "ip"));
226 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/", "apitest", "", "domain"));
228 routeInstance.noticeRouteListener4Delete(microServiceInfo);
230 } catch (Exception e) {
231 Assert.fail("throw exception means error occured!" + e.getMessage());
235 apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "10081", "ip");
236 Assert.fail("should not process to here.");
237 } catch (Exception e) {
238 Assert.assertTrue(e instanceof ExtendedNotFoundException);
242 apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "10082", "ip");
243 Assert.fail("should not process to here.");
244 } catch (Exception e) {
245 Assert.assertTrue(e instanceof ExtendedNotFoundException);
249 apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "apitest", "", "domain");
250 Assert.fail("should not process to here.");
251 } catch (Exception e) {
252 Assert.assertTrue(e instanceof ExtendedNotFoundException);
258 public void test_noticeRouteListener4Add_del_iui() {
260 MicroServiceFullInfo microServiceInfo = buildMicroServiceFullInfo4IUI();
261 routeInstance.noticeRouteListener4Add(microServiceInfo);
262 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "20081", "ip"));
263 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/", "iuitest-ns", "", "domain"));
265 routeInstance.noticeRouteListener4Delete(microServiceInfo);
267 } catch (Exception e) {
268 Assert.fail("throw exception means error occured!" + e.getMessage());
272 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "20081", "ip");
273 Assert.fail("should not process to here.");
274 } catch (Exception e) {
275 Assert.assertTrue(e instanceof ExtendedNotFoundException);
279 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "iuitest-ns", "", "domain");
280 Assert.fail("should not process to here.");
281 } catch (Exception e) {
282 Assert.assertTrue(e instanceof ExtendedNotFoundException);
288 public void test_noticeRouteListener4Add_del_iui_path() {
290 MicroServiceFullInfo microServiceInfo = buildMicroServiceFullInfo4IUI_path();
291 routeInstance.noticeRouteListener4Add(microServiceInfo);
292 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10081", "ip"));
293 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10082", "ip"));
294 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "host", "", "domain"));
296 routeInstance.noticeRouteListener4Delete(microServiceInfo);
297 } catch (Exception e) {
298 Assert.fail("throw exception means error occured!" + e.getMessage());
302 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10081", "ip");
303 Assert.fail("should not process to here.");
304 } catch (Exception e) {
305 Assert.assertTrue(e instanceof ExtendedNotFoundException);
309 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10082", "ip");
310 Assert.fail("should not process to here.");
311 } catch (Exception e) {
312 Assert.assertTrue(e instanceof ExtendedNotFoundException);
316 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "host", "", "domain");
317 Assert.fail("should not process to here.");
318 } catch (Exception e) {
319 Assert.assertTrue(e instanceof ExtendedNotFoundException);
326 public void test_noticeRouteListener4Add_del_iui_mutiPort() {
328 MicroServiceFullInfo microServiceInfo = buildMicroServiceFullInfo4IUI_path();
329 microServiceInfo.setPath("");
330 microServiceInfo.setHost("");
332 routeInstance.noticeRouteListener4Add(microServiceInfo);
333 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10081", "ip"));
334 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10082", "ip"));
335 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/", "iuitest", "", "domain"));
337 routeInstance.noticeRouteListener4Delete(microServiceInfo);
338 } catch (Exception e) {
339 Assert.fail("throw exception means error occured!" + e.getMessage());
343 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10081", "ip");
344 Assert.fail("should not process to here.");
345 } catch (Exception e) {
346 Assert.assertTrue(e instanceof ExtendedNotFoundException);
350 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10082", "ip");
351 Assert.fail("should not process to here.");
352 } catch (Exception e) {
353 Assert.assertTrue(e instanceof ExtendedNotFoundException);
357 customRouteServiceWrapper.getCustomRouteInstance("/", "iuitest", "", "domain");
358 Assert.fail("should not process to here.");
359 } catch (Exception e) {
360 Assert.assertTrue(e instanceof ExtendedNotFoundException);
366 public void test_noticeRouteListener4Add_del_http() {
368 MicroServiceFullInfo microServiceInfo = buildMicroServiceFullInfo4HTTP();
369 routeInstance.noticeRouteListener4Add(microServiceInfo);
370 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "20081", "ip"));
371 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "httptest-ns", "",
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.");
382 } catch (Exception e) {
383 Assert.assertTrue(e instanceof ExtendedNotFoundException);
387 customRouteServiceWrapper.getCustomRouteInstance("/httpTest", "httptest-ns", "", "domain");
388 Assert.fail("should not process to here.");
389 } catch (Exception e) {
390 Assert.assertTrue(e instanceof ExtendedNotFoundException);
396 public void test_noticeRouteListener4Add_del_http_path() {
398 MicroServiceFullInfo microServiceInfo = buildMicroServiceFullInfo4HTTP_path();
399 routeInstance.noticeRouteListener4Add(microServiceInfo);
400 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10081", "ip"));
401 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10082", "ip"));
402 Assert.assertNotNull(
403 customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "host", "", "domain"));
405 routeInstance.noticeRouteListener4Delete(microServiceInfo);
406 } catch (Exception e) {
407 Assert.fail("throw exception means error occured!" + e.getMessage());
411 customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10081", "ip");
412 Assert.fail("should not process to here.");
413 } catch (Exception e) {
414 Assert.assertTrue(e instanceof ExtendedNotFoundException);
418 customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10082", "ip");
419 Assert.fail("should not process to here.");
420 } catch (Exception e) {
421 Assert.assertTrue(e instanceof ExtendedNotFoundException);
425 customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "host", "", "domain");
426 Assert.fail("should not process to here.");
427 } catch (Exception e) {
428 Assert.assertTrue(e instanceof ExtendedNotFoundException);
435 public void test_noticeRouteListener4Add_del_http_mutiPort() {
437 MicroServiceFullInfo microServiceInfo = buildMicroServiceFullInfo4HTTP_path();
438 microServiceInfo.setPath("");
439 microServiceInfo.setHost("");
441 routeInstance.noticeRouteListener4Add(microServiceInfo);
442 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10081", "ip"));
443 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10082", "ip"));
444 Assert.assertNotNull(
445 customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "httptest", "", "domain"));
447 routeInstance.noticeRouteListener4Delete(microServiceInfo);
448 } catch (Exception e) {
449 Assert.fail("throw exception means error occured!" + e.getMessage());
453 customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10081", "ip");
454 Assert.fail("should not process to here.");
455 } catch (Exception e) {
456 Assert.assertTrue(e instanceof ExtendedNotFoundException);
460 customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10082", "ip");
461 Assert.fail("should not process to here.");
462 } catch (Exception e) {
463 Assert.assertTrue(e instanceof ExtendedNotFoundException);
467 customRouteServiceWrapper.getCustomRouteInstance("/httpTest", "httptest", "", "domain");
468 Assert.fail("should not process to here.");
469 } catch (Exception e) {
470 Assert.assertTrue(e instanceof ExtendedNotFoundException);
477 public void test_noticeRouteListener4Add_portal() {
479 PowerMockito.mockStatic(System.class);
480 PowerMockito.when(System.getenv("SDCLIENT_IP")).thenReturn("127.0.0.1");
481 ApiRouteAppConfig configuration = new ApiRouteAppConfig();
483 DiscoverInfo discoverInfo = new DiscoverInfo();
484 discoverInfo.setEnabled(true);
485 discoverInfo.setIp("127.0.0.2");
486 discoverInfo.setPort(10081);
487 configuration.setDiscoverInfo(discoverInfo);
488 ConfigUtil.getInstance().initDiscoverInfo(configuration);
491 PowerMockito.mockStatic(HttpClientUtil.class);
493 "http://127.0.0.1:10081/api/microservices/v1/services/portalTest/version/v1/allpublishaddress?namespace=&visualRange=0";
495 "[{\"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\"}]";
496 PowerMockito.when(HttpClientUtil.httpGet(publishUrl)).thenReturn(resultJson);
498 MicroServiceFullInfo microServiceInfo = buildMicroServiceFullInfo4PORTAL();
500 routeInstance.noticeRouteListener4Add(microServiceInfo);
502 CustomRouteInfo routeInfo_ip =
503 customRouteServiceWrapper.getCustomRouteInstance("/portalTest/v1", "", "10088", "ip");
504 RouteServer[] servers_ip = new RouteServer[] {new RouteServer("10.74.148.99", "8080")};
505 Assert.assertArrayEquals(servers_ip, routeInfo_ip.getServers());
507 CustomRouteInfo routeInfo_domain =
508 customRouteServiceWrapper.getCustomRouteInstance("/portalTest/v1", "host", "", "domain");
509 RouteServer[] servers_domain = new RouteServer[] {new RouteServer("10.74.165.246", "443")};
511 Assert.assertArrayEquals(servers_domain, routeInfo_domain.getServers());
513 } catch (Exception e) {
514 Assert.fail("throw exception means error occured!" + e.getMessage());
520 private MicroServiceFullInfo buildMicroServiceFullInfo4API() {
521 MicroServiceFullInfo microServiceInfo = new MicroServiceFullInfo();
522 microServiceInfo.setServiceName("apiTest-ns");
523 microServiceInfo.setVersion("v1");
524 microServiceInfo.setEnable_ssl(false);
525 microServiceInfo.setPublish_port("20081");
526 microServiceInfo.setProtocol("REST");
527 microServiceInfo.setUrl("/api/apiTest/v1");
528 microServiceInfo.setVisualRange("1");
529 microServiceInfo.setStatus("1");
530 microServiceInfo.setNamespace("ns");
531 Set<Node> nodes = new HashSet<Node>();
532 nodes.add(new Node("10.74.148.88", "8080"));
533 nodes.add(new Node("10.74.148.89", "8080"));
534 microServiceInfo.setNodes(nodes);
536 return microServiceInfo;
539 private MicroServiceFullInfo buildMicroServiceFullInfo4API_path() {
540 MicroServiceFullInfo microServiceInfo = new MicroServiceFullInfo();
541 microServiceInfo.setServiceName("apiTest");
542 microServiceInfo.setVersion("v1");
543 microServiceInfo.setEnable_ssl(true);
544 microServiceInfo.setHost("host");
545 microServiceInfo.setPath("/api/apiTest4Path/v1");
546 microServiceInfo.setPublish_port("10081|10082");
547 microServiceInfo.setProtocol("REST");
548 microServiceInfo.setUrl("/api/apiTest/v1");
549 microServiceInfo.setVisualRange("0");
550 microServiceInfo.setLb_policy("ip_hash");
551 microServiceInfo.setStatus("1");
552 Set<Node> nodes = new HashSet<Node>();
553 nodes.add(new Node("10.74.148.88", "8080"));
554 nodes.add(new Node("10.74.148.89", "8080"));
555 microServiceInfo.setNodes(nodes);
557 return microServiceInfo;
561 private MicroServiceFullInfo buildMicroServiceFullInfo4PORTAL() {
563 MicroServiceFullInfo microServiceInfo = new MicroServiceFullInfo();
564 microServiceInfo.setServiceName("portalTest");
565 microServiceInfo.setVersion("v1");
566 microServiceInfo.setEnable_ssl(true);
567 microServiceInfo.setHost("host");
568 microServiceInfo.setPublish_port("10088");
569 microServiceInfo.setProtocol("HTTP");
570 microServiceInfo.setUrl("/portalTestUrl/v1");
571 microServiceInfo.setVisualRange("0");
572 microServiceInfo.setLb_policy("ip_hash");
573 microServiceInfo.setStatus("1");
574 microServiceInfo.setCustom(RouteUtil.CUSTOM_PORTAL);
575 Set<Node> nodes = new HashSet<Node>();
576 nodes.add(new Node("10.74.148.99", "8080"));
577 microServiceInfo.setNodes(nodes);
579 return microServiceInfo;
582 private MicroServiceFullInfo buildMicroServiceFullInfo4IUI() {
583 MicroServiceFullInfo microServiceInfo = new MicroServiceFullInfo();
584 microServiceInfo.setServiceName("iuiTest-ns");
585 microServiceInfo.setNamespace("ns");
586 microServiceInfo.setVersion("v1");
587 microServiceInfo.setEnable_ssl(false);
588 microServiceInfo.setPublish_port("20081");
589 microServiceInfo.setProtocol("UI");
590 microServiceInfo.setUrl("/iui/iuiTest");
591 microServiceInfo.setVisualRange("1");
592 microServiceInfo.setStatus("1");
593 Set<Node> nodes = new HashSet<Node>();
594 nodes.add(new Node("10.74.148.88", "8080"));
595 nodes.add(new Node("10.74.148.89", "8080"));
596 microServiceInfo.setNodes(nodes);
598 return microServiceInfo;
601 private MicroServiceFullInfo buildMicroServiceFullInfo4IUI_path() {
602 MicroServiceFullInfo microServiceInfo = new MicroServiceFullInfo();
603 microServiceInfo.setServiceName("iuiTest");
604 microServiceInfo.setVersion("v1");
605 microServiceInfo.setEnable_ssl(true);
606 microServiceInfo.setHost("host");
607 microServiceInfo.setProtocol("UI");
608 microServiceInfo.setUrl("/iui/iuiTest");
609 microServiceInfo.setLb_policy("ip_hash");
610 microServiceInfo.setPublish_port("10081|10082");
611 microServiceInfo.setPath("/iui/iuiTest4Path");
612 microServiceInfo.setVisualRange("0");
613 microServiceInfo.setStatus("1");
614 Set<Node> nodes = new HashSet<Node>();
615 nodes.add(new Node("10.74.148.88", "8080"));
616 nodes.add(new Node("10.74.148.89", "8080"));
617 microServiceInfo.setNodes(nodes);
619 return microServiceInfo;
622 private MicroServiceFullInfo buildMicroServiceFullInfo4HTTP() {
623 MicroServiceFullInfo microServiceInfo = new MicroServiceFullInfo();
624 microServiceInfo.setServiceName("httpTest-ns");
625 microServiceInfo.setNamespace("ns");
626 microServiceInfo.setVersion("v1");
627 microServiceInfo.setEnable_ssl(false);
628 microServiceInfo.setPublish_port("20081");
629 microServiceInfo.setProtocol("HTTP");
630 microServiceInfo.setUrl("/httpTest");
631 microServiceInfo.setVisualRange("1");
632 microServiceInfo.setStatus("1");
633 Set<Node> nodes = new HashSet<Node>();
634 nodes.add(new Node("10.74.148.88", "8080"));
635 nodes.add(new Node("10.74.148.89", "8080"));
636 microServiceInfo.setNodes(nodes);
638 return microServiceInfo;
641 private MicroServiceFullInfo buildMicroServiceFullInfo4HTTP_path() {
642 MicroServiceFullInfo microServiceInfo = new MicroServiceFullInfo();
643 microServiceInfo.setServiceName("httpTest");
644 microServiceInfo.setVersion("v1");
645 microServiceInfo.setEnable_ssl(true);
646 microServiceInfo.setHost("host");
647 microServiceInfo.setPublish_port("20081");
648 microServiceInfo.setProtocol("HTTP");
649 microServiceInfo.setUrl("/httpTest");
650 microServiceInfo.setVisualRange("0");
651 microServiceInfo.setStatus("1");
652 microServiceInfo.setLb_policy("ip_hash");
653 microServiceInfo.setPublish_port("10081|10082");
654 microServiceInfo.setPath("/httpTest4Path");
655 Set<Node> nodes = new HashSet<Node>();
656 nodes.add(new Node("10.74.148.88", "8080"));
657 nodes.add(new Node("10.74.148.89", "8080"));
658 microServiceInfo.setNodes(nodes);
660 return microServiceInfo;