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