[cvs] / jsr166 / src / test / tck / ThreadPoolExecutor9Test.java Repository:
ViewVC logotype

View of /jsr166/src/test/tck/ThreadPoolExecutor9Test.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (download) (annotate)
Fri Sep 4 19:35:46 2015 UTC (2 years, 1 month ago) by jsr166
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +0 -0 lines
FILE REMOVED
move ThreadPoolExecutor9Test.java into ThreadPoolExecutorTest.java
/*
 * Written by Martin Buchholz and Doug Lea with assistance from
 * members of JCP JSR-166 Expert Group and released to the public
 * domain, as explained at
 * http://creativecommons.org/publicdomain/zero/1.0/
 */

import static java.util.concurrent.TimeUnit.MILLISECONDS;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;

import junit.framework.Test;
import junit.framework.TestSuite;

public class ThreadPoolExecutor9Test extends JSR166TestCase {
    public static void main(String[] args) {
        main(suite(), args);
    }
    public static Test suite() {
        return new TestSuite(ThreadPoolExecutor9Test.class);
    }

    /**
     * Configuration changes that allow core pool size greater than
     * max pool size result in IllegalArgumentException.
     */
    public void testPoolSizeInvariants() {
        ThreadPoolExecutor p =
            new ThreadPoolExecutor(1, 1,
                                   LONG_DELAY_MS, MILLISECONDS,
                                   new ArrayBlockingQueue<Runnable>(10));
        for (int s = 1; s < 5; s++) {
            p.setMaximumPoolSize(s);
            p.setCorePoolSize(s);
            try {
                p.setMaximumPoolSize(s - 1);
                shouldThrow();
            } catch (IllegalArgumentException success) {}
            assertEquals(s, p.getCorePoolSize());
            assertEquals(s, p.getMaximumPoolSize());
            try {
                p.setCorePoolSize(s + 1);
                shouldThrow();
            } catch (IllegalArgumentException success) {}
            assertEquals(s, p.getCorePoolSize());
            assertEquals(s, p.getMaximumPoolSize());
        }
        joinPool(p);
    }

}

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8