Esempio n. 1
0
  public void testCustomRejectedExecutionHandler() {
    RejectedExecutionHandler handler =
        new RejectedExecutionHandler() {
          public void rejectedExecution(Runnable arg0, ThreadPoolExecutor arg1) {
            // nothing to do here
          }
        };

    ThreadingProfile profile = new ThreadingProfile();
    profile.setRejectedExecutionHandler(handler);
    ThreadPoolExecutor pool = profile.createPool("testPool");
    assertSame(handler, pool.getRejectedExecutionHandler());
  }
Esempio n. 2
0
  public void testCustomThreadFactory() {
    ThreadingProfile profile = new ThreadingProfile();

    ThreadFactory configuredFactory =
        new ThreadFactory() {
          public Thread newThread(Runnable r) {
            return null;
          }
        };

    profile.setThreadFactory(configuredFactory);
    ThreadPoolExecutor pool = profile.createPool();
    ThreadFactory returnedFactory = pool.getThreadFactory();
    assertSame(configuredFactory, returnedFactory);
  }
Esempio n. 3
0
 public void testDefaultNamedThreadFactory() {
   ThreadingProfile profile = new ThreadingProfile();
   ThreadPoolExecutor pool = profile.createPool("myThreadPool");
   ThreadFactory returnedFactory = pool.getThreadFactory();
   assertTrue(returnedFactory instanceof NamedThreadFactory);
 }
Esempio n. 4
0
 public void testDefaultThreadFactory() {
   ThreadingProfile profile = new ThreadingProfile();
   ThreadPoolExecutor pool = profile.createPool();
   ThreadFactory returnedFactory = pool.getThreadFactory();
   assertTrue(returnedFactory.getClass().isInstance(Executors.defaultThreadFactory()));
 }