package fr.xevents.spikes;

import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

public class ScheduledTaskRegistrarIT {

    private static final Logger log = LoggerFactory.getLogger(ScheduledTaskRegistrarIT.class);

    private final ScheduledTaskRegistrar registrar = new ScheduledTaskRegistrar();
    private final CountDownLatch latch = new CountDownLatch(10);

    @Test
    public void registerAScheduledTaskWithRegistrar() throws Exception {
        CountDownTask task = new CountDownTask();
        Map<Runnable, Long> fixedDelayTasks = new HashMap<Runnable, Long>();
        fixedDelayTasks.put(task, new Long(100));
        registrar.setFixedDelayTasks(fixedDelayTasks);

        registrar.afterPropertiesSet();

        latch.await(2000, TimeUnit.MILLISECONDS);

        assertThat(latch.getCount(), equalTo((long) 0));
    }

    public class CountDownTask implements Runnable {

        @Override
        public void run() {
            latch.countDown();
            log.debug("DummyTask has been triggered, CountDownLatch is decreased.");
        }

        // private final EventSynchronizer synchronizer;
        // private final String providerId;
        // private final UserRepository userRepository;
        //
        // public DummyTask(EventSynchronizer synchronizer, UserRepository userRepository, String providerId) {
        // this.synchronizer = synchronizer;
        // this.userRepository = userRepository;
        // this.providerId = providerId;
        // }
        //
        // @Override
        // public void run() {
        // System.out.println("jhjkhhjklhjklhkl");
        // // List<User> users = userRepository.getAllUsers();
        // // synchronizer.updateEvents(users, providerId);
        // }
    }

}

@@ -247,24 +247,50 @@
 imeUnit;%0D%0A%0D%0A
+import org.junit.Ignore;%0D%0A
 import org.j
@@ -301,16 +301,16 @@
 .Test;%0D%0A
-
 import o
@@ -736,16 +736,29 @@
  @Test%0D%0A
+    @Ignore%0D%0A
     publ
@@ -1442,24 +1442,24 @@
 reased.%22);%0D%0A
+
         %7D%0D%0A%0D
@@ -1460,704 +1460,8 @@
   %7D%0D
-%0A%0D%0A        // private final EventSynchronizer synchronizer;%0D%0A        // private final String providerId;%0D%0A        // private final UserRepository userRepository;%0D%0A        //%0D%0A        // public DummyTask(EventSynchronizer synchronizer, UserRepository userRepository, String providerId) %7B%0D%0A        // this.synchronizer = synchronizer;%0D%0A        // this.userRepository = userRepository;%0D%0A        // this.providerId = providerId;%0D%0A        // %7D%0D%0A        //%0D%0A        // @Override%0D%0A        // public void run() %7B%0D%0A        // System.out.println(%22jhjkhhjklhjklhkl%22);%0D%0A        // // List%3CUser%3E users = userRepository.getAllUsers();%0D%0A        // // synchronizer.updateEvents(users, providerId);%0D%0A        // %7D%0D
 %0A   

Remove comments