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.*", "jdk.internal.reflect.*"})
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());
114 * public void test_noticeRouteListener4Update_iui() { try {
115 * routeInstance.noticeRouteListener4Update("iuiTest-ns", "v1",
116 * buildMicroServiceFullInfo4IUI()); IuiRouteInfo iuiRouteInfo =
117 * iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest-ns", "host", "20081", "ip");
119 * Assert.assertNotNull(iuiRouteInfo); Assert.assertEquals("1", iuiRouteInfo.getStatus());
121 * routeInstance.noticeUpdateStatusListener(buildMicroServiceFullInfo4IUI(), "0"); iuiRouteInfo
122 * = iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest-ns", "host", "20081", "ip");
123 * Assert.assertEquals("0", iuiRouteInfo.getStatus());
125 * } catch (Exception e) { 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);
253 public void test_noticeRouteListener4Add_del_iui() throws Exception {
255 MicroServiceFullInfo microServiceInfo = buildMicroServiceFullInfo4IUI();
256 routeInstance.noticeRouteListener4Add(microServiceInfo);
257 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "20081", "ip");
258 // Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/", "iuitest-ns",
261 routeInstance.noticeRouteListener4Delete(microServiceInfo);
265 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "20081", "ip");
266 Assert.fail("should not process to here.");
267 } catch (Exception e) {
268 Assert.assertTrue(e instanceof ExtendedNotFoundException);
272 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "iuitest-ns", "", "domain");
273 Assert.fail("should not process to here.");
274 } catch (Exception e) {
275 Assert.assertTrue(e instanceof ExtendedNotFoundException);
282 public void test_noticeRouteListener4Add_del_iui_path() {
284 MicroServiceFullInfo microServiceInfo = buildMicroServiceFullInfo4IUI_path();
285 routeInstance.noticeRouteListener4Add(microServiceInfo);
286 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10081", "ip"));
287 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10082", "ip"));
288 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "host", "", "domain"));
290 routeInstance.noticeRouteListener4Delete(microServiceInfo);
291 } catch (Exception e) {
292 Assert.fail("throw exception means error occured!" + e.getMessage());
296 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10081", "ip");
297 Assert.fail("should not process to here.");
298 } catch (Exception e) {
299 Assert.assertTrue(e instanceof ExtendedNotFoundException);
303 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10082", "ip");
304 Assert.fail("should not process to here.");
305 } catch (Exception e) {
306 Assert.assertTrue(e instanceof ExtendedNotFoundException);
310 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "host", "", "domain");
311 Assert.fail("should not process to here.");
312 } catch (Exception e) {
313 Assert.assertTrue(e instanceof ExtendedNotFoundException);
320 public void test_noticeRouteListener4Add_del_iui_mutiPort() {
322 MicroServiceFullInfo microServiceInfo = buildMicroServiceFullInfo4IUI_path();
323 microServiceInfo.setPath("");
324 microServiceInfo.setHost("");
326 routeInstance.noticeRouteListener4Add(microServiceInfo);
327 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10081", "ip"));
328 Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10082", "ip"));
329 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/", "iuitest", "", "domain"));
331 routeInstance.noticeRouteListener4Delete(microServiceInfo);
332 } catch (Exception e) {
333 Assert.fail("throw exception means error occured!" + e.getMessage());
337 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10081", "ip");
338 Assert.fail("should not process to here.");
339 } catch (Exception e) {
340 Assert.assertTrue(e instanceof ExtendedNotFoundException);
344 iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10082", "ip");
345 Assert.fail("should not process to here.");
346 } catch (Exception e) {
347 Assert.assertTrue(e instanceof ExtendedNotFoundException);
351 customRouteServiceWrapper.getCustomRouteInstance("/", "iuitest", "", "domain");
352 Assert.fail("should not process to here.");
353 } catch (Exception e) {
354 Assert.assertTrue(e instanceof ExtendedNotFoundException);
360 * @Test public void test_noticeRouteListener4Add_del_http() { try { MicroServiceFullInfo
361 * microServiceInfo = buildMicroServiceFullInfo4HTTP();
362 * routeInstance.noticeRouteListener4Add(microServiceInfo);
363 * Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "",
365 * Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1",
366 * "httptest-ns", "", "domain"));
368 * routeInstance.noticeRouteListener4Delete(microServiceInfo); } catch (Exception e) {
369 * Assert.fail("throw exception means error occured!" + e.getMessage()); }
371 * try { customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "20081", "ip");
372 * Assert.fail("should not process to here."); } catch (Exception e) { Assert.assertTrue(e
373 * instanceof ExtendedNotFoundException); }
375 * try { customRouteServiceWrapper.getCustomRouteInstance("/httpTest", "httptest-ns", "",
376 * "domain"); Assert.fail("should not process to here."); } catch (Exception e) {
377 * Assert.assertTrue(e instanceof ExtendedNotFoundException); }
383 public void test_noticeRouteListener4Add_del_http_path() {
385 MicroServiceFullInfo microServiceInfo = buildMicroServiceFullInfo4HTTP_path();
386 routeInstance.noticeRouteListener4Add(microServiceInfo);
387 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10081", "ip"));
388 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10082", "ip"));
389 Assert.assertNotNull(
390 customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "host", "", "domain"));
392 routeInstance.noticeRouteListener4Delete(microServiceInfo);
393 } catch (Exception e) {
394 Assert.fail("throw exception means error occured!" + e.getMessage());
398 customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10081", "ip");
399 Assert.fail("should not process to here.");
400 } catch (Exception e) {
401 Assert.assertTrue(e instanceof ExtendedNotFoundException);
405 customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10082", "ip");
406 Assert.fail("should not process to here.");
407 } catch (Exception e) {
408 Assert.assertTrue(e instanceof ExtendedNotFoundException);
412 customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "host", "", "domain");
413 Assert.fail("should not process to here.");
414 } catch (Exception e) {
415 Assert.assertTrue(e instanceof ExtendedNotFoundException);
422 public void test_noticeRouteListener4Add_del_http_mutiPort() {
424 MicroServiceFullInfo microServiceInfo = buildMicroServiceFullInfo4HTTP_path();
425 microServiceInfo.setPath("");
426 microServiceInfo.setHost("");
428 routeInstance.noticeRouteListener4Add(microServiceInfo);
429 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10081", "ip"));
430 Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10082", "ip"));
431 Assert.assertNotNull(
432 customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "httptest", "", "domain"));
434 routeInstance.noticeRouteListener4Delete(microServiceInfo);
435 } catch (Exception e) {
436 Assert.fail("throw exception means error occured!" + e.getMessage());
440 customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10081", "ip");
441 Assert.fail("should not process to here.");
442 } catch (Exception e) {
443 Assert.assertTrue(e instanceof ExtendedNotFoundException);
447 customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10082", "ip");
448 Assert.fail("should not process to here.");
449 } catch (Exception e) {
450 Assert.assertTrue(e instanceof ExtendedNotFoundException);
454 customRouteServiceWrapper.getCustomRouteInstance("/httpTest", "httptest", "", "domain");
455 Assert.fail("should not process to here.");
456 } catch (Exception e) {
457 Assert.assertTrue(e instanceof ExtendedNotFoundException);
464 public void test_noticeRouteListener4Add_portal() {
466 PowerMockito.mockStatic(System.class);
467 PowerMockito.when(System.getenv("SDCLIENT_IP")).thenReturn("127.0.0.1");
468 ApiRouteAppConfig configuration = new ApiRouteAppConfig();
470 DiscoverInfo discoverInfo = new DiscoverInfo();
471 discoverInfo.setEnabled(true);
472 discoverInfo.setIp("127.0.0.2");
473 discoverInfo.setPort(10081);
474 configuration.setDiscoverInfo(discoverInfo);
475 ConfigUtil.getInstance().initDiscoverInfo(configuration);
478 PowerMockito.mockStatic(HttpClientUtil.class);
480 "http://127.0.0.1:10081/api/microservices/v1/services/portalTest/version/v1/allpublishaddress?namespace=&visualRange=0";
482 "[{\"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\"}]";
483 PowerMockito.when(HttpClientUtil.httpGet(publishUrl)).thenReturn(resultJson);
485 MicroServiceFullInfo microServiceInfo = buildMicroServiceFullInfo4PORTAL();
487 routeInstance.noticeRouteListener4Add(microServiceInfo);
489 CustomRouteInfo routeInfo_ip =
490 customRouteServiceWrapper.getCustomRouteInstance("/portalTest/v1", "", "10088", "ip");
491 RouteServer[] servers_ip = new RouteServer[] {new RouteServer("10.74.148.99", "8080")};
492 Assert.assertArrayEquals(servers_ip, routeInfo_ip.getServers());
494 CustomRouteInfo routeInfo_domain =
495 customRouteServiceWrapper.getCustomRouteInstance("/portalTest/v1", "host", "", "domain");
496 RouteServer[] servers_domain = new RouteServer[] {new RouteServer("10.74.165.246", "443")};
498 Assert.assertArrayEquals(servers_domain, routeInfo_domain.getServers());
500 } catch (Exception e) {
501 Assert.fail("throw exception means error occured!" + e.getMessage());
507 private MicroServiceFullInfo buildMicroServiceFullInfo4API() {
508 MicroServiceFullInfo microServiceInfo = new MicroServiceFullInfo();
509 microServiceInfo.setServiceName("apiTest-ns");
510 microServiceInfo.setVersion("v1");
511 microServiceInfo.setEnable_ssl(false);
512 microServiceInfo.setPublish_port("20081");
513 microServiceInfo.setProtocol("REST");
514 microServiceInfo.setUrl("/api/apiTest/v1");
515 microServiceInfo.setVisualRange("1");
516 microServiceInfo.setStatus("1");
517 microServiceInfo.setNamespace("ns");
518 Set<Node> nodes = new HashSet<Node>();
519 nodes.add(new Node("10.74.148.88", "8080"));
520 nodes.add(new Node("10.74.148.89", "8080"));
521 microServiceInfo.setNodes(nodes);
523 return microServiceInfo;
526 private MicroServiceFullInfo buildMicroServiceFullInfo4API_path() {
527 MicroServiceFullInfo microServiceInfo = new MicroServiceFullInfo();
528 microServiceInfo.setServiceName("apiTest");
529 microServiceInfo.setVersion("v1");
530 microServiceInfo.setEnable_ssl(true);
531 microServiceInfo.setHost("host");
532 microServiceInfo.setPath("/api/apiTest4Path/v1");
533 microServiceInfo.setPublish_port("10081|10082");
534 microServiceInfo.setProtocol("REST");
535 microServiceInfo.setUrl("/api/apiTest/v1");
536 microServiceInfo.setVisualRange("0");
537 microServiceInfo.setLb_policy("ip_hash");
538 microServiceInfo.setStatus("1");
539 Set<Node> nodes = new HashSet<Node>();
540 nodes.add(new Node("10.74.148.88", "8080"));
541 nodes.add(new Node("10.74.148.89", "8080"));
542 microServiceInfo.setNodes(nodes);
544 return microServiceInfo;
548 private MicroServiceFullInfo buildMicroServiceFullInfo4PORTAL() {
550 MicroServiceFullInfo microServiceInfo = new MicroServiceFullInfo();
551 microServiceInfo.setServiceName("portalTest");
552 microServiceInfo.setVersion("v1");
553 microServiceInfo.setEnable_ssl(true);
554 microServiceInfo.setHost("host");
555 microServiceInfo.setPublish_port("10088");
556 microServiceInfo.setProtocol("HTTP");
557 microServiceInfo.setUrl("/portalTestUrl/v1");
558 microServiceInfo.setVisualRange("0");
559 microServiceInfo.setLb_policy("ip_hash");
560 microServiceInfo.setStatus("1");
561 microServiceInfo.setCustom(RouteUtil.CUSTOM_PORTAL);
562 Set<Node> nodes = new HashSet<Node>();
563 nodes.add(new Node("10.74.148.99", "8080"));
564 microServiceInfo.setNodes(nodes);
566 return microServiceInfo;
569 private MicroServiceFullInfo buildMicroServiceFullInfo4IUI() {
570 MicroServiceFullInfo microServiceInfo = new MicroServiceFullInfo();
571 microServiceInfo.setServiceName("iuiTest");
572 microServiceInfo.setNamespace("ns");
573 microServiceInfo.setVersion("v1");
574 microServiceInfo.setEnable_ssl(false);
575 microServiceInfo.setPublish_port("20081");
576 microServiceInfo.setProtocol("UI");
577 microServiceInfo.setUrl("/iui/iuiTest");
578 microServiceInfo.setVisualRange("1");
579 microServiceInfo.setStatus("1");
580 Set<Node> nodes = new HashSet<Node>();
581 nodes.add(new Node("10.74.148.88", "8080"));
582 nodes.add(new Node("10.74.148.89", "8080"));
583 microServiceInfo.setNodes(nodes);
585 return microServiceInfo;
588 private MicroServiceFullInfo buildMicroServiceFullInfo4IUI_path() {
589 MicroServiceFullInfo microServiceInfo = new MicroServiceFullInfo();
590 microServiceInfo.setServiceName("iuiTest");
591 microServiceInfo.setVersion("v1");
592 microServiceInfo.setEnable_ssl(true);
593 microServiceInfo.setHost("host");
594 microServiceInfo.setProtocol("UI");
595 microServiceInfo.setUrl("/iui/iuiTest");
596 microServiceInfo.setLb_policy("ip_hash");
597 microServiceInfo.setPublish_port("10081|10082");
598 microServiceInfo.setPath("/iui/iuiTest4Path");
599 microServiceInfo.setVisualRange("0");
600 microServiceInfo.setStatus("1");
601 Set<Node> nodes = new HashSet<Node>();
602 nodes.add(new Node("10.74.148.88", "8080"));
603 nodes.add(new Node("10.74.148.89", "8080"));
604 microServiceInfo.setNodes(nodes);
606 return microServiceInfo;
609 private MicroServiceFullInfo buildMicroServiceFullInfo4HTTP() {
610 MicroServiceFullInfo microServiceInfo = new MicroServiceFullInfo();
611 microServiceInfo.setServiceName("httpTest-ns");
612 microServiceInfo.setNamespace("ns");
613 microServiceInfo.setVersion("v1");
614 microServiceInfo.setEnable_ssl(false);
615 microServiceInfo.setPublish_port("20081");
616 microServiceInfo.setProtocol("HTTP");
617 microServiceInfo.setUrl("/httpTest");
618 microServiceInfo.setVisualRange("1");
619 microServiceInfo.setStatus("1");
620 Set<Node> nodes = new HashSet<Node>();
621 nodes.add(new Node("10.74.148.88", "8080"));
622 nodes.add(new Node("10.74.148.89", "8080"));
623 microServiceInfo.setNodes(nodes);
625 return microServiceInfo;
628 private MicroServiceFullInfo buildMicroServiceFullInfo4HTTP_path() {
629 MicroServiceFullInfo microServiceInfo = new MicroServiceFullInfo();
630 microServiceInfo.setServiceName("httpTest");
631 microServiceInfo.setVersion("v1");
632 microServiceInfo.setEnable_ssl(true);
633 microServiceInfo.setHost("host");
634 microServiceInfo.setPublish_port("20081");
635 microServiceInfo.setProtocol("HTTP");
636 microServiceInfo.setUrl("/httpTest");
637 microServiceInfo.setVisualRange("0");
638 microServiceInfo.setStatus("1");
639 microServiceInfo.setLb_policy("ip_hash");
640 microServiceInfo.setPublish_port("10081|10082");
641 microServiceInfo.setPath("/httpTest4Path");
642 Set<Node> nodes = new HashSet<Node>();
643 nodes.add(new Node("10.74.148.88", "8080"));
644 nodes.add(new Node("10.74.148.89", "8080"));
645 microServiceInfo.setNodes(nodes);
647 return microServiceInfo;