<commit_before>package org.kurento.test.services;

import static org.kurento.commons.PropertiesManager.getProperty;
import static org.kurento.test.services.KurentoServicesTestHelper.KCS_WS_URI_PROP;
import static org.kurento.test.services.KurentoServicesTestHelper.KMS_RABBITMQ_ADDRESS_DEFAULT;
import static org.kurento.test.services.KurentoServicesTestHelper.KMS_RABBITMQ_ADDRESS_PROP;
import static org.kurento.test.services.KurentoServicesTestHelper.KMS_TRANSPORT_DEFAULT;
import static org.kurento.test.services.KurentoServicesTestHelper.KMS_TRANSPORT_PROP;
import static org.kurento.test.services.KurentoServicesTestHelper.KMS_TRANSPORT_RABBITMQ_VALUE;
import static org.kurento.test.services.KurentoServicesTestHelper.KMS_TRANSPORT_WS_VALUE;
import static org.kurento.test.services.KurentoServicesTestHelper.KMS_WS_URI_DEFAULT;
import static org.kurento.test.services.KurentoServicesTestHelper.KMS_WS_URI_PROP;

import java.lang.reflect.Constructor;
import java.security.InvalidParameterException;

import org.kurento.client.factory.KurentoClient;
import org.kurento.commons.Address;
import org.kurento.jsonrpc.client.JsonRpcClient;
import org.kurento.jsonrpc.client.JsonRpcClientWebSocket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class KurentoClientTestFactory {

	private static final Logger log = LoggerFactory
			.getLogger(KurentoClientTestFactory.class);

	public static KurentoClient createKurentoForTest() {
		return KurentoClient
				.createFromJsonRpcClient(createJsonRpcClient("client"));
	}

	public static JsonRpcClient createJsonRpcClient(String prefix) {

		String kmsTransport;

		if (prefix.equals("client")) {

			if (getProperty(KCS_WS_URI_PROP) != null) {

				String wsUri = getProperty(KCS_WS_URI_PROP);

				log.info(
						"Connecting kurento client to kcs with websockets to uri '{}'",
						wsUri);

				return new JsonRpcClientWebSocket(wsUri);
			} else {

				return createJsonRpcClient("kcs");
			}

		} else if (prefix.equals("kcs")) {

			kmsTransport = getProperty(KMS_TRANSPORT_PROP,
					KMS_TRANSPORT_DEFAULT);

			switch (kmsTransport) {
			case KMS_TRANSPORT_WS_VALUE:

				String wsUri = getProperty(KMS_WS_URI_PROP, KMS_WS_URI_DEFAULT);

				log.info("Connecting kcs to kms with websockets to uri '{}'",
						wsUri);

				return new JsonRpcClientWebSocket(wsUri);

			case KMS_TRANSPORT_RABBITMQ_VALUE:

				Address rabbitAddress = getProperty(KMS_RABBITMQ_ADDRESS_PROP,
						KMS_RABBITMQ_ADDRESS_DEFAULT);

				log.info("Connecting kcs to kms with RabbitMQ in address '{}'",
						rabbitAddress);

				return newJsonRpcClientRabbitMq(rabbitAddress);

			default:

				throw new RuntimeException(
						"Invalid transport value in property '"
								+ KMS_TRANSPORT_PROP + "': " + kmsTransport
								+ ". Valid values are: "
								+ KMS_TRANSPORT_RABBITMQ_VALUE + " or "
								+ KMS_TRANSPORT_WS_VALUE);
			}
		} else {
			throw new InvalidParameterException();
		}<commit_msg>Changed log messages referred to KCS<commit_after>package org.kurento.test.services;

import static org.kurento.commons.PropertiesManager.getProperty;
import static org.kurento.test.services.KurentoServicesTestHelper.KCS_WS_URI_PROP;
import static org.kurento.test.services.KurentoServicesTestHelper.KMS_RABBITMQ_ADDRESS_DEFAULT;
import static org.kurento.test.services.KurentoServicesTestHelper.KMS_RABBITMQ_ADDRESS_PROP;
import static org.kurento.test.services.KurentoServicesTestHelper.KMS_TRANSPORT_DEFAULT;
import static org.kurento.test.services.KurentoServicesTestHelper.KMS_TRANSPORT_PROP;
import static org.kurento.test.services.KurentoServicesTestHelper.KMS_TRANSPORT_RABBITMQ_VALUE;
import static org.kurento.test.services.KurentoServicesTestHelper.KMS_TRANSPORT_WS_VALUE;
import static org.kurento.test.services.KurentoServicesTestHelper.KMS_WS_URI_DEFAULT;
import static org.kurento.test.services.KurentoServicesTestHelper.KMS_WS_URI_PROP;

import java.lang.reflect.Constructor;
import java.security.InvalidParameterException;

import org.kurento.client.factory.KurentoClient;
import org.kurento.commons.Address;
import org.kurento.jsonrpc.client.JsonRpcClient;
import org.kurento.jsonrpc.client.JsonRpcClientWebSocket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class KurentoClientTestFactory {

	private static final Logger log = LoggerFactory
			.getLogger(KurentoClientTestFactory.class);

	public static KurentoClient createKurentoForTest() {
		return KurentoClient
				.createFromJsonRpcClient(createJsonRpcClient("client"));
	}

	public static JsonRpcClient createJsonRpcClient(String prefix) {

		String kmsTransport;

		if (prefix.equals("client")) {

			if (getProperty(KCS_WS_URI_PROP) != null) {

				String wsUri = getProperty(KCS_WS_URI_PROP);

				log.info(
						"Connecting kurento client with websockets to uri '{}'",
						wsUri);

				return new JsonRpcClientWebSocket(wsUri);
			} else {

				return createJsonRpcClient("kcs");
			}

		} else if (prefix.equals("kcs")) {

			kmsTransport = getProperty(KMS_TRANSPORT_PROP,
					KMS_TRANSPORT_DEFAULT);

			switch (kmsTransport) {
			case KMS_TRANSPORT_WS_VALUE:

				String wsUri = getProperty(KMS_WS_URI_PROP, KMS_WS_URI_DEFAULT);

				log.info("Connecting to kms with websockets to uri '{}'", wsUri);

				return new JsonRpcClientWebSocket(wsUri);

			case KMS_TRANSPORT_RABBITMQ_VALUE:

				Address rabbitAddress = getProperty(KMS_RABBITMQ_ADDRESS_PROP,
						KMS_RABBITMQ_ADDRESS_DEFAULT);

				log.info("Connecting to kms with RabbitMQ in address '{}'",
						rabbitAddress);

				return newJsonRpcClientRabbitMq(rabbitAddress);

			default:

				throw new RuntimeException(
						"Invalid transport value in property '"
								+ KMS_TRANSPORT_PROP + "': " + kmsTransport
								+ ". Valid values are: "
								+ KMS_TRANSPORT_RABBITMQ_VALUE + " or "
								+ KMS_TRANSPORT_WS_VALUE);
			}
		} else {
			throw new InvalidParameterException();
		}
{'fraction_non_alphanumeric': 0.08448800270361609, 'fraction_numerical': 0.0006759040216289286, 'mean_word_length': 5.191422594142259, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2899006', 'n_tokens_mistral': 2256, 'n_tokens_neox': 1966, 'n_words': 323}