package de.skuzzle.inject.async;

import static org.junit.Assert.assertEquals;

import java.util.concurrent.CountDownLatch;

import org.junit.Before;
import org.junit.Test;

import com.google.inject.AbstractModule;
import com.google.inject.Guice;

import de.skuzzle.inject.async.annotation.CronTrigger;
import de.skuzzle.inject.async.annotation.Scheduled;

public class ScheduledIT {

    private static CountDownLatch latch = new CountDownLatch(2);

    public static class TypeWithScheduledMethods {

        @Scheduled
        @CronTrigger("0/5 * * * * ?")
        public void scheduledSyso(String s) {
            assertEquals("foobar", s);
            latch.countDown();
        }
    }

    @Before
    public void setup() {
        Guice.createInjector(new AbstractModule() {

            @Override
            protected void configure() {
                GuiceAsync.enableFor(binder());
                bind(TypeWithScheduledMethods.class).asEagerSingleton();
                bind(String.class).toInstance("foobar");
            }
        });
    }

    @Test(timeout = 30000)
    public void testExecuteMultipleTimes() throws Exception {
        latch.await();
    }
}

@@ -348,16 +348,73 @@
 heduled;
+%0Aimport de.skuzzle.inject.async.annotation.SimpleTrigger;
 %0A%0Apublic
@@ -454,16 +454,25 @@
  static 
+volatile 
 CountDow
@@ -478,17 +478,101 @@
 wnLatch 
-l
+cronLatch = new CountDownLatch(2);%0A    private static volatile CountDownLatch simpleL
 atch = n
@@ -796,25 +796,210 @@
             
-l
+cronLatch.countDown();%0A        %7D%0A%0A        @Scheduled%0A        @SimpleTrigger(5000)%0A        public void simpleTrigger(String s) %7B%0A            assertEquals(%22foobar%22, s);%0A            simpleL
 atch.countDo
@@ -1483,17 +1483,50 @@
         
-l
+cronLatch.await();%0A        simpleL
 atch.awa

Extend integration test