Fix clm issue
[msb/java-sdk.git] / src / test / java / org / onap / msb / sdk / discovery / MSBServiceTest.java
index e214bf1..f969c10 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright 2017 ZTE Corporation.
+ * Copyright 2017-2018 ZTE Corporation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  * in compliance with the License. You may obtain a copy of the License at
@@ -29,9 +29,12 @@ import org.onap.msb.sdk.discovery.util.JacksonJsonUtil;
 import org.powermock.api.mockito.PowerMockito;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
 
 @RunWith(PowerMockRunner.class)
 @PrepareForTest({HttpClientUtil.class})
+@PowerMockIgnore("jdk.internal.reflect.*")
+
 public class MSBServiceTest {
     private static final String MOCK_MSB_URL_REG_UPDATE_TRUE =
                     "http://127.0.0.1:10081/api/microservices/v1/services?createOrUpdate=true";
@@ -43,7 +46,7 @@ public class MSBServiceTest {
                     "http://127.0.0.1:10081/api/microservices/v1/services/aai/version/v8";
 
     private static final String MOCK_REG_SERVICE_JSON =
-                    "{\"serviceName\":\"aai\",\"version\":\"v8\",\"url\":\"/aai/v8\",\"protocol\":\"REST\",\"visualRange\":\"1\",\"lb_policy\":\"\",\"path\":\"/aai/v8\",\"nodes\":[{\"ip\":\"10.74.44.1\",\"port\":\"8443\",\"ttl\":\"20\"}],\"metadata\":[{\"key\":\"key1\",\"value\":\"value1\"}]}";
+                    "{\"serviceName\":\"aai\",\"version\":\"v8\",\"url\":\"/aai/v8\",\"protocol\":\"REST\",\"visualRange\":\"1\",\"lb_policy\":\"\",\"path\":\"/aai/v8\",\"nodes\":[{\"ip\":\"10.74.44.1\",\"port\":\"8443\",\"ttl\":\"20\",\"checkType\":\"HTTP\",\"checkUrl\":\"\",\"checkInterval\":\"10s\",\"checkTimeOut\":\"10s\"}],\"metadata\":[{\"key\":\"key1\",\"value\":\"value1\"}],\"enable_ssl\":false}";
 
     @Test
     public void test_registration_update_true() throws RouteException {
@@ -114,17 +117,16 @@ public class MSBServiceTest {
         MSBService msbService = new MSBService();
         msbService.cancelMicroServiceInfo(msbAddress, "aai", "v8", "10.74.44.1", "8443");
     }
-    
+
     @Test
-    public void test_healthCheckbyTTL(){
-       try{
-       PowerMockito.mockStatic(HttpClientUtil.class);
-        MSBService msbService = new MSBService();
-        msbService.healthCheckbyTTL("127.0.0.1:10081","aai", "v8", "10.74.44.1", "8443");
-       }
-       catch (Exception e) {
-               Assert.assertTrue(e instanceof RouteException);
-               }
+    public void test_healthCheckbyTTL() {
+        try {
+            PowerMockito.mockStatic(HttpClientUtil.class);
+            MSBService msbService = new MSBService();
+            msbService.healthCheckbyTTL("127.0.0.1:10081", "aai", "v8", "10.74.44.1", "8443");
+        } catch (Exception e) {
+            Assert.assertTrue(e instanceof RouteException);
+        }
     }
 
     private MicroServiceFullInfo mockMicroServiceFullInfo(MicroServiceInfo info) {
@@ -136,9 +138,9 @@ public class MSBServiceTest {
         serviceInfo.setVisualRange(info.getVisualRange());
         serviceInfo.setLb_policy(info.getLb_policy());
         serviceInfo.setPath(info.getPath());
-        
-        Set<NodeInfo> nodes=new HashSet<NodeInfo>();
-        NodeInfo node=new NodeInfo();
+
+        Set<NodeInfo> nodes = new HashSet<NodeInfo>();
+        NodeInfo node = new NodeInfo();
         node.setCreated_at(new Date());
         node.setExpiration(new Date());
         node.setIp("10.74.44.1");
@@ -147,7 +149,7 @@ public class MSBServiceTest {
         node.setStatus("1");
         node.setTtl("20");
         node.setUpdated_at(new Date());
-        
+
         nodes.add(node);
         serviceInfo.setNodes(nodes);
         return serviceInfo;