From 422fe052e2962bacd902bc0a10488ab017071a37 Mon Sep 17 00:00:00 2001 From: HuabingZhao Date: Tue, 10 Oct 2017 13:59:16 +0800 Subject: Add unit test for MSB JAVA SDK Issue-Id: MSB-86 Change-Id: Icfd790e04014c47aae87beab39fc812c2a64914c Signed-off-by: HuabingZhao --- .../org/onap/msb/sdk/discovery/MSBServiceTest.java | 31 +++++++++++++--------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'src/test/java/org/onap/msb/sdk/discovery/MSBServiceTest.java') diff --git a/src/test/java/org/onap/msb/sdk/discovery/MSBServiceTest.java b/src/test/java/org/onap/msb/sdk/discovery/MSBServiceTest.java index b202ff4..fc8f483 100644 --- a/src/test/java/org/onap/msb/sdk/discovery/MSBServiceTest.java +++ b/src/test/java/org/onap/msb/sdk/discovery/MSBServiceTest.java @@ -97,14 +97,21 @@ public class MSBServiceTest { Assert.assertTrue(microServiceFullInfo.getVisualRange().equals("1")); } - // @Test - // public void test_unregistration() throws Exception { - // String msbAddress = "127.0.0.1:10081"; - // mockHttpDel(); - // MSBService msbService = new MSBService(); - // msbService.cancelMicroServiceInfo(msbAddress, "aai", "v8"); - // } + @Test + public void test_unregistration() throws Exception { + String msbAddress = "127.0.0.1:10081"; + mockHttpDel(); + MSBService msbService = new MSBService(); + msbService.cancelMicroServiceInfo(msbAddress, "aai", "v8"); + } + @Test + public void test_unregistration_a_instance() throws Exception { + String msbAddress = "127.0.0.1:10081"; + mockHttpDel(); + MSBService msbService = new MSBService(); + msbService.cancelMicroServiceInfo(msbAddress, "aai", "v8", "10.74.44.1", "8443"); + } private MicroServiceFullInfo mockMicroServiceFullInfo(MicroServiceInfo info) { MicroServiceFullInfo serviceInfo = new MicroServiceFullInfo(); @@ -130,10 +137,8 @@ public class MSBServiceTest { PowerMockito.when(HttpClientUtil.httpGet(mockMSBUrl)).thenReturn(mockServiceInfoJson); } - // private void mockHttpDel() throws Exception { - // PowerMockito.mockStatic(HttpClientUtil.class); - // HttpClientUtil myClass = PowerMockito.spy(new HttpClientUtil()); - // PowerMockito.doNothing().when(myClass, HttpClientUtil.class.getMethod("delete", String.class, - // String.class)); - // } + private void mockHttpDel() throws Exception { + PowerMockito.mockStatic(HttpClientUtil.class); + + } } -- cgit 1.2.3-korg