Divide the MSB source codes into two repos
[msb/apigateway.git] / apiroute / apiroute-service / src / test / java / org / onap / msb / apiroute / wrapper / serviceListener / MicroServiceChangeListenerTest.java
1 package org.onap.msb.apiroute.wrapper.serviceListener;
2
3 import java.lang.reflect.InvocationHandler;
4 import java.lang.reflect.Method;
5 import java.util.HashSet;
6 import java.util.Set;
7
8 import org.junit.Assert;
9 import org.junit.Before;
10 import org.junit.BeforeClass;
11 import org.junit.Test;
12 import org.junit.runner.RunWith;
13 import org.onap.msb.apiroute.ApiRouteAppConfig;
14 import org.onap.msb.apiroute.api.ApiRouteInfo;
15 import org.onap.msb.apiroute.api.CustomRouteInfo;
16 import org.onap.msb.apiroute.api.DiscoverInfo;
17 import org.onap.msb.apiroute.api.IuiRouteInfo;
18 import org.onap.msb.apiroute.api.MicroServiceFullInfo;
19 import org.onap.msb.apiroute.api.Node;
20 import org.onap.msb.apiroute.api.RouteServer;
21 import org.onap.msb.apiroute.api.exception.ExtendedNotFoundException;
22 import org.onap.msb.apiroute.wrapper.ApiRouteServiceWrapper;
23 import org.onap.msb.apiroute.wrapper.CustomRouteServiceWrapper;
24 import org.onap.msb.apiroute.wrapper.InitRouteServiceWrapper;
25 import org.onap.msb.apiroute.wrapper.IuiRouteServiceWrapper;
26 import org.onap.msb.apiroute.wrapper.dao.RedisAccessWrapper;
27 import org.onap.msb.apiroute.wrapper.serviceListener.RouteNotify;
28 import org.onap.msb.apiroute.wrapper.util.ConfigUtil;
29 import org.onap.msb.apiroute.wrapper.util.HttpClientUtil;
30 import org.onap.msb.apiroute.wrapper.util.JedisUtil;
31 import org.onap.msb.apiroute.wrapper.util.RouteUtil;
32 import org.powermock.api.mockito.PowerMockito;
33 import org.powermock.core.classloader.annotations.PowerMockIgnore;
34 import org.powermock.core.classloader.annotations.PrepareForTest;
35 import org.powermock.modules.junit4.PowerMockRunner;
36
37 import redis.clients.jedis.JedisPool;
38 import redis.clients.jedis.JedisPoolConfig;
39
40 import com.fiftyonred.mock_jedis.MockJedisPool;
41
42 @RunWith(PowerMockRunner.class)
43 @PrepareForTest({JedisUtil.class,ConfigUtil.class,HttpClientUtil.class, RedisAccessWrapper.class,})
44 @PowerMockIgnore({"javax.management.*"})
45 public class MicroServiceChangeListenerTest {
46   private static RouteNotify routeInstance;
47   private static ApiRouteServiceWrapper apiRouteServiceWrapper;
48   private static IuiRouteServiceWrapper iuiRouteServiceWrapper;
49   private static CustomRouteServiceWrapper customRouteServiceWrapper;
50
51   
52   @BeforeClass
53   public static void setUpBeforeClass() throws Exception {
54     InitRouteServiceWrapper.getInstance().registerServiceChangeListener();
55     routeInstance=RouteNotify.getInstance();
56     apiRouteServiceWrapper=ApiRouteServiceWrapper.getInstance();
57     iuiRouteServiceWrapper=IuiRouteServiceWrapper.getInstance();
58     customRouteServiceWrapper=CustomRouteServiceWrapper.getInstance();
59
60     PowerMockito.mockStatic(System.class);
61     PowerMockito.when(System.getenv("ROUTE_WAY")).thenReturn("ip|domain");
62     ConfigUtil.getInstance().initRouteWay();
63   }
64   
65   @Before
66   public  void initReidsMock() throws Exception {
67       final JedisPool mockJedisPool = new MockJedisPool(new JedisPoolConfig(), "localhost");
68       PowerMockito.mockStatic(JedisUtil.class);
69       JedisUtil jedisUtil=PowerMockito.mock(JedisUtil.class);
70       PowerMockito.when(jedisUtil.borrowJedisInstance()).thenReturn(mockJedisPool.getResource());
71
72       PowerMockito.replace(PowerMockito.method(RedisAccessWrapper.class, "filterKeys")).with(new InvocationHandler() {
73           @Override
74           public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
75               return mockJedisPool.getResource().keys((String) args[0]);
76           }
77       });
78   }
79   
80   @Test
81   public void test_noticeRouteListener4Update_api(){
82     try {
83       routeInstance.noticeRouteListener4Update("apiTest-ns", "v1", buildMicroServiceFullInfo4API());
84       ApiRouteInfo apiRouteInfo=apiRouteServiceWrapper.getApiRouteInstance("apiTest-ns", "v1", "host", "20081", "ip");
85
86       Assert.assertNotNull(apiRouteInfo);
87       Assert.assertEquals("1", apiRouteInfo.getStatus());
88       
89       routeInstance.noticeUpdateStatusListener(buildMicroServiceFullInfo4API(),"0");
90       apiRouteInfo=apiRouteServiceWrapper.getApiRouteInstance("apiTest-ns", "v1", "host", "20081", "ip");
91       Assert.assertEquals("0", apiRouteInfo.getStatus());
92       
93     } catch (Exception e) {
94       Assert.fail("throw exception means error occured!" + e.getMessage());
95     }
96   }
97   
98   @Test
99   public void test_noticeRouteListener4Update_iui(){
100     try {
101       routeInstance.noticeRouteListener4Update("iuiTest-ns", "v1", buildMicroServiceFullInfo4IUI());
102       IuiRouteInfo iuiRouteInfo=iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest-ns", "host", "20081", "ip");
103       
104       Assert.assertNotNull(iuiRouteInfo);
105       Assert.assertEquals("1", iuiRouteInfo.getStatus());
106       
107       routeInstance.noticeUpdateStatusListener(buildMicroServiceFullInfo4IUI(),"0");
108       iuiRouteInfo=iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest-ns", "host", "20081", "ip");
109       Assert.assertEquals("0", iuiRouteInfo.getStatus());
110       
111     } catch (Exception e) {
112       Assert.fail("throw exception means error occured!" + e.getMessage());
113     }
114   }
115   
116   @Test
117   public void test_noticeRouteListener4Update_http(){
118     try {
119       routeInstance.noticeRouteListener4Update("httpTest-ns", "v1", buildMicroServiceFullInfo4HTTP());
120       CustomRouteInfo customRouteInfo=customRouteServiceWrapper.getCustomRouteInstance("/httpTest-ns", "host", "20081", "ip");
121       Assert.assertNotNull(customRouteInfo);      
122       Assert.assertEquals("1", customRouteInfo.getStatus());
123       
124       routeInstance.noticeUpdateStatusListener(buildMicroServiceFullInfo4HTTP(),"0");
125       customRouteInfo=customRouteServiceWrapper.getCustomRouteInstance("/httpTest-ns", "host", "20081", "ip");
126       Assert.assertEquals("0", customRouteInfo.getStatus());
127     } catch (Exception e) {
128       Assert.fail("throw exception means error occured!" + e.getMessage());
129     }
130   }
131   
132   @Test
133   public void test_noticeRouteListener4Add_del_api(){
134     try {
135       MicroServiceFullInfo microServiceInfo =buildMicroServiceFullInfo4API();
136       routeInstance.noticeRouteListener4Add(microServiceInfo);
137       Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "20081", "ip"));
138       Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/", "apitest-ns", "", "domain"));
139       
140       routeInstance.noticeRouteListener4Delete(microServiceInfo);
141
142     } catch (Exception e) {
143       Assert.fail("throw exception means error occured!" + e.getMessage());
144     }
145     
146     try {     
147       apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "20081", "ip");
148       Assert.fail("should not process to here.");    
149      } 
150      catch(Exception e){
151          Assert.assertTrue(e instanceof ExtendedNotFoundException);
152      }
153     
154     try {     
155       apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "apitest-ns", "", "domain");
156       Assert.fail("should not process to here.");    
157      } 
158      catch(Exception e){
159          Assert.assertTrue(e instanceof ExtendedNotFoundException);
160      }
161
162     
163   }
164   
165   @Test
166   public void test_noticeRouteListener4Add_del_api_path(){
167     try {
168       MicroServiceFullInfo microServiceInfo =buildMicroServiceFullInfo4API_path();
169       routeInstance.noticeRouteListener4Add(microServiceInfo);
170       Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "", "10081", "ip"));
171       Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "", "10082", "ip"));
172       Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "host", "", "domain"));
173       
174       routeInstance.noticeRouteListener4Delete(microServiceInfo);
175       
176     } catch (Exception e) {
177       Assert.fail("throw exception means error occured!" + e.getMessage());
178     }
179     
180      try {     
181        apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "", "10081", "ip");
182        Assert.fail("should not process to here.");    
183       } 
184       catch(Exception e){
185           Assert.assertTrue(e instanceof ExtendedNotFoundException);
186       }
187      
188      try {     
189        apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "", "10082", "ip");
190        Assert.fail("should not process to here.");    
191       } 
192       catch(Exception e){
193           Assert.assertTrue(e instanceof ExtendedNotFoundException);
194       }
195      
196      try {     
197        apiRouteServiceWrapper.getApiRouteInstance("apiTest4Path", "v1", "host", "", "domain");
198        Assert.fail("should not process to here.");    
199       } 
200       catch(Exception e){
201           Assert.assertTrue(e instanceof ExtendedNotFoundException);
202       }
203     
204   }
205   
206   @Test
207   public void test_noticeRouteListener4Add_del_api_mutiPort(){
208     try {
209       MicroServiceFullInfo microServiceInfo =buildMicroServiceFullInfo4API_path();
210       microServiceInfo.setPath("");
211       microServiceInfo.setHost("");
212       
213       routeInstance.noticeRouteListener4Add(microServiceInfo);
214       Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "10081", "ip"));
215       Assert.assertNotNull(apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "10082", "ip"));
216       Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/", "apitest", "", "domain"));
217       
218       routeInstance.noticeRouteListener4Delete(microServiceInfo);
219       
220     } catch (Exception e) {
221       Assert.fail("throw exception means error occured!" + e.getMessage());
222     }
223     
224      try {     
225        apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "10081", "ip");
226        Assert.fail("should not process to here.");    
227       } 
228       catch(Exception e){
229           Assert.assertTrue(e instanceof ExtendedNotFoundException);
230       }
231      
232      try {     
233        apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "", "10082", "ip");
234        Assert.fail("should not process to here.");    
235       } 
236       catch(Exception e){
237           Assert.assertTrue(e instanceof ExtendedNotFoundException);
238       }
239      
240      try {     
241        apiRouteServiceWrapper.getApiRouteInstance("apiTest", "v1", "apitest", "", "domain");
242        Assert.fail("should not process to here.");    
243       } 
244       catch(Exception e){
245           Assert.assertTrue(e instanceof ExtendedNotFoundException);
246       }
247     
248   }
249   
250   @Test
251   public void test_noticeRouteListener4Add_del_iui(){
252     try {
253       MicroServiceFullInfo microServiceInfo =buildMicroServiceFullInfo4IUI();
254       routeInstance.noticeRouteListener4Add(microServiceInfo);
255       Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "20081", "ip"));
256       Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/", "iuitest-ns", "", "domain"));
257       
258       routeInstance.noticeRouteListener4Delete(microServiceInfo);
259             
260     } catch (Exception e) {
261       Assert.fail("throw exception means error occured!" + e.getMessage());
262     }
263     
264     try {     
265       iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "20081", "ip");
266       Assert.fail("should not process to here.");    
267      } 
268      catch(Exception e){
269          Assert.assertTrue(e instanceof ExtendedNotFoundException);
270      }
271     
272     try {     
273       iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "iuitest-ns", "", "domain");
274       Assert.fail("should not process to here.");    
275      } 
276      catch(Exception e){
277          Assert.assertTrue(e instanceof ExtendedNotFoundException);
278      }
279     
280   }
281   
282   @Test
283   public void test_noticeRouteListener4Add_del_iui_path(){
284     try {
285       MicroServiceFullInfo microServiceInfo =buildMicroServiceFullInfo4IUI_path();
286       routeInstance.noticeRouteListener4Add(microServiceInfo);
287       Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10081", "ip"));
288       Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10082", "ip"));
289       Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "host", "", "domain"));
290       
291       routeInstance.noticeRouteListener4Delete(microServiceInfo);
292     } catch (Exception e) {
293       Assert.fail("throw exception means error occured!" + e.getMessage());
294     }
295     
296     try {     
297       iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10081", "ip");
298       Assert.fail("should not process to here.");    
299      } 
300      catch(Exception e){
301          Assert.assertTrue(e instanceof ExtendedNotFoundException);
302      }
303     
304     try {     
305       iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "", "10082", "ip");
306       Assert.fail("should not process to here.");    
307      } 
308      catch(Exception e){
309          Assert.assertTrue(e instanceof ExtendedNotFoundException);
310      }
311     
312     try {     
313       iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest4Path", "host", "", "domain");
314       Assert.fail("should not process to here.");    
315      } 
316      catch(Exception e){
317          Assert.assertTrue(e instanceof ExtendedNotFoundException);
318      }
319     
320   }
321   
322   
323   @Test
324   public void test_noticeRouteListener4Add_del_iui_mutiPort(){
325     try {
326       MicroServiceFullInfo microServiceInfo =buildMicroServiceFullInfo4IUI_path();
327       microServiceInfo.setPath("");
328       microServiceInfo.setHost("");
329       
330       routeInstance.noticeRouteListener4Add(microServiceInfo);
331       Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10081", "ip"));
332       Assert.assertNotNull(iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10082", "ip"));
333       Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/", "iuitest", "", "domain"));
334       
335       routeInstance.noticeRouteListener4Delete(microServiceInfo);
336     } catch (Exception e) {
337       Assert.fail("throw exception means error occured!" + e.getMessage());
338     }
339     
340     try {     
341       iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10081", "ip");
342       Assert.fail("should not process to here.");    
343      } 
344      catch(Exception e){
345          Assert.assertTrue(e instanceof ExtendedNotFoundException);
346      }
347     
348     try {     
349       iuiRouteServiceWrapper.getIuiRouteInstance("iuiTest", "", "10082", "ip");
350       Assert.fail("should not process to here.");    
351      } 
352      catch(Exception e){
353          Assert.assertTrue(e instanceof ExtendedNotFoundException);
354      }
355     
356     try {     
357       customRouteServiceWrapper.getCustomRouteInstance("/", "iuitest", "", "domain");
358       Assert.fail("should not process to here.");    
359      } 
360      catch(Exception e){
361          Assert.assertTrue(e instanceof ExtendedNotFoundException);
362      }
363     
364   }
365   
366   @Test
367   public void test_noticeRouteListener4Add_del_http(){
368     try {
369       MicroServiceFullInfo microServiceInfo=buildMicroServiceFullInfo4HTTP();
370       routeInstance.noticeRouteListener4Add(microServiceInfo);
371       Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "20081", "ip"));
372       Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "httptest-ns", "", "domain"));
373       
374       routeInstance.noticeRouteListener4Delete(microServiceInfo);
375     } catch (Exception e) {
376       Assert.fail("throw exception means error occured!" + e.getMessage());
377     }
378     
379     try {     
380       customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "20081", "ip");
381       Assert.fail("should not process to here.");    
382      } 
383      catch(Exception e){
384          Assert.assertTrue(e instanceof ExtendedNotFoundException);
385      }
386     
387     try {     
388       customRouteServiceWrapper.getCustomRouteInstance("/httpTest", "httptest-ns", "", "domain");
389       Assert.fail("should not process to here.");    
390      } 
391      catch(Exception e){
392          Assert.assertTrue(e instanceof ExtendedNotFoundException);
393      }
394     
395   }
396   
397   @Test
398   public void test_noticeRouteListener4Add_del_http_path(){
399     try {
400       MicroServiceFullInfo microServiceInfo=buildMicroServiceFullInfo4HTTP_path();
401       routeInstance.noticeRouteListener4Add(microServiceInfo);
402       Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10081", "ip"));
403       Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10082", "ip"));
404       Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "host", "", "domain"));
405       
406       routeInstance.noticeRouteListener4Delete(microServiceInfo);
407     } catch (Exception e) {
408       Assert.fail("throw exception means error occured!" + e.getMessage());
409     }
410     
411     try {     
412       customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10081", "ip");
413       Assert.fail("should not process to here.");    
414      } 
415      catch(Exception e){
416          Assert.assertTrue(e instanceof ExtendedNotFoundException);
417      }
418     
419     try {     
420       customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "", "10082", "ip");
421       Assert.fail("should not process to here.");    
422      } 
423      catch(Exception e){
424          Assert.assertTrue(e instanceof ExtendedNotFoundException);
425      }
426     
427     try {     
428       customRouteServiceWrapper.getCustomRouteInstance("/httpTest4Path", "host", "", "domain");
429       Assert.fail("should not process to here.");    
430      } 
431      catch(Exception e){
432          Assert.assertTrue(e instanceof ExtendedNotFoundException);
433      }
434     
435   }
436   
437   
438   @Test
439   public void test_noticeRouteListener4Add_del_http_mutiPort(){
440     try {
441       MicroServiceFullInfo microServiceInfo=buildMicroServiceFullInfo4HTTP_path();
442       microServiceInfo.setPath("");
443       microServiceInfo.setHost("");
444       
445       routeInstance.noticeRouteListener4Add(microServiceInfo);
446       Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10081", "ip"));
447       Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10082", "ip"));
448       Assert.assertNotNull(customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "httptest", "", "domain"));
449       
450       routeInstance.noticeRouteListener4Delete(microServiceInfo);
451     } catch (Exception e) {
452       Assert.fail("throw exception means error occured!" + e.getMessage());
453     }
454     
455     try {     
456       customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10081", "ip");
457       Assert.fail("should not process to here.");    
458      } 
459      catch(Exception e){
460          Assert.assertTrue(e instanceof ExtendedNotFoundException);
461      }
462     
463     try {     
464       customRouteServiceWrapper.getCustomRouteInstance("/httpTest/v1", "", "10082", "ip");
465       Assert.fail("should not process to here.");    
466      } 
467      catch(Exception e){
468          Assert.assertTrue(e instanceof ExtendedNotFoundException);
469      }
470     
471     try {     
472       customRouteServiceWrapper.getCustomRouteInstance("/httpTest", "httptest", "", "domain");
473       Assert.fail("should not process to here.");    
474      } 
475      catch(Exception e){
476          Assert.assertTrue(e instanceof ExtendedNotFoundException);
477      }
478     
479   }
480
481   
482   @Test
483   public void test_noticeRouteListener4Add_portal(){
484     try {
485       PowerMockito.mockStatic(System.class);
486       PowerMockito.when(System.getenv("SDCLIENT_IP")).thenReturn("127.0.0.1");
487       ApiRouteAppConfig configuration=new ApiRouteAppConfig();
488       
489       DiscoverInfo discoverInfo=new DiscoverInfo();
490       discoverInfo.setEnabled(true);
491       discoverInfo.setIp("127.0.0.2");
492       discoverInfo.setPort(10081);    
493       configuration.setDiscoverInfo(discoverInfo);
494       ConfigUtil.getInstance().initDiscoverInfo(configuration);
495       
496       
497       PowerMockito.mockStatic(HttpClientUtil.class);
498       String publishUrl="http://127.0.0.1:10081/api/microservices/v1/services/portalTest/version/v1/allpublishaddress?namespace=&visualRange=0";
499       String resultJson ="[{\"domain\":\"opapi.openpalette.zte.com.cn\",\"port\":\"443\",\"publish_url\":\"/api\",\"visualRange\":\"0\",\"publish_protocol\":\"https\"},{\"ip\":\"10.74.165.246\",\"port\":\"443\",\"publish_url\":\"/opapi\",\"visualRange\":\"0\",\"publish_protocol\":\"https\"},{\"ip\":\"10.74.165.246\",\"port\":\"80\",\"publish_url\":\"/opapi\",\"visualRange\":\"0\",\"publish_protocol\":\"http\"}]";
500       PowerMockito.when(HttpClientUtil.httpGet(publishUrl)).thenReturn(resultJson);
501       
502       MicroServiceFullInfo microServiceInfo=buildMicroServiceFullInfo4PORTAL();
503       
504       routeInstance.noticeRouteListener4Add(microServiceInfo);
505       
506       CustomRouteInfo routeInfo_ip=customRouteServiceWrapper.getCustomRouteInstance("/portalTest/v1", "", "10088", "ip");
507        RouteServer[] servers_ip = new RouteServer[]{new RouteServer("10.74.148.99","8080")};   
508        Assert.assertArrayEquals(servers_ip, routeInfo_ip.getServers());
509       
510        CustomRouteInfo routeInfo_domain=customRouteServiceWrapper.getCustomRouteInstance("/portalTest/v1", "host", "", "domain");
511        RouteServer[] servers_domain = new RouteServer[]{new RouteServer("10.74.165.246","443")};   
512
513        Assert.assertArrayEquals(servers_domain, routeInfo_domain.getServers());
514       
515     } catch (Exception e) {
516       Assert.fail("throw exception means error occured!" + e.getMessage());
517     }
518     
519   }
520   
521   
522   private MicroServiceFullInfo buildMicroServiceFullInfo4API(){
523     MicroServiceFullInfo microServiceInfo=new MicroServiceFullInfo();
524     microServiceInfo.setServiceName("apiTest-ns");
525     microServiceInfo.setVersion("v1");
526     microServiceInfo.setEnable_ssl(false);
527     microServiceInfo.setPublish_port("20081");
528     microServiceInfo.setProtocol("REST");
529     microServiceInfo.setUrl("/api/apiTest/v1");
530     microServiceInfo.setVisualRange("1");
531     microServiceInfo.setStatus("1");
532     microServiceInfo.setNamespace("ns");
533     Set<Node> nodes = new HashSet<Node>();
534     nodes.add(new Node("10.74.148.88","8080"));
535     nodes.add(new Node("10.74.148.89","8080"));
536     microServiceInfo.setNodes(nodes);
537     
538     return microServiceInfo;
539   }
540   
541   private MicroServiceFullInfo buildMicroServiceFullInfo4API_path(){
542     MicroServiceFullInfo microServiceInfo=new MicroServiceFullInfo();
543     microServiceInfo.setServiceName("apiTest");
544     microServiceInfo.setVersion("v1");
545     microServiceInfo.setEnable_ssl(true);
546     microServiceInfo.setHost("host");
547     microServiceInfo.setPath("/api/apiTest4Path/v1");
548     microServiceInfo.setPublish_port("10081|10082");
549     microServiceInfo.setProtocol("REST");
550     microServiceInfo.setUrl("/api/apiTest/v1");
551     microServiceInfo.setVisualRange("0");
552     microServiceInfo.setLb_policy("ip_hash");
553     microServiceInfo.setStatus("1");
554     Set<Node> nodes = new HashSet<Node>();
555     nodes.add(new Node("10.74.148.88","8080"));
556     nodes.add(new Node("10.74.148.89","8080"));
557     microServiceInfo.setNodes(nodes);
558     
559     return microServiceInfo;
560   }
561   
562   
563   private MicroServiceFullInfo buildMicroServiceFullInfo4PORTAL(){
564     
565     MicroServiceFullInfo microServiceInfo=new MicroServiceFullInfo();
566     microServiceInfo.setServiceName("portalTest");
567     microServiceInfo.setVersion("v1");
568     microServiceInfo.setEnable_ssl(true);
569     microServiceInfo.setHost("host");
570     microServiceInfo.setPublish_port("10088");
571     microServiceInfo.setProtocol("HTTP");
572     microServiceInfo.setUrl("/portalTestUrl/v1");
573     microServiceInfo.setVisualRange("0");
574     microServiceInfo.setLb_policy("ip_hash");
575     microServiceInfo.setStatus("1");
576     microServiceInfo.setCustom(RouteUtil.CUSTOM_PORTAL);
577     Set<Node> nodes = new HashSet<Node>();
578     nodes.add(new Node("10.74.148.99","8080"));
579     microServiceInfo.setNodes(nodes);
580     
581     return microServiceInfo;
582   }
583   
584   private MicroServiceFullInfo buildMicroServiceFullInfo4IUI(){
585     MicroServiceFullInfo microServiceInfo=new MicroServiceFullInfo();
586     microServiceInfo.setServiceName("iuiTest-ns");
587     microServiceInfo.setNamespace("ns");
588     microServiceInfo.setVersion("v1");
589     microServiceInfo.setEnable_ssl(false);
590     microServiceInfo.setPublish_port("20081");
591     microServiceInfo.setProtocol("UI");
592     microServiceInfo.setUrl("/iui/iuiTest");
593     microServiceInfo.setVisualRange("1");
594     microServiceInfo.setStatus("1");
595     Set<Node> nodes = new HashSet<Node>();
596     nodes.add(new Node("10.74.148.88","8080"));
597     nodes.add(new Node("10.74.148.89","8080"));
598     microServiceInfo.setNodes(nodes);
599     
600     return microServiceInfo;
601   }
602   
603   private MicroServiceFullInfo buildMicroServiceFullInfo4IUI_path(){
604     MicroServiceFullInfo microServiceInfo=new MicroServiceFullInfo();
605     microServiceInfo.setServiceName("iuiTest");
606     microServiceInfo.setVersion("v1");
607     microServiceInfo.setEnable_ssl(true);
608     microServiceInfo.setHost("host");
609     microServiceInfo.setProtocol("UI");
610     microServiceInfo.setUrl("/iui/iuiTest");
611     microServiceInfo.setLb_policy("ip_hash");
612     microServiceInfo.setPublish_port("10081|10082");
613     microServiceInfo.setPath("/iui/iuiTest4Path");
614     microServiceInfo.setVisualRange("0");
615     microServiceInfo.setStatus("1");
616     Set<Node> nodes = new HashSet<Node>();
617     nodes.add(new Node("10.74.148.88","8080"));
618     nodes.add(new Node("10.74.148.89","8080"));
619     microServiceInfo.setNodes(nodes);
620     
621     return microServiceInfo;
622   }
623   
624   private MicroServiceFullInfo buildMicroServiceFullInfo4HTTP(){
625     MicroServiceFullInfo microServiceInfo=new MicroServiceFullInfo();
626     microServiceInfo.setServiceName("httpTest-ns");
627     microServiceInfo.setNamespace("ns");
628     microServiceInfo.setVersion("v1");
629     microServiceInfo.setEnable_ssl(false);
630     microServiceInfo.setPublish_port("20081");
631     microServiceInfo.setProtocol("HTTP");
632     microServiceInfo.setUrl("/httpTest");
633     microServiceInfo.setVisualRange("1");
634     microServiceInfo.setStatus("1");
635     Set<Node> nodes = new HashSet<Node>();
636     nodes.add(new Node("10.74.148.88","8080"));
637     nodes.add(new Node("10.74.148.89","8080"));
638     microServiceInfo.setNodes(nodes);
639     
640     return microServiceInfo;
641   }
642   
643   private MicroServiceFullInfo buildMicroServiceFullInfo4HTTP_path(){
644     MicroServiceFullInfo microServiceInfo=new MicroServiceFullInfo();
645     microServiceInfo.setServiceName("httpTest");
646     microServiceInfo.setVersion("v1");
647     microServiceInfo.setEnable_ssl(true);
648     microServiceInfo.setHost("host");
649     microServiceInfo.setPublish_port("20081");
650     microServiceInfo.setProtocol("HTTP");
651     microServiceInfo.setUrl("/httpTest");
652     microServiceInfo.setVisualRange("0");
653     microServiceInfo.setStatus("1");
654     microServiceInfo.setLb_policy("ip_hash");
655     microServiceInfo.setPublish_port("10081|10082");
656     microServiceInfo.setPath("/httpTest4Path");
657     Set<Node> nodes = new HashSet<Node>();
658     nodes.add(new Node("10.74.148.88","8080"));
659     nodes.add(new Node("10.74.148.89","8080"));
660     microServiceInfo.setNodes(nodes);
661     
662     return microServiceInfo;
663   }
664   
665   
666 }