import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
+import com.google.common.base.Stopwatch;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
-
import org.junit.After;
import org.junit.Test;
-import com.google.common.base.Stopwatch;
-
/**
* Tests various ThreadPoolExecutor implementations.
*
100000, "TestPool", 0 );
}
- @Test(expected=RejectedExecutionException.class)
+ @Test(expected = RejectedExecutionException.class)
public void testFastThreadPoolRejectingTask() throws Exception {
executor = SpecialExecutors.newBoundedFastThreadPool( 1, 1, "TestPool" );
100000, "TestPool", 0 );
}
- @Test(expected=RejectedExecutionException.class)
+ @Test(expected = RejectedExecutionException.class)
public void testCachedThreadRejectingTask() throws Exception {
ExecutorService executor = SpecialExecutors.newBoundedCachedThreadPool( 1, 1, "TestPool" );
this.executor = executor;
- System.out.println( "\nTesting " + executor.getClass().getSimpleName() + " with " +
- numTasksToRun + " tasks." );
+ System.out.println("\nTesting " + executor.getClass().getSimpleName() + " with " + numTasksToRun + " tasks.");
final CountDownLatch tasksRunLatch = new CountDownLatch( numTasksToRun );
final ConcurrentMap<Thread, AtomicLong> taskCountPerThread = new ConcurrentHashMap<>();
stopWatch.stop();
if (!done) {
- fail( (numTasksToRun - tasksRunLatch.getCount()) + " tasks out of " +
- numTasksToRun + " executed" );
+ fail((numTasksToRun - tasksRunLatch.getCount()) + " tasks out of " + numTasksToRun + " executed");
}
if (threadError.get() != null) {
} else if (blockLatch != null) {
blockLatch.await();
}
- } catch( InterruptedException e ) {}
+ } catch (InterruptedException e) {
+ }
if (expThreadPrefix != null) {
assertEquals( "Thread name starts with " + expThreadPrefix, true,
count.incrementAndGet();
}
- } catch( AssertionError e ) {
+ } catch (AssertionError e) {
if (threadError != null) {
threadError.set( e );
}