<commit_before>/*
 * Copyright 2012-2014 MarkLogic Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.marklogic.client.test;

import static org.junit.Assert.*;

import org.apache.http.client.HttpClient;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import com.marklogic.client.DatabaseClient;
import com.marklogic.client.DatabaseClientFactory;
import com.marklogic.client.DatabaseClientFactory.Authentication;
import com.marklogic.client.extra.httpclient.HttpClientConfigurator;

public class DatabaseClientFactoryTest {
	@BeforeClass
	public static void beforeClass() {
		Common.connect();
	}
	@AfterClass
	public static void afterClass() {
		Common.release();
	}

	@Test
	public void testConnectStringIntStringStringDigest() {
		assertNotNull("Factory could not create client with digest connection", Common.client);
	}

	@Test
	public void testRuntimeDatabaseSelection() {
		DatabaseClient tmpClient = DatabaseClientFactory.newClient(
			Common.HOST, Common.PORT, "Documents", Common.USERNAME, Common.PASSWORD, Authentication.DIGEST
		);
		assertNotNull("Factory could not create client with digest connection", tmpClient);
		String database = 
			tmpClient.newServerEval()
				.xquery("xdmp:database-name(xdmp:database())")
				.evalAs(String.class);
		assertEquals("Runtime database should is wrong", "Documents", database);
		tmpClient.release();
	}

	@Test
	public void testConfigurator() {
		ConfiguratorImpl configurator = new ConfiguratorImpl();

		DatabaseClientFactory.addConfigurator(configurator);
<commit_msg>finish testing runtime database selection now that eval is working<commit_after>/*
 * Copyright 2012-2014 MarkLogic Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.marklogic.client.test;

import static org.junit.Assert.*;

import org.apache.http.client.HttpClient;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import com.marklogic.client.DatabaseClient;
import com.marklogic.client.DatabaseClientFactory;
import com.marklogic.client.DatabaseClientFactory.Authentication;
import com.marklogic.client.extra.httpclient.HttpClientConfigurator;

public class DatabaseClientFactoryTest {
	@BeforeClass
	public static void beforeClass() {
		Common.connect();
		//System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.wire", "debug");
	}
	@AfterClass
	public static void afterClass() {
		Common.release();
	}

	@Test
	public void testConnectStringIntStringStringDigest() {
		assertNotNull("Factory could not create client with digest connection", Common.client);
	}

	@Test
	public void testRuntimeDatabaseSelection() {
		DatabaseClient tmpClient = DatabaseClientFactory.newClient(
			Common.HOST, Common.PORT, "Documents", Common.ADMIN_USERNAME, Common.ADMIN_PASSWORD, Authentication.DIGEST
		);
		assertNotNull("Factory could not create client with digest connection", tmpClient);
		String database = 
			tmpClient.newServerEval()
				.database("Documents")
				.xquery("xdmp:database-name(xdmp:database())")
				.evalAs(String.class);
		assertEquals("Runtime database is wrong", "Documents", database);
		tmpClient.release();
	}

	@Test
	public void testConfigurator() {
		ConfiguratorImpl configurator = new ConfiguratorImpl();

		DatabaseClientFactory.addConfigurator(configurator);

{'fraction_non_alphanumeric': 0.09352847015778641, 'fraction_numerical': 0.005488223187742968, 'mean_word_length': 5.117482517482517, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6001360', 'n_tokens_mistral': 1259, 'n_tokens_neox': 1171, 'n_words': 363}