@Test public void testAddDropKeyspace() throws Exception { ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition("DynKeyspace", "DynCf"); cassandraCluster.addKeyspace( new ThriftKsDef("DynKeyspace", "org.apache.cassandra.locator.SimpleStrategy", 1, Arrays.asList(cfDef))); String ksid2 = cassandraCluster.dropKeyspace("DynKeyspace"); assertNotNull(ksid2); // Now let's wait for schema agreement. cassandraCluster.addKeyspace(new ThriftKsDef("DynKeyspace", "org.apache.cassandra.locator.SimpleStrategy", 1, Arrays.asList(cfDef)), true); ksid2 = cassandraCluster.dropKeyspace("DynKeyspace", true); assertNotNull(ksid2); }
@Test public void testAddDropKeyspace() throws Exception { ThriftCluster cassandraCluster = new ThriftCluster("Test Cluster", cassandraHostConfigurator, user1Credentials); ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition("DynKeyspace", "DynCf"); cassandraCluster.addKeyspace( new ThriftKsDef("DynKeyspace", "org.apache.cassandra.locator.SimpleStrategy", 1, Arrays.asList(cfDef))); String ksid2 = cassandraCluster.dropKeyspace("DynKeyspace"); assertNotNull(ksid2); }
@Test public void testAddEmptyKeyspace() throws Exception { cassandraCluster.addKeyspace(new ThriftKsDef("DynKeyspaceEmpty")); assertNotNull(cassandraCluster.describeKeyspace("DynKeyspaceEmpty")); String ksid2 = cassandraCluster.dropKeyspace("DynKeyspaceEmpty"); assertNotNull(ksid2); }
@Before public void setUp() throws Exception { super.setupClient(); KEYSPACE_DEV = new ThriftKsDef(new KsDef(KEYSPACE, "org.apache.cassandra.locator.SimpleStrategy", Arrays.asList(new CfDef[] { BLOB_CF_DEF }))); ((ThriftKsDef)KEYSPACE_DEV).setReplicationFactor(1); cassandraHostConfigurator = new CassandraHostConfigurator("localhost:9170"); cassandraCluster = new ThriftCluster("Test Cluster", cassandraHostConfigurator); keyspace = HFactory.createKeyspace(KEYSPACE, cassandraCluster); try { cassandraCluster.dropKeyspace(KEYSPACE); } catch (Exception e) { } cassandraCluster.addKeyspace(KEYSPACE_DEV); }
@Test public void testAddEmptyBasicKeyspaceDefinition() throws Exception { BasicKeyspaceDefinition ksDef = new BasicKeyspaceDefinition(); ksDef.setName("DynKeyspaceEmpty"); ksDef.setReplicationFactor(1); ksDef.setStrategyClass("SimpleStrategy"); cassandraCluster.addKeyspace(ksDef); assertNotNull(cassandraCluster.describeKeyspace("DynKeyspaceEmpty")); String ksid2 = cassandraCluster.dropKeyspace("DynKeyspaceEmpty"); assertNotNull(ksid2); }
@Test public void testEditKeyspace() throws Exception { BasicColumnFamilyDefinition columnFamilyDefinition = new BasicColumnFamilyDefinition(); columnFamilyDefinition.setKeyspaceName("DynKeyspace2"); columnFamilyDefinition.setName("DynamicCF"); ColumnFamilyDefinition cfDef = new ThriftCfDef(columnFamilyDefinition); KeyspaceDefinition keyspaceDefinition = HFactory.createKeyspaceDefinition("DynKeyspace2", "org.apache.cassandra.locator.SimpleStrategy", 1, Arrays.asList(cfDef)); cassandraCluster.addKeyspace(keyspaceDefinition); keyspaceDefinition = HFactory.createKeyspaceDefinition("DynKeyspace2", "org.apache.cassandra.locator.SimpleStrategy", 2, null); cassandraCluster.updateKeyspace(keyspaceDefinition); KeyspaceDefinition fromCluster = cassandraCluster.describeKeyspace("DynKeyspace2"); assertEquals(2,fromCluster.getReplicationFactor()); cassandraCluster.dropKeyspace("DynKeyspace2"); }
@Test public void testEditBasicKeyspaceDefinition() throws Exception { BasicKeyspaceDefinition ksDef = new BasicKeyspaceDefinition(); ksDef.setName("DynKeyspace4"); ksDef.setReplicationFactor(1); ksDef.setStrategyClass("SimpleStrategy"); cassandraCluster.addKeyspace(ksDef); assertNotNull(cassandraCluster.describeKeyspace("DynKeyspace4")); ksDef.setReplicationFactor(2); cassandraCluster.updateKeyspace(ksDef); KeyspaceDefinition fromCluster = cassandraCluster.describeKeyspace("DynKeyspace4"); assertEquals(2, fromCluster.getReplicationFactor()); cassandraCluster.dropKeyspace("DynKeyspace4"); }