@@ -0,0 +1,2270 @@
+package net.greghaines.jesque;%0A%0Aimport static net.greghaines.jesque.utils.JesqueUtils.entry;%0Aimport static net.greghaines.jesque.utils.JesqueUtils.map;%0A%0Aimport java.util.Arrays;%0Aimport java.util.concurrent.atomic.AtomicBoolean;%0A%0Aimport net.greghaines.jesque.worker.Worker;%0Aimport net.greghaines.jesque.worker.WorkerEvent;%0Aimport net.greghaines.jesque.worker.WorkerImpl;%0Aimport net.greghaines.jesque.worker.WorkerListener;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Apublic class LongRunningTest%0A%7B%0A%09private static final Logger log = LoggerFactory.getLogger(LongRunningTest.class);%0A%09private static final Config config = new ConfigBuilder().build();%0A%09%0A%09private static void sleepTight(final long millis) %7B%0A%09%09try %7B%0A%09%09%09Thread.sleep(millis);%0A%09%09%7D catch (InterruptedException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%09%7D%0A%0A%09@Before%0A%09public void resetRedis()%0A%09throws Exception%0A%09%7B%0A%09%09TestUtils.resetRedis(config);%0A%09%7D%0A%09%0A%09@Test%0A%09public void dummy()%7B%7D // Makes JUnit happy that there's at least one test if the others are commented out%0A%09%0A%09@SuppressWarnings(%22unchecked%22)%0A//%09@Test%0A%09public void issue28()%0A%09throws InterruptedException%0A%09%7B%0A%09%09TestUtils.enqueueJobs(%22longRunning%22, Arrays.asList(new Job(%22LongRunningAction%22)), config);%0A%09%09final Worker worker2 = new WorkerImpl(config, Arrays.asList(%22longRunning%22), %0A%09%09%09map(entry(%22LongRunningAction%22, LongRunningAction.class)));%0A%09%09final AtomicBoolean succesCallbackInvokedRef = new AtomicBoolean(false);%0A%09%09worker2.addListener(new WorkerListener() %7B%0A%09%09%09@Override%0A%09%09%09public void onEvent(final WorkerEvent event, final Worker worker, final String queue,%0A%09%09%09%09%09final Job job, final Object runner, final Object result, final Exception ex) %7B%0A%09%09%09%09succesCallbackInvokedRef.set(true);%0A%09%09%09%09log.info(%22SUCCCES- %7B%7D%22, job);%0A%09%09%09%7D%0A%09%09%7D, WorkerEvent.JOB_SUCCESS);%0A%09%09final Thread workerThread2 = new Thread(worker2);%0A%09%09workerThread2.start();%0A%09%09sleepTight(1000);%0A%09%09worker2.end(false);%0A%09%09workerThread2.join();%0A%09%09Assert.assertTrue(%22Success callback should have been called%22, succesCallbackInvokedRef.get());%0A%09%7D%0A%09%0A%09public static class LongRunningAction implements Runnable%0A%09%7B%0A%09%09public LongRunningAction()%7B%7D%0A%0A%09%09public void run()%0A%09%09%7B%0A%09%09%09sleepTight(10*60*1000); // Sleep for 10 minutes%0A%09%09%7D%0A%09%7D%0A%7D%0A

Test for Issue #28