Search in sources :

Example 1 with EventRejectedExecutionHandler

use of org.ff4j.audit.EventRejectedExecutionHandler in project ff4j by ff4j.

the class ExceptionsTest method testExceptionHandler.

@Test
public void testExceptionHandler() {
    EventRejectedExecutionHandler ereh = new EventRejectedExecutionHandler();
    final BlockingQueue<Runnable> queue = new ArrayBlockingQueue<Runnable>(2);
    // Executor with worker to process threads
    RejectedExecutionHandler rej = new EventRejectedExecutionHandler();
    ThreadFactory tFactorty = new PublisherThreadFactory();
    ThreadPoolExecutor executor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, queue, tFactorty, rej);
    ereh.rejectedExecution(new Thread(), executor);
}
Also used : PublisherThreadFactory(org.ff4j.audit.PublisherThreadFactory) ThreadFactory(java.util.concurrent.ThreadFactory) PublisherThreadFactory(org.ff4j.audit.PublisherThreadFactory) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) EventRejectedExecutionHandler(org.ff4j.audit.EventRejectedExecutionHandler) RejectedExecutionHandler(java.util.concurrent.RejectedExecutionHandler) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) EventRejectedExecutionHandler(org.ff4j.audit.EventRejectedExecutionHandler) Test(org.junit.Test)

Example 2 with EventRejectedExecutionHandler

use of org.ff4j.audit.EventRejectedExecutionHandler in project ff4j by ff4j.

the class ExceptionsTest method testExceptionHandlerInterrupted.

@Test
public void testExceptionHandlerInterrupted() throws InterruptedException {
    EventRejectedExecutionHandler.setMock(true);
    EventRejectedExecutionHandler ereh = new EventRejectedExecutionHandler();
    ereh.rejectedExecution(new Thread(), null);
    EventRejectedExecutionHandler.setMock(false);
    Assert.assertNotNull(ereh);
}
Also used : EventRejectedExecutionHandler(org.ff4j.audit.EventRejectedExecutionHandler) Test(org.junit.Test)

Aggregations

EventRejectedExecutionHandler (org.ff4j.audit.EventRejectedExecutionHandler)2 Test (org.junit.Test)2 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)1 RejectedExecutionHandler (java.util.concurrent.RejectedExecutionHandler)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 PublisherThreadFactory (org.ff4j.audit.PublisherThreadFactory)1