Fix clm issue
[msb/java-sdk.git] / src / test / java / org / onap / msb / sdk / httpclient / msb / MSBServiceClientTest.java
index 71acd1a..ce00d8b 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
@@ -16,6 +16,7 @@ package org.onap.msb.sdk.httpclient.msb;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.onap.msb.sdk.discovery.MSBService;
 import org.onap.msb.sdk.discovery.common.RouteException;
 import org.onap.msb.sdk.discovery.entity.MicroServiceFullInfo;
 import org.onap.msb.sdk.discovery.entity.MicroServiceInfo;
@@ -24,9 +25,11 @@ 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 MSBServiceClientTest {
     private static final String MOCK_MSB_URL_REG_UPDATE_TRUE =
                     "http://127.0.0.1:10081/api/microservices/v1/services?createOrUpdate=true";
@@ -38,7 +41,7 @@ public class MSBServiceClientTest {
                     "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\":\"\"}],\"metadata\":null}";
+                    "{\"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\":\"\",\"checkType\":\"HTTP\",\"checkUrl\":\"\",\"checkInterval\":\"10s\",\"checkTimeOut\":\"10s\"}],\"metadata\":null,\"enable_ssl\":false}";
 
     @Test
     public void test_registration_update_true() throws RouteException {
@@ -89,6 +92,20 @@ public class MSBServiceClientTest {
         Assert.assertTrue(microServiceFullInfo.getVisualRange().equals("1"));
     }
 
+    @Test
+    public void test_unregistration() throws Exception {
+        mockHttpDel();
+        MSBServiceClient msbClient = new MSBServiceClient("127.0.0.1", 10081);
+        msbClient.cancelMicroServiceInfo("aai", "v8");
+    }
+
+    @Test
+    public void test_unregistration_a_instance() throws Exception {
+        mockHttpDel();
+        MSBServiceClient msbClient = new MSBServiceClient("127.0.0.1", 10081);
+        msbClient.cancelMicroServiceInfo("aai", "v8", "10.74.44.1", "8443");
+    }
+
     private MicroServiceFullInfo mockMicroServiceFullInfo(MicroServiceInfo info) {
         MicroServiceFullInfo serviceInfo = new MicroServiceFullInfo();
         serviceInfo.setServiceName(info.getServiceName());
@@ -113,4 +130,8 @@ public class MSBServiceClientTest {
         PowerMockito.when(HttpClientUtil.httpGet(mockMSBUrl)).thenReturn(mockServiceInfoJson);
     }
 
+    private void mockHttpDel() throws Exception {
+        PowerMockito.mockStatic(HttpClientUtil.class);
+
+    }
 }