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 * @Test public void test_noticeRouteListener4Add_del_api() { try { MicroServiceFullInfo
148 * microServiceInfo = buildMicroServiceFullInfo4API();
149 * routeInstance.noticeRouteListener4Add(microServiceInfo);
150 * Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "20081",
151 * "ip")); Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/",
152 * "apitest-ns", "", "domain"));
154 * routeInstance.noticeRouteListener4Delete(microServiceInfo);
156 * } catch (Exception e) { Assert.fail("throw exception means error occured!" + e.getMessage());
159 * try { apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "20081", "ip");
160 * Assert.fail("should not process to here."); } catch (Exception e) { Assert.assertTrue(e
161 * instanceof ExtendedNotFoundException); }
163 * try { apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "apitest-ns", "",
164 * "domain"); Assert.fail("should not process to here."); } catch (Exception e) {
165 * Assert.assertTrue(e instanceof ExtendedNotFoundException); }
172 public void test_noticeRouteListener4Add_del_api_path() {
174 MicroServiceFullInfo microServiceInfo = buildMicroServiceFullInfo4API_path();
175 routeInstance.noticeRouteListener4Add(microServiceInfo);
176 Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "", "10081", "ip"));
177 Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "", "10082", "ip"));
178 Assert.assertNotNull(
179 apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "host", "", "domain"));
181 routeInstance.noticeRouteListener4Delete(microServiceInfo);
183 } catch (Exception e) {
184 Assert.fail("throw exception means error occured!" + e.getMessage());
188 apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "", "10081", "ip");
189 Assert.fail("should not process to here.");
190 } catch (Exception e) {
191 Assert.assertTrue(e instanceof ExtendedNotFoundException);
195 apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "", "10082", "ip");
196 Assert.fail("should not process to here.");
197 } catch (Exception e) {
198 Assert.assertTrue(e instanceof ExtendedNotFoundException);
202 apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "host", "", "domain");
203 Assert.fail("should not process to here.");
204 } catch (Exception e) {
205 Assert.assertTrue(e instanceof ExtendedNotFoundException);
211 public void test_noticeRouteListener4Add_del_api_mutiPort() {
213 MicroServiceFullInfo microServiceInfo = buildMicroServiceFullInfo4API_path();
214 microServiceInfo.setPath("");
215 microServiceInfo.setHost("");
217 routeInstance.noticeRouteListener4Add(microServiceInfo);
218 Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "10081", "ip"));
219 Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "10082", "ip"));
220 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/", "apitest", "", "domain"));
222 routeInstance.noticeRouteListener4Delete(microServiceInfo);
224 } catch (Exception e) {
225 Assert.fail("throw exception means error occured!" + e.getMessage());
229 apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "10081", "ip");
230 Assert.fail("should not process to here.");
231 } catch (Exception e) {
232 Assert.assertTrue(e instanceof ExtendedNotFoundException);
236 apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "10082", "ip");
237 Assert.fail("should not process to here.");
238 } catch (Exception e) {
239 Assert.assertTrue(e instanceof ExtendedNotFoundException);
243 apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "apitest", "", "domain");
244 Assert.fail("should not process to here.");
245 } catch (Exception e) {
246 Assert.assertTrue(e instanceof ExtendedNotFoundException);
252 * @Test public void test_noticeRouteListener4Add_del_iui() { try { MicroServiceFullInfo
253 * microServiceInfo = buildMicroServiceFullInfo4IUI();
254 * routeInstance.noticeRouteListener4Add(microServiceInfo);
255 * Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "20081",
256 * "ip")); Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/",
257 * "iuitest-ns", "", "domain"));
259 * routeInstance.noticeRouteListener4Delete(microServiceInfo);
261 * } catch (Exception e) { Assert.fail("throw exception means error occured!" + e.getMessage());
264 * try { iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "20081", "ip");
265 * Assert.fail("should not process to here."); } catch (Exception e) { Assert.assertTrue(e
266 * instanceof ExtendedNotFoundException); }
268 * try { iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "iuitest-ns", "", "domain");
269 * Assert.fail("should not process to here."); } catch (Exception e) { Assert.assertTrue(e
270 * instanceof ExtendedNotFoundException); }
276 public void test_noticeRouteListener4Add_del_iui_path() {
278 MicroServiceFullInfo microServiceInfo = buildMicroServiceFullInfo4IUI_path();
279 routeInstance.noticeRouteListener4Add(microServiceInfo);
280 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10081", "ip"));
281 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10082", "ip"));
282 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "host", "", "domain"));
284 routeInstance.noticeRouteListener4Delete(microServiceInfo);
285 } catch (Exception e) {
286 Assert.fail("throw exception means error occured!" + e.getMessage());
290 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10081", "ip");
291 Assert.fail("should not process to here.");
292 } catch (Exception e) {
293 Assert.assertTrue(e instanceof ExtendedNotFoundException);
297 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10082", "ip");
298 Assert.fail("should not process to here.");
299 } catch (Exception e) {
300 Assert.assertTrue(e instanceof ExtendedNotFoundException);
304 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "host", "", "domain");
305 Assert.fail("should not process to here.");
306 } catch (Exception e) {
307 Assert.assertTrue(e instanceof ExtendedNotFoundException);
314 public void test_noticeRouteListener4Add_del_iui_mutiPort() {
316 MicroServiceFullInfo microServiceInfo = buildMicroServiceFullInfo4IUI_path();
317 microServiceInfo.setPath("");
318 microServiceInfo.setHost("");
320 routeInstance.noticeRouteListener4Add(microServiceInfo);
321 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10081", "ip"));
322 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10082", "ip"));
323 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/", "iuitest", "", "domain"));
325 routeInstance.noticeRouteListener4Delete(microServiceInfo);
326 } catch (Exception e) {
327 Assert.fail("throw exception means error occured!" + e.getMessage());
331 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10081", "ip");
332 Assert.fail("should not process to here.");
333 } catch (Exception e) {
334 Assert.assertTrue(e instanceof ExtendedNotFoundException);
338 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10082", "ip");
339 Assert.fail("should not process to here.");
340 } catch (Exception e) {
341 Assert.assertTrue(e instanceof ExtendedNotFoundException);
345 customRouteServiceWrapper.getCustomRouteInstance("/", "iuitest", "", "domain");
346 Assert.fail("should not process to here.");
347 } catch (Exception e) {
348 Assert.assertTrue(e instanceof ExtendedNotFoundException);
354 * @Test public void test_noticeRouteListener4Add_del_http() { try { MicroServiceFullInfo
355 * microServiceInfo = buildMicroServiceFullInfo4HTTP();
356 * routeInstance.noticeRouteListener4Add(microServiceInfo);
357 * Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "",
359 * Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1",
360 * "httptest-ns", "", "domain"));
362 * routeInstance.noticeRouteListener4Delete(microServiceInfo); } catch (Exception e) {
363 * Assert.fail("throw exception means error occured!" + e.getMessage()); }
365 * try { customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "20081", "ip");
366 * Assert.fail("should not process to here."); } catch (Exception e) { Assert.assertTrue(e
367 * instanceof ExtendedNotFoundException); }
369 * try { customRouteServiceWrapper.getCustomRouteInstance("/httpTest", "httptest-ns", "",
370 * "domain"); Assert.fail("should not process to here."); } catch (Exception e) {
371 * Assert.assertTrue(e instanceof ExtendedNotFoundException); }
377 public void test_noticeRouteListener4Add_del_http_path() {
379 MicroServiceFullInfo microServiceInfo = buildMicroServiceFullInfo4HTTP_path();
380 routeInstance.noticeRouteListener4Add(microServiceInfo);
381 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10081", "ip"));
382 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10082", "ip"));
383 Assert.assertNotNull(
384 customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "host", "", "domain"));
386 routeInstance.noticeRouteListener4Delete(microServiceInfo);
387 } catch (Exception e) {
388 Assert.fail("throw exception means error occured!" + e.getMessage());
392 customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10081", "ip");
393 Assert.fail("should not process to here.");
394 } catch (Exception e) {
395 Assert.assertTrue(e instanceof ExtendedNotFoundException);
399 customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10082", "ip");
400 Assert.fail("should not process to here.");
401 } catch (Exception e) {
402 Assert.assertTrue(e instanceof ExtendedNotFoundException);
406 customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "host", "", "domain");
407 Assert.fail("should not process to here.");
408 } catch (Exception e) {
409 Assert.assertTrue(e instanceof ExtendedNotFoundException);
416 public void test_noticeRouteListener4Add_del_http_mutiPort() {
418 MicroServiceFullInfo microServiceInfo = buildMicroServiceFullInfo4HTTP_path();
419 microServiceInfo.setPath("");
420 microServiceInfo.setHost("");
422 routeInstance.noticeRouteListener4Add(microServiceInfo);
423 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10081", "ip"));
424 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10082", "ip"));
425 Assert.assertNotNull(
426 customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "httptest", "", "domain"));
428 routeInstance.noticeRouteListener4Delete(microServiceInfo);
429 } catch (Exception e) {
430 Assert.fail("throw exception means error occured!" + e.getMessage());
434 customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10081", "ip");
435 Assert.fail("should not process to here.");
436 } catch (Exception e) {
437 Assert.assertTrue(e instanceof ExtendedNotFoundException);
441 customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10082", "ip");
442 Assert.fail("should not process to here.");
443 } catch (Exception e) {
444 Assert.assertTrue(e instanceof ExtendedNotFoundException);
448 customRouteServiceWrapper.getCustomRouteInstance("/httpTest", "httptest", "", "domain");
449 Assert.fail("should not process to here.");
450 } catch (Exception e) {
451 Assert.assertTrue(e instanceof ExtendedNotFoundException);
458 public void test_noticeRouteListener4Add_portal() {
460 PowerMockito.mockStatic(System.class);
461 PowerMockito.when(System.getenv("SDCLIENT_IP")).thenReturn("127.0.0.1");
462 ApiRouteAppConfig configuration = new ApiRouteAppConfig();
464 DiscoverInfo discoverInfo = new DiscoverInfo();
465 discoverInfo.setEnabled(true);
466 discoverInfo.setIp("127.0.0.2");
467 discoverInfo.setPort(10081);
468 configuration.setDiscoverInfo(discoverInfo);
469 ConfigUtil.getInstance().initDiscoverInfo(configuration);
472 PowerMockito.mockStatic(HttpClientUtil.class);
474 "http://127.0.0.1:10081/api/microservices/v1/services/portalTest/version/v1/allpublishaddress?namespace=&visualRange=0";
476 "[{\"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\"}]";
477 PowerMockito.when(HttpClientUtil.httpGet(publishUrl)).thenReturn(resultJson);
479 MicroServiceFullInfo microServiceInfo = buildMicroServiceFullInfo4PORTAL();
481 routeInstance.noticeRouteListener4Add(microServiceInfo);
483 CustomRouteInfo routeInfo_ip =
484 customRouteServiceWrapper.getCustomRouteInstance("/portalTest/v1", "", "10088", "ip");
485 RouteServer[] servers_ip = new RouteServer[] {new RouteServer("10.74.148.99", "8080")};
486 Assert.assertArrayEquals(servers_ip, routeInfo_ip.getServers());
488 CustomRouteInfo routeInfo_domain =
489 customRouteServiceWrapper.getCustomRouteInstance("/portalTest/v1", "host", "", "domain");
490 RouteServer[] servers_domain = new RouteServer[] {new RouteServer("10.74.165.246", "443")};
492 Assert.assertArrayEquals(servers_domain, routeInfo_domain.getServers());
494 } catch (Exception e) {
495 Assert.fail("throw exception means error occured!" + e.getMessage());
501 private MicroServiceFullInfo buildMicroServiceFullInfo4API() {
502 MicroServiceFullInfo microServiceInfo = new MicroServiceFullInfo();
503 microServiceInfo.setServiceName("apiTest-ns");
504 microServiceInfo.setVersion("v1");
505 microServiceInfo.setEnable_ssl(false);
506 microServiceInfo.setPublish_port("20081");
507 microServiceInfo.setProtocol("REST");
508 microServiceInfo.setUrl("/api/apiTest/v1");
509 microServiceInfo.setVisualRange("1");
510 microServiceInfo.setStatus("1");
511 microServiceInfo.setNamespace("ns");
512 Set<Node> nodes = new HashSet<Node>();
513 nodes.add(new Node("10.74.148.88", "8080"));
514 nodes.add(new Node("10.74.148.89", "8080"));
515 microServiceInfo.setNodes(nodes);
517 return microServiceInfo;
520 private MicroServiceFullInfo buildMicroServiceFullInfo4API_path() {
521 MicroServiceFullInfo microServiceInfo = new MicroServiceFullInfo();
522 microServiceInfo.setServiceName("apiTest");
523 microServiceInfo.setVersion("v1");
524 microServiceInfo.setEnable_ssl(true);
525 microServiceInfo.setHost("host");
526 microServiceInfo.setPath("/api/apiTest4Path/v1");
527 microServiceInfo.setPublish_port("10081|10082");
528 microServiceInfo.setProtocol("REST");
529 microServiceInfo.setUrl("/api/apiTest/v1");
530 microServiceInfo.setVisualRange("0");
531 microServiceInfo.setLb_policy("ip_hash");
532 microServiceInfo.setStatus("1");
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;
542 private MicroServiceFullInfo buildMicroServiceFullInfo4PORTAL() {
544 MicroServiceFullInfo microServiceInfo = new MicroServiceFullInfo();
545 microServiceInfo.setServiceName("portalTest");
546 microServiceInfo.setVersion("v1");
547 microServiceInfo.setEnable_ssl(true);
548 microServiceInfo.setHost("host");
549 microServiceInfo.setPublish_port("10088");
550 microServiceInfo.setProtocol("HTTP");
551 microServiceInfo.setUrl("/portalTestUrl/v1");
552 microServiceInfo.setVisualRange("0");
553 microServiceInfo.setLb_policy("ip_hash");
554 microServiceInfo.setStatus("1");
555 microServiceInfo.setCustom(RouteUtil.CUSTOM_PORTAL);
556 Set<Node> nodes = new HashSet<Node>();
557 nodes.add(new Node("10.74.148.99", "8080"));
558 microServiceInfo.setNodes(nodes);
560 return microServiceInfo;
563 private MicroServiceFullInfo buildMicroServiceFullInfo4IUI() {
564 MicroServiceFullInfo microServiceInfo = new MicroServiceFullInfo();
565 microServiceInfo.setServiceName("iuiTest-ns");
566 microServiceInfo.setNamespace("ns");
567 microServiceInfo.setVersion("v1");
568 microServiceInfo.setEnable_ssl(false);
569 microServiceInfo.setPublish_port("20081");
570 microServiceInfo.setProtocol("UI");
571 microServiceInfo.setUrl("/iui/iuiTest");
572 microServiceInfo.setVisualRange("1");
573 microServiceInfo.setStatus("1");
574 Set<Node> nodes = new HashSet<Node>();
575 nodes.add(new Node("10.74.148.88", "8080"));
576 nodes.add(new Node("10.74.148.89", "8080"));
577 microServiceInfo.setNodes(nodes);
579 return microServiceInfo;
582 private MicroServiceFullInfo buildMicroServiceFullInfo4IUI_path() {
583 MicroServiceFullInfo microServiceInfo = new MicroServiceFullInfo();
584 microServiceInfo.setServiceName("iuiTest");
585 microServiceInfo.setVersion("v1");
586 microServiceInfo.setEnable_ssl(true);
587 microServiceInfo.setHost("host");
588 microServiceInfo.setProtocol("UI");
589 microServiceInfo.setUrl("/iui/iuiTest");
590 microServiceInfo.setLb_policy("ip_hash");
591 microServiceInfo.setPublish_port("10081|10082");
592 microServiceInfo.setPath("/iui/iuiTest4Path");
593 microServiceInfo.setVisualRange("0");
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 buildMicroServiceFullInfo4HTTP() {
604 MicroServiceFullInfo microServiceInfo = new MicroServiceFullInfo();
605 microServiceInfo.setServiceName("httpTest-ns");
606 microServiceInfo.setNamespace("ns");
607 microServiceInfo.setVersion("v1");
608 microServiceInfo.setEnable_ssl(false);
609 microServiceInfo.setPublish_port("20081");
610 microServiceInfo.setProtocol("HTTP");
611 microServiceInfo.setUrl("/httpTest");
612 microServiceInfo.setVisualRange("1");
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_path() {
623 MicroServiceFullInfo microServiceInfo = new MicroServiceFullInfo();
624 microServiceInfo.setServiceName("httpTest");
625 microServiceInfo.setVersion("v1");
626 microServiceInfo.setEnable_ssl(true);
627 microServiceInfo.setHost("host");
628 microServiceInfo.setPublish_port("20081");
629 microServiceInfo.setProtocol("HTTP");
630 microServiceInfo.setUrl("/httpTest");
631 microServiceInfo.setVisualRange("0");
632 microServiceInfo.setStatus("1");
633 microServiceInfo.setLb_policy("ip_hash");
634 microServiceInfo.setPublish_port("10081|10082");
635 microServiceInfo.setPath("/httpTest4Path");
636 Set<Node> nodes = new HashSet<Node>();
637 nodes.add(new Node("10.74.148.88", "8080"));
638 nodes.add(new Node("10.74.148.89", "8080"));
639 microServiceInfo.setNodes(nodes);
641 return microServiceInfo;