Skip to content

Commit

Permalink
allow to have null column value + reformatting : fix #28
Browse files Browse the repository at this point in the history
  • Loading branch information
jsevellec committed Oct 4, 2012
1 parent e5e5f40 commit 7461282
Show file tree
Hide file tree
Showing 52 changed files with 2,645 additions and 2,561 deletions.
57 changes: 27 additions & 30 deletions src/main/java/org/cassandraunit/AbstractCassandraUnit4TestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,48 @@

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;
private CassandraUnit cassandraUnit;
private Keyspace keyspace = null;
private boolean initialized = false;
private Cluster cluster;

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

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

}
}

public abstract DataSet getDataSet();
public abstract DataSet getDataSet();

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

public Keyspace getKeyspace() {
return keyspace;
}
public Keyspace getKeyspace() {
return keyspace;
}

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

public Cluster getCluster() {
return cluster;
}
public Cluster getCluster() {
return cluster;
}

}
34 changes: 17 additions & 17 deletions src/main/java/org/cassandraunit/CassandraUnit.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
import org.junit.rules.ExternalResource;

public class CassandraUnit extends ExternalResource {
public Cluster cluster;
public Keyspace keyspace;
public Cluster cluster;
public Keyspace keyspace;

private DataSet dataSet;
private DataSet dataSet;

public static String clusterName = "TestCluster";
public static String host = "localhost:9171";
public static String clusterName = "TestCluster";
public static String host = "localhost:9171";
private String configurationFileName;

public CassandraUnit(DataSet dataSet) {
this.dataSet = dataSet;
}
this.dataSet = dataSet;
}

public CassandraUnit(DataSet dataSet, String configurationFileName, String host) {
this(dataSet);
Expand All @@ -28,21 +28,21 @@ public CassandraUnit(DataSet dataSet, String configurationFileName, String host)
}

@Override
protected void before() throws Exception {
/* start an embedded Cassandra */
protected void before() throws Exception {
/* start an embedded Cassandra */
if (configurationFileName != null) {
EmbeddedCassandraServerHelper.startEmbeddedCassandra(configurationFileName);
EmbeddedCassandraServerHelper.startEmbeddedCassandra(configurationFileName);
} else {
EmbeddedCassandraServerHelper.startEmbeddedCassandra();
}

/* create structure and load data */
DataLoader dataLoader = new DataLoader(clusterName, host);
dataLoader.load(dataSet);
/* create structure and load data */
DataLoader dataLoader = new DataLoader(clusterName, host);
dataLoader.load(dataSet);

/* get hector client object to query data in your test */
cluster = HFactory.getOrCreateCluster(clusterName, host);
keyspace = HFactory.createKeyspace(dataSet.getKeyspace().getName(), cluster);
}
/* get hector client object to query data in your test */
cluster = HFactory.getOrCreateCluster(clusterName, host);
keyspace = HFactory.createKeyspace(dataSet.getKeyspace().getName(), cluster);
}

}
Loading

0 comments on commit 7461282

Please sign in to comment.