1 /*******************************************************************************
2 * Copyright 2016-2017 ZTE, Inc. and others.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 ******************************************************************************/
16 package org.onap.msb.apiroute;
18 import org.junit.Before;
19 import org.junit.Test;
20 import org.junit.runner.RunWith;
21 import org.mockito.Mockito;
22 import org.onap.msb.apiroute.SyncDataManager;
23 import org.onap.msb.apiroute.wrapper.consulextend.async.ConsulResponseCallback;
24 import org.onap.msb.apiroute.wrapper.consulextend.util.Http;
25 import org.powermock.api.mockito.PowerMockito;
26 import org.powermock.core.classloader.annotations.PowerMockIgnore;
27 import org.powermock.core.classloader.annotations.PrepareForTest;
28 import org.powermock.modules.junit4.PowerMockRunner;
30 import com.fasterxml.jackson.core.type.TypeReference;
32 @RunWith(PowerMockRunner.class)
33 @PrepareForTest({ Http.class })
34 @PowerMockIgnore({ "javax.net.ssl.*" })
35 public class SyncDataManagerTest {
37 @SuppressWarnings("unchecked")
39 public void setUpBeforeTest() {
40 Http http = PowerMockito.mock(Http.class);
45 .asyncGet(Mockito.anyString(),
46 Mockito.any(TypeReference.class),
47 Mockito.any(ConsulResponseCallback.class));
52 .asyncGetDelayHandle(Mockito.anyString(),
53 Mockito.any(TypeReference.class),
54 Mockito.any(ConsulResponseCallback.class));
57 PowerMockito.spy(Http.class);
58 PowerMockito.when(Http.getInstance()).thenReturn(http);
63 public void testSyncDataManager()
65 SyncDataManager.initSyncTask("127.0.0.1",8500);
66 SyncDataManager.startWatchService("huangleibo");
67 SyncDataManager.resetIndex("huangleibo");
68 SyncDataManager.stopWatchService("huangleibo");
69 SyncDataManager.stopWatchServiceList();