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.Mockito.atLeast;
20 import static org.mockito.Mockito.verify;
22 import java.util.concurrent.Executors;
23 import java.util.concurrent.ScheduledExecutorService;
24 import java.util.concurrent.TimeUnit;
26 import org.junit.jupiter.api.Test;
27 import org.junit.jupiter.api.extension.ExtendWith;
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 * Integration test for the ScheduledXmlContext.
39 * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/27/18
40 * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
45 @ExtendWith({ SpringExtension.class })
46 @ContextConfiguration(locations = { "classpath:scheduled-context.xml" })
47 class ScheduledXmlContextITest extends AbstractTestNGSpringContextTests {
49 private static final int WAIT_FOR_SCHEDULING = 1;
52 private ScheduledTasks scheduledTask;
55 void testScheduling() {
56 final ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
57 executorService.scheduleWithFixedDelay(this::verifyDmaapConsumerTask, 0, WAIT_FOR_SCHEDULING, TimeUnit.SECONDS);
60 private void verifyDmaapConsumerTask() {
61 verify(scheduledTask, atLeast(1)).executeDatafileMainTask();