All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.cassandraunit.AbstractCassandraUnit4TestCase Maven / Gradle / Ivy

There is a newer version: 4.3.1.0
Show newest version
package org.cassandraunit;

import me.prettyprint.hector.api.Cluster;
import me.prettyprint.hector.api.Keyspace;
import org.cassandraunit.dataset.DataSet;
import org.junit.Before;

/**
 * @author Jeremy Sevellec
 */
public abstract class AbstractCassandraUnit4TestCase {

    private CassandraUnit cassandraUnit;
    private Keyspace keyspace = null;
    private boolean initialized = false;
    private Cluster cluster;
    
    public AbstractCassandraUnit4TestCase() {
    	cassandraUnit = new CassandraUnit(getDataSet());
    }
    
    public AbstractCassandraUnit4TestCase(String configurationFileName) {
    	cassandraUnit = new CassandraUnit(getDataSet(), configurationFileName);
    }

	@Before
    public void before() throws Exception {
        if (!initialized) {
            cassandraUnit.before();

            cluster = cassandraUnit.cluster;
            keyspace = cassandraUnit.keyspace;
            initialized = true;
        }

    }

    public abstract DataSet getDataSet();

    public void setKeyspace(Keyspace keyspace) {
        this.keyspace = keyspace;
    }

    public Keyspace getKeyspace() {
        return keyspace;
    }

    public void setCluster(Cluster cluster) {
        this.cluster = cluster;
    }

    public Cluster getCluster() {
        return cluster;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy