<commit_before>/*
 * Copyright 2015-2016 the original author or authors.
 *
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution and is available at
 *
 * http://www.eclipse.org/legal/epl-v10.html
 */

package org.junit.gen5.launcher;

import java.util.ServiceLoader;
import java.util.logging.Logger;

import org.junit.gen5.commons.util.ReflectionUtils;
import org.junit.gen5.engine.TestEngine;

/**
 * @since 5.0
 */
class ServiceLoaderTestEngineRegistry implements TestEngineRegistry {

	private static final Logger LOG = Logger.getLogger(ServiceLoaderTestEngineRegistry.class.getName());

	private static final Object monitor = new Object();

	private static Iterable<TestEngine> testEngines;

	@Override
	public Iterable<TestEngine> getTestEngines() {
		synchronized (monitor) {
			if (testEngines == null) {
				testEngines = ServiceLoader.load(TestEngine.class, ReflectionUtils.getDefaultClassLoader());
				for (TestEngine testEngine : testEngines) {
					LOG.info(() -> String.format("Discovered TestEngine with ID '%s'.", testEngine.getId()));
				}
			}
			return testEngines;
		}
	}

}<commit_msg>Log discovered TestEngine IDs in a single statement<commit_after>/*
 * Copyright 2015-2016 the original author or authors.
 *
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution and is available at
 *
 * http://www.eclipse.org/legal/epl-v10.html
 */

package org.junit.gen5.launcher;

import static java.util.stream.Collectors.toList;
import static java.util.stream.StreamSupport.stream;

import java.util.ServiceLoader;
import java.util.logging.Logger;

import org.junit.gen5.commons.util.ReflectionUtils;
import org.junit.gen5.engine.TestEngine;

/**
 * @since 5.0
 */
class ServiceLoaderTestEngineRegistry implements TestEngineRegistry {

	private static final Logger LOG = Logger.getLogger(ServiceLoaderTestEngineRegistry.class.getName());

	private static final Object monitor = new Object();

	private static Iterable<TestEngine> testEngines;

	@Override
	public Iterable<TestEngine> getTestEngines() {
		synchronized (monitor) {
			if (testEngines == null) {
				testEngines = ServiceLoader.load(TestEngine.class, ReflectionUtils.getDefaultClassLoader());
				LOG.info(() -> "Discovered TestEngines with IDs "
						+ stream(testEngines.spliterator(), false).map(TestEngine::getId).collect(toList()));
			}
			return testEngines;
		}
	}

}
{'fraction_non_alphanumeric': 0.10310463779225756, 'fraction_numerical': 0.013031812955155231, 'mean_word_length': 4.686274509803922, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1224177', 'n_tokens_mistral': 804, 'n_tokens_neox': 732, 'n_words': 201}