// Path: spring-cloud-core/src/main/java/org/springframework/cloud/service/common/CassandraServiceInfo.java
// @ServiceLabel("cassandra")
// public class CassandraServiceInfo extends BaseServiceInfo {
// 
// 	private final List<String> contactPoints;
// 	private final int port;
// 	private final String username;
// 	private final String password;
// 
// 	/**
// 	 * Creates a new {@link CassandraServiceInfo} using Contact points and port.
// 	 *
// 	 * @param id the service-id
// 	 * @param contactPoints list of contact-points
// 	 * @param port the port
// 	 */
// 	public CassandraServiceInfo(String id, List<String> contactPoints, int port) {
// 		this(id, contactPoints, port, null, null);
// 	}
// 
// 	/**
// 	 * Creates a new {@link CassandraServiceInfo} using Contact points with a port and
// 	 * username/password credentials.
// 	 *
// 	 * @param id the service-id
// 	 * @param contactPoints list of contact-points
// 	 * @param port the port
// 	 * @param username the user name
// 	 * @param password the password
// 	 */
// 	public CassandraServiceInfo(String id, List<String> contactPoints, int port,
// 			String username, String password) {
// 		super(id);
// 
// 		this.contactPoints = contactPoints;
// 		this.port = port;
// 		this.username = username;
// 		this.password = password;
// 	}
// 
// 	@ServiceProperty(category = "contactpoints")
// 	public List<String> getContactPoints() {
// 		return contactPoints;
// 	}
// 
// 	@ServiceProperty(category = "port")
// 	public int getPort() {
// 		return port;
// 	}
// 
// 	@ServiceProperty(category = "username")
// 	public String getUsername() {
// 		return username;
// 	}
// 
// 	@ServiceProperty(category = "password")
// 	public String getPassword() {
// 		return password;
// 	}
// }


import com.datastax.driver.core.ProtocolVersion;
import com.datastax.driver.core.QueryOptions;
import com.datastax.driver.core.SocketOptions;
import com.datastax.driver.core.policies.ConstantReconnectionPolicy;
import com.datastax.driver.core.policies.DowngradingConsistencyRetryPolicy;
import com.datastax.driver.core.policies.Policies;
import com.datastax.driver.core.policies.RoundRobinPolicy;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import java.util.Collections;
import org.junit.Test;
import org.springframework.cloud.service.common.CassandraServiceInfo;
import com.datastax.driver.core.AuthProvider;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Configuration;
import com.datastax.driver.core.PlainTextAuthProvider;
import com.datastax.driver.core.PoolingOptions;
import com.datastax.driver.core.ProtocolOptions;
/*
 * Copyright 2016 the original author or authors.
 *
 * 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
 *
 *      https://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 org.springframework.cloud.service.column;





/**
 * @author Mark Paluch
 */
public class CassandraClusterCreatorTest {

	CassandraClusterCreator creator = new CassandraClusterCreator();

	@Test
	public void shouldCreateCluster() throws Exception {

		CassandraServiceInfo info = new CassandraServiceInfo("local",
				Collections.singletonList("127.0.0.1"), 9142);

		Cluster cluster = creator.create(info, null);

		Configuration configuration = cluster.getConfiguration();

		assertThat(configuration.getProtocolOptions().getAuthProvider(),
				is(AuthProvider.NONE));
	}

	@Test
	public void shouldCreateClusterWithAuthentication() throws Exception {

		CassandraServiceInfo info = new CassandraServiceInfo("local",
				Collections.singletonList("127.0.0.1"), 9142, "walter", "white");

		Cluster cluster = creator.create(info, null);

		Configuration configuration = cluster.getConfiguration();

		assertThat(configuration.getProtocolOptions().getAuthProvider(),
				is(instanceOf(PlainTextAuthProvider.class)));
	}

	@Test
	public void shouldCreateClusterWithConfig() throws Exception {

		CassandraServiceInfo info = new CassandraServiceInfo("local",
				Collections.singletonList("127.0.0.1"), 9142);

		CassandraClusterConfig config = new CassandraClusterConfig();
		config.setCompression(ProtocolOptions.Compression.NONE);
		config.setPoolingOptions(new PoolingOptions().setPoolTimeoutMillis(1234));
		config.setQueryOptions(new QueryOptions());
		config.setProtocolVersion(ProtocolVersion.NEWEST_SUPPORTED);
// Path: spring-cloud-core/src/main/java/org/springframework/cloud/service/common/CassandraServiceInfo.java
// @ServiceLabel("cassandra")
// public class CassandraServiceInfo extends BaseServiceInfo {
// 
// 	private final List<String> contactPoints;
// 	private final int port;
// 	private final String username;
// 	private final String password;
// 
// 	/**
// 	 * Creates a new {@link CassandraServiceInfo} using Contact points and port.
// 	 *
// 	 * @param id the service-id
// 	 * @param contactPoints list of contact-points
// 	 * @param port the port
// 	 */
// 	public CassandraServiceInfo(String id, List<String> contactPoints, int port) {
// 		this(id, contactPoints, port, null, null);
// 	}
// 
// 	/**
// 	 * Creates a new {@link CassandraServiceInfo} using Contact points with a port and
// 	 * username/password credentials.
// 	 *
// 	 * @param id the service-id
// 	 * @param contactPoints list of contact-points
// 	 * @param port the port
// 	 * @param username the user name
// 	 * @param password the password
// 	 */
// 	public CassandraServiceInfo(String id, List<String> contactPoints, int port,
// 			String username, String password) {
// 		super(id);
// 
// 		this.contactPoints = contactPoints;
// 		this.port = port;
// 		this.username = username;
// 		this.password = password;
// 	}
// 
// 	@ServiceProperty(category = "contactpoints")
// 	public List<String> getContactPoints() {
// 		return contactPoints;
// 	}
// 
// 	@ServiceProperty(category = "port")
// 	public int getPort() {
// 		return port;
// 	}
// 
// 	@ServiceProperty(category = "username")
// 	public String getUsername() {
// 		return username;
// 	}
// 
// 	@ServiceProperty(category = "password")
// 	public String getPassword() {
// 		return password;
// 	}
// }


// Path: spring-cloud-spring-service-connector/src/test/java/org/springframework/cloud/service/column/CassandraClusterCreatorTest.java
import com.datastax.driver.core.ProtocolVersion;
import com.datastax.driver.core.QueryOptions;
import com.datastax.driver.core.SocketOptions;
import com.datastax.driver.core.policies.ConstantReconnectionPolicy;
import com.datastax.driver.core.policies.DowngradingConsistencyRetryPolicy;
import com.datastax.driver.core.policies.Policies;
import com.datastax.driver.core.policies.RoundRobinPolicy;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import java.util.Collections;
import org.junit.Test;
import org.springframework.cloud.service.common.CassandraServiceInfo;
import com.datastax.driver.core.AuthProvider;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Configuration;
import com.datastax.driver.core.PlainTextAuthProvider;
import com.datastax.driver.core.PoolingOptions;
import com.datastax.driver.core.ProtocolOptions;

/*
 * Copyright 2016 the original author or authors.
 *
 * 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
 *
 *      https://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 org.springframework.cloud.service.column;





/**
 * @author Mark Paluch
 */
public class CassandraClusterCreatorTest {

	CassandraClusterCreator creator = new CassandraClusterCreator();

	@Test
	public void shouldCreateCluster() throws Exception {

		CassandraServiceInfo info = new CassandraServiceInfo("local",
				Collections.singletonList("127.0.0.1"), 9142);

		Cluster cluster = creator.create(info, null);

		Configuration configuration = cluster.getConfiguration();

		assertThat(configuration.getProtocolOptions().getAuthProvider(),
				is(AuthProvider.NONE));
	}

	@Test
	public void shouldCreateClusterWithAuthentication() throws Exception {

		CassandraServiceInfo info = new CassandraServiceInfo("local",
				Collections.singletonList("127.0.0.1"), 9142, "walter", "white");

		Cluster cluster = creator.create(info, null);

		Configuration configuration = cluster.getConfiguration();

		assertThat(configuration.getProtocolOptions().getAuthProvider(),
				is(instanceOf(PlainTextAuthProvider.class)));
	}

	@Test
	public void shouldCreateClusterWithConfig() throws Exception {

		CassandraServiceInfo info = new CassandraServiceInfo("local",
				Collections.singletonList("127.0.0.1"), 9142);

		CassandraClusterConfig config = new CassandraClusterConfig();
		config.setCompression(ProtocolOptions.Compression.NONE);
		config.setPoolingOptions(new PoolingOptions().setPoolTimeoutMillis(1234));
		config.setQueryOptions(new QueryOptions());
		config.setProtocolVersion(ProtocolVersion.NEWEST_SUPPORTED);
		config.setLoadBalancingPolicy(new RoundRobinPolicy());