2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.dcaegen2.services.prh.integration;
23 import static org.mockito.Mockito.atLeast;
24 import static org.mockito.Mockito.verify;
26 import java.util.concurrent.Executors;
27 import java.util.concurrent.ScheduledExecutorService;
28 import java.util.concurrent.TimeUnit;
29 import org.junit.jupiter.api.Test;
30 import org.junit.jupiter.api.extension.ExtendWith;
31 import org.onap.dcaegen2.services.prh.integration.junit5.mockito.MockitoExtension;
32 import org.onap.dcaegen2.services.prh.tasks.ScheduledTasks;
33 import org.springframework.beans.factory.annotation.Autowired;
34 import org.springframework.context.annotation.Configuration;
35 import org.springframework.test.context.ContextConfiguration;
36 import org.springframework.test.context.junit.jupiter.SpringExtension;
39 * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/27/18
42 @ExtendWith({MockitoExtension.class, SpringExtension.class})
43 @ContextConfiguration(locations = "classpath:scheduled-context.xml")
44 class ScheduledXmlContextITest {
46 private static final int WAIT_FOR_SCHEDULING = 1;
49 private ScheduledTasks scheduledTask;
52 void testScheduling() {
53 final ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
54 executorService.scheduleWithFixedDelay(this::verifyDmaapConsumerTask, 0, WAIT_FOR_SCHEDULING, TimeUnit.SECONDS);
57 private void verifyDmaapConsumerTask() {
58 verify(scheduledTask, atLeast(1)).scheduleMainPrhEventTask();