当前位置: 首页>>代码示例>>Java>>正文


Java RunnerScheduler类代码示例

本文整理汇总了Java中org.junit.runners.model.RunnerScheduler的典型用法代码示例。如果您正苦于以下问题:Java RunnerScheduler类的具体用法?Java RunnerScheduler怎么用?Java RunnerScheduler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RunnerScheduler类属于org.junit.runners.model包,在下文中一共展示了RunnerScheduler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parallelize

import org.junit.runners.model.RunnerScheduler; //导入依赖的package包/类
private static Runner parallelize(Runner runner) {
    int nThreads = Integer.getInteger(Constants.NTHREADS, Runtime.getRuntime().availableProcessors());
    LOGGER.info("Using " + nThreads + " threads.");
    if (runner instanceof ParentRunner) {
        ((ParentRunner<?>) runner).setScheduler(new RunnerScheduler() {
            private final ExecutorService fService = Executors.newFixedThreadPool(nThreads);

            @Override public void schedule(Runnable childStatement) {
                fService.submit(childStatement);
            }

            @Override public void finished() {
                try {
                    fService.shutdown();
                    fService.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
                } catch (InterruptedException e) {
                    e.printStackTrace(System.err);
                }
            }
        });
    }
    return runner;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:24,代码来源:ParallelComputer.java

示例2: runChildren

import org.junit.runners.model.RunnerScheduler; //导入依赖的package包/类
private void runChildren(@SuppressWarnings("hiding") final RunNotifier notifier) {
    RunnerScheduler currentScheduler = scheduler;
    try {
        List<FrameworkMethod> roots = graph.getRoots().stream().map(r -> nameToMethod.get(r)).collect(Collectors.toList());
        for (FrameworkMethod each : roots) {
            currentScheduler.schedule(new Runnable() {
                @Override
                public void run() {
                    ConcurrentDependsOnRunner.this.runChild(each, notifier);
                }
            });
        }
    } finally {
        currentScheduler.finished();
    }
}
 
开发者ID:aafuks,项目名称:aaf-junit,代码行数:17,代码来源:ConcurrentDependsOnRunner.java

示例3: runChildren

import org.junit.runners.model.RunnerScheduler; //导入依赖的package包/类
private void runChildren(@SuppressWarnings("hiding") final RunNotifier notifier) {
    RunnerScheduler currentScheduler = scheduler;
    try {
        List<Runner> roots = graph.getRoots().stream().map(r -> nameToRunner.get(r)).collect(Collectors.toList());
        for (Runner each : roots) {
            currentScheduler.schedule(new Runnable() {
                @Override
                public void run() {
                    ConcurrentDependsOnClasspathSuite.this.runChild(each, notifier);
                }
            });
        }
    } finally {
        currentScheduler.finished();
    }
}
 
开发者ID:aafuks,项目名称:aaf-junit,代码行数:17,代码来源:ConcurrentDependsOnClasspathSuite.java

示例4: Parallelized

import org.junit.runners.model.RunnerScheduler; //导入依赖的package包/类
public Parallelized(Class<?> klass) throws Throwable {
    super(klass);

    setScheduler(new RunnerScheduler() {
        private final ExecutorService service = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());

        public void schedule(Runnable childStatement) {
            service.submit(childStatement);
        }

        public void finished() {
            try {
                service.shutdown();
                service.awaitTermination(5, TimeUnit.MINUTES);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    });
}
 
开发者ID:pavelfatin,项目名称:typometer,代码行数:21,代码来源:Parallelized.java

示例5: ParallelSuite

import org.junit.runners.model.RunnerScheduler; //导入依赖的package包/类
public ParallelSuite(Class<?> klass, RunnerBuilder builder) throws InitializationError {

        super(klass, builder);

        setScheduler(new RunnerScheduler() {

            private final ExecutorService service = Executors.newCachedThreadPool();

            public void schedule(Runnable childStatement) {
                service.submit(childStatement);
            }

            public void finished() {
                try {
                    service.shutdown();
                    service.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
                } catch (InterruptedException e) {
                    e.printStackTrace(System.err);
                }
            }
        });
    }
 
开发者ID:pillfill,项目名称:pf-java-client,代码行数:23,代码来源:ParallelSuite.java

示例6: parallelize

import org.junit.runners.model.RunnerScheduler; //导入依赖的package包/类
private static Runner parallelize(Runner runner) {
    if (runner instanceof ParentRunner) {
        ((ParentRunner<?>) runner).setScheduler(new RunnerScheduler() {
            private final ExecutorService fService = Executors.newCachedThreadPool();

            public void schedule(Runnable childStatement) {
                fService.submit(childStatement);
            }

            public void finished() {
                try {
                    fService.shutdown();
                    fService.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
                } catch (InterruptedException e) {
                    e.printStackTrace(System.err);
                }
            }
        });
    }
    return runner;
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:22,代码来源:ParallelComputer.java

示例7: useChildHarvester

import org.junit.runners.model.RunnerScheduler; //导入依赖的package包/类
@Test
public void useChildHarvester() throws InitializationError {
    log = "";
    ParentRunner<?> runner = new BlockJUnit4ClassRunner(FruitTest.class);
    runner.setScheduler(new RunnerScheduler() {
        public void schedule(Runnable childStatement) {
            log += "before ";
            childStatement.run();
            log += "after ";
        }

        public void finished() {
            log += "afterAll ";
        }
    });

    runner.run(new RunNotifier());
    assertEquals("before apple after before banana after afterAll ", log);
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:20,代码来源:ParentRunnerTest.java

示例8: ParallelParameterized

import org.junit.runners.model.RunnerScheduler; //导入依赖的package包/类
public ParallelParameterized(Class<?> arg0) throws Throwable {

        super(arg0);

        setScheduler(new RunnerScheduler() {

            private final ExecutorService service = Executors.newFixedThreadPool(8);

            public void schedule(Runnable childStatement) {
                service.submit(childStatement);
            }

            public void finished() {
                try {
                    service.shutdown();
                    service.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
                } catch (InterruptedException e) {
                    e.printStackTrace(System.err);
                }
            }
        });
    }
 
开发者ID:johannessimon,项目名称:pal,代码行数:23,代码来源:ParallelParameterized.java

示例9: ParallelParameterized

import org.junit.runners.model.RunnerScheduler; //导入依赖的package包/类
/** Coppied from super constructor: Only called reflectively. Do not use problematically. */
public ParallelParameterized(final Class<?> test_class) throws Throwable {

    super(test_class);
    final String index_as_string = System.getProperty(TEST_PARAM_INDEX);
    next_host_index = new AtomicInteger();
    parameter_index = index_as_string != null ? Integer.valueOf(index_as_string) : null;
    configuration = getParallelizationAnnotation();
    process_builder = new AgentBasedJavaProcessBuilder();
    configure(configuration);
    setScheduler(new RunnerScheduler() {

        @Override
        public void schedule(final Runnable childStatement) {

            executor_service.execute(childStatement);
        }

        @Override
        public void finished() {

            executor_service.shutdown();
            try {
                executor_service.awaitTermination(10, TimeUnit.MINUTES);
            }
            catch (InterruptedException exc) {
                throw new RuntimeException(exc);
            }
        }
    });
}
 
开发者ID:stacs-srg,项目名称:shabdiz,代码行数:32,代码来源:ParallelParameterized.java

示例10: setScheduler

import org.junit.runners.model.RunnerScheduler; //导入依赖的package包/类
@Override
public void setScheduler(RunnerScheduler scheduler) {
  for (Runner child : getChildren()) {
    if (child instanceof ParentRunner<?>) {
      ((ParentRunner<?>) child).setScheduler(scheduler);
    }
  }
}
 
开发者ID:Terracotta-OSS,项目名称:offheap-store,代码行数:9,代码来源:ParallelParameterized.java

示例11: ConcurrentJunitRunner

import org.junit.runners.model.RunnerScheduler; //导入依赖的package包/类
public ConcurrentJunitRunner(final Class<?> klass) throws InitializationError {
    super(klass);
    setScheduler(new RunnerScheduler() {
        ExecutorService executorService = Executors.newFixedThreadPool(
                klass.isAnnotationPresent(Concurrent.class) ?
                        klass.getAnnotation(Concurrent.class).threads() :
                        (int) (Runtime.getRuntime().availableProcessors() * 1.5),
                new NamedThreadFactory(klass.getSimpleName()));
        CompletionService<Void> completionService = new ExecutorCompletionService<>(executorService);
        Queue<Future<Void>> tasks = new LinkedList<>();

        @Override
        public void schedule(Runnable childStatement) {
            tasks.offer(completionService.submit(childStatement, null));
        }

        @Override
        public void finished() {
            try {
                while (!tasks.isEmpty())
                    tasks.remove(completionService.take());
            } catch (@SuppressWarnings("unused") InterruptedException e) {
                Thread.currentThread().interrupt();
            } finally {
                while (!tasks.isEmpty())
                    tasks.poll().cancel(true);
                executorService.shutdownNow();
            }
        }
    });
}
 
开发者ID:centic9,项目名称:commons-test,代码行数:32,代码来源:ConcurrentJunitRunner.java

示例12: runChildren

import org.junit.runners.model.RunnerScheduler; //导入依赖的package包/类
private void runChildren(final RunNotifier notifier) {
    final RunnerScheduler scheduler = fScheduler;
    try {
        for (final T each : getFilteredChildren()) {
            scheduler.schedule(new Runnable() {
                public void run() {
                    ParentRunner.this.runChild(each, notifier);
                }
            });
        }
    } finally {
        scheduler.finished();
    }
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:15,代码来源:ParentRunner.java

示例13: runChildren

import org.junit.runners.model.RunnerScheduler; //导入依赖的package包/类
private void runChildren(final RunNotifier notifier) {
    final RunnerScheduler currentScheduler = scheduler;
    try {
        for (final FrameworkMethod each : getFilteredChildren()) {
            currentScheduler.schedule(new Runnable() {
                public void run() {
                    runChild(each, notifier);
                }
            });
        }
    } finally {
        currentScheduler.finished();
    }
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:15,代码来源:PinpointPluginTestRunner.java

示例14: runChildren

import org.junit.runners.model.RunnerScheduler; //导入依赖的package包/类
private void runChildren(final RunNotifier notifier) {
    final RunnerScheduler currentScheduler = scheduler;

    try {
        for (final Runner each : getFilteredChildren()) {
            currentScheduler.schedule(new Runnable() {
                public void run() {
                    runChild(each, notifier);
                }
            });
        }
    } finally {
        currentScheduler.finished();
    }
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:16,代码来源:PinpointPluginTestSuite.java

示例15: setScheduler

import org.junit.runners.model.RunnerScheduler; //导入依赖的package包/类
@Override
public void setScheduler(RunnerScheduler scheduler) {
	super.setScheduler(scheduler);
	this.scheduler = scheduler;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:6,代码来源:AbstractParallelScenarioRunner.java


注:本文中的org.junit.runners.model.RunnerScheduler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。