2 * ============LICENSE_START======================================================================
3 * Copyright (C) 2018 NOKIA Intellectual Property, 2018-2019 Nordix Foundation. All rights reserved.
4 * ===============================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6 * in compliance with the License. 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 distributed under the License
11 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12 * or implied. See the License for the specific language governing permissions and limitations under
14 * ============LICENSE_END========================================================================
17 package org.onap.dcaegen2.collectors.datafile.integration;
19 import static org.mockito.ArgumentMatchers.any;
20 import static org.mockito.Mockito.atLeast;
21 import static org.mockito.Mockito.verify;
22 import java.util.concurrent.Executors;
23 import java.util.concurrent.ScheduledExecutorService;
24 import java.util.concurrent.TimeUnit;
25 import org.junit.jupiter.api.Test;
26 import org.junit.jupiter.api.extension.ExtendWith;
27 import org.onap.dcaegen2.collectors.datafile.integration.junit5.mockito.MockitoExtension;
28 import org.onap.dcaegen2.collectors.datafile.tasks.ScheduledTasks;
29 import org.springframework.beans.factory.annotation.Autowired;
30 import org.springframework.context.annotation.ComponentScan;
31 import org.springframework.context.annotation.Configuration;
32 import org.springframework.test.context.ContextConfiguration;
33 import org.springframework.test.context.junit.jupiter.SpringExtension;
34 import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
37 * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/27/18
38 * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
43 @ExtendWith({MockitoExtension.class, SpringExtension.class})
44 @ContextConfiguration(locations = {"classpath:scheduled-context.xml"})
45 class ScheduledXmlContextITest extends AbstractTestNGSpringContextTests {
47 private static final int WAIT_FOR_SCHEDULING = 1;
50 private ScheduledTasks scheduledTask;
53 void testScheduling() {
54 final ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
55 executorService.scheduleWithFixedDelay(this::verifyDmaapConsumerTask, 0, WAIT_FOR_SCHEDULING, TimeUnit.SECONDS);
58 private void verifyDmaapConsumerTask() {
59 verify(scheduledTask, atLeast(1)).scheduleMainDatafileEventTask(any());