<commit_before>package com.cloudant.tests;

import static org.junit.Assert.assertNotNull;

import java.util.List;
import java.util.Properties;

import junit.framework.Assert;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import com.cloudant.client.api.CloudantClient;
import com.cloudant.client.api.model.ApiKey;
import com.cloudant.client.api.model.Membership;
import com.cloudant.client.api.model.Task;
import com.cloudant.tests.util.Utils;

public class CloudantClientTests {

	private static final Log log = LogFactory.getLog(CloudantClientTests.class);
	private static CloudantClient account;
	public static CloudantClient cookieBasedClient;
	private static Properties props;

	@BeforeClass
	public static void setUpClass() {
		props = Utils.getProperties("cloudant.properties", log);
		account = new CloudantClient(props.getProperty("cloudant.account"),
				props.getProperty("cloudant.username"),
				props.getProperty("cloudant.password"));
		String cookie = account.getCookie();
		cookieBasedClient = new CloudantClient(
				props.getProperty("cloudant.account"), cookie);

	}

	@AfterClass
	public static void tearDownClass() {
		account.shutdown();
	}

	@Test
	public void apiKey() {
		ApiKey key = account.generateApiKey();
		assertNotNull(key);
		assertNotNull(key.getKey());
		assertNotNull(key.getPassword());
	}

	@Test
	public void activeTasks() {
		List<Task> tasks = account.getActiveTasks();
		assertNotNull(tasks);
	}

	@Test
	public void membership() {
		Membership mship = account.getMembership();
		assertNotNull(mship);
		assertNotNull(mship.getClusterNodes());
		assertNotNull(mship.getClusterNodes().hasNext());
		assertNotNull(mship.getAllNodes());
		assertNotNull(mship.getAllNodes().hasNext());
	}

	@Test
	public void cookieTest() {
		Membership membership = cookieBasedClient.getMembership();
		assertNotNull(membership);
	}

	@Test
	public void cookieAPITest() {
		cookieBasedClient.generateApiKey();

	}

	@Test
	public void cookieNegativeTest() {
		String cookie = account.getCookie() + "XXX";
		boolean exceptionRaised = true;
		try {
			cookieBasedClient = new CloudantClient(
					props.getProperty("cloudant.account"), cookie);
			exceptionRaised = false;
		} catch (Exception e) {
			exceptionRaised = true;
		}
		if (exceptionRaised == false) {
			Assert.fail("could not connect to cloudant. Un-recognized cookie");
		}
	}

}<commit_msg>updated test case for cookie based connection with cloudant<commit_after>package com.cloudant.tests;

import static org.junit.Assert.assertNotNull;

import java.util.List;
import java.util.Properties;

import junit.framework.Assert;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import com.cloudant.client.api.CloudantClient;
import com.cloudant.client.api.model.ApiKey;
import com.cloudant.client.api.model.Membership;
import com.cloudant.client.api.model.Task;
import com.cloudant.tests.util.Utils;

public class CloudantClientTests {

	private static final Log log = LogFactory.getLog(CloudantClientTests.class);
	private static CloudantClient account;
	public static CloudantClient cookieBasedClient;
	private static Properties props;

	@BeforeClass
	public static void setUpClass() {
		props = Utils.getProperties("cloudant.properties", log);
		account = new CloudantClient(props.getProperty("cloudant.account"),
				props.getProperty("cloudant.username"),
				props.getProperty("cloudant.password"));
		String cookie = account.getCookie();
		cookieBasedClient = new CloudantClient(
				props.getProperty("cloudant.account"), cookie);

	}

	@AfterClass
	public static void tearDownClass() {
		account.shutdown();
	}

	@Test
	public void apiKey() {
		ApiKey key = account.generateApiKey();
		assertNotNull(key);
		assertNotNull(key.getKey());
		assertNotNull(key.getPassword());
	}

	@Test
	public void activeTasks() {
		List<Task> tasks = account.getActiveTasks();
		assertNotNull(tasks);
	}

	@Test
	public void membership() {
		Membership mship = account.getMembership();
		assertNotNull(mship);
		assertNotNull(mship.getClusterNodes());
		assertNotNull(mship.getClusterNodes().hasNext());
		assertNotNull(mship.getAllNodes());
		assertNotNull(mship.getAllNodes().hasNext());
	}

	@Test
	public void cookieTest() {
		Membership membership = cookieBasedClient.getMembership();
		assertNotNull(membership);
	}

	@Test
	public void cookieAPITest() {
		cookieBasedClient.generateApiKey();

	}

	@Test
	public void cookieNegativeTest() {
		String cookie = account.getCookie() + "XXX";
		boolean exceptionRaised = true;
		try {
			CloudantClient cookieBasedClient = new CloudantClient(
					props.getProperty("cloudant.account"), cookie);
			exceptionRaised = false;
		} catch (Exception e) {
			exceptionRaised = true;
		}
		if (exceptionRaised == false) {
			Assert.fail("could not connect to cloudant. Un-recognized cookie");
		}
	}

}
{'fraction_non_alphanumeric': 0.11653170057278293, 'fraction_numerical': 0.0, 'mean_word_length': 5.175609756097561, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6644513', 'n_tokens_mistral': 1639, 'n_tokens_neox': 1517, 'n_words': 321}