Package com.carrotsearch.randomizedtesting.timeouts

Source Code of com.carrotsearch.randomizedtesting.timeouts.Test017ThreadLeaksCustomFiltersException$Nested1

package com.carrotsearch.randomizedtesting.timeouts;

import org.junit.Test;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;

import com.carrotsearch.randomizedtesting.RandomizedRunner;
import com.carrotsearch.randomizedtesting.ThreadFilter;
import com.carrotsearch.randomizedtesting.Utils;
import com.carrotsearch.randomizedtesting.WithNestedTestClass;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;

/**
* Checks custom thread ignore policy.
*/
public class Test017ThreadLeaksCustomFiltersException extends WithNestedTestClass {
  public static class ExceptionFilter implements ThreadFilter {
    @Override
    public boolean reject(Thread t) {
      throw new RuntimeException("filter-exception");
    }
  }

  @ThreadLeakScope(Scope.TEST)
  @ThreadLeakFilters(defaultFilters = true, filters = {
      ExceptionFilter.class
  })
  public static class Nested1 {
    @Test
    public void testFooBars() throws Exception {
      assumeRunningNested();
      for (int i = 0; i < 10; i++) {
        startZombieThread("foobar-" + i);
      }
    }
  }

  @Test
  public void testExceptionInFilter() throws Throwable {
    Result r = new JUnitCore().run(new RandomizedRunner(Nested1.class));
    Utils.assertFailureWithMessage(r, "filter-exception");
  }   
}
TOP

Related Classes of com.carrotsearch.randomizedtesting.timeouts.Test017ThreadLeaksCustomFiltersException$Nested1

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.