Search in sources :

Example 1 with ConfigureParallelRunnerWith

use of com.hazelcast.test.annotation.ConfigureParallelRunnerWith in project hazelcast by hazelcast.

the class HazelcastParallelClassRunner method getMaxThreads.

private int getMaxThreads(Class<?> clazz) throws InitializationError {
    if (!SPAWN_MULTIPLE_THREADS) {
        return 1;
    }
    ConfigureParallelRunnerWith annotation = clazz.getAnnotation(ConfigureParallelRunnerWith.class);
    if (annotation != null) {
        try {
            Class<? extends ParallelRunnerOptions> optionsClass = annotation.value();
            Constructor constructor = optionsClass.getConstructor();
            ParallelRunnerOptions parallelRunnerOptions = (ParallelRunnerOptions) constructor.newInstance();
            return parallelRunnerOptions.maxParallelTests();
        } catch (Exception e) {
            throw new InitializationError(e);
        }
    } else {
        return DEFAULT_MAX_THREADS;
    }
}
Also used : Constructor(java.lang.reflect.Constructor) InitializationError(org.junit.runners.model.InitializationError) ConfigureParallelRunnerWith(com.hazelcast.test.annotation.ConfigureParallelRunnerWith) IOException(java.io.IOException)

Aggregations

ConfigureParallelRunnerWith (com.hazelcast.test.annotation.ConfigureParallelRunnerWith)1 IOException (java.io.IOException)1 Constructor (java.lang.reflect.Constructor)1 InitializationError (org.junit.runners.model.InitializationError)1