Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding unit test for issue 382 fix

  • Loading branch information...
commit 6083901114555338cc0865f0c55dbc33e30c9ef4 1 parent 6ff5cec
@opuneet opuneet authored
View
59 astyanax-thrift/src/test/java/com/netflix/astyanax/thrift/ThriftKeyspaceImplTest.java
@@ -1909,6 +1909,65 @@ public void testKeyspaceDoesntExist() {
keyspaceContext.shutdown();
}
}
+
+
+ @Test
+ public void testCreateKeyspaceThatAlreadyExists() {
+
+ String keyspaceName = TEST_KEYSPACE_NAME + "_ksAlreadyExists";
+
+ AstyanaxContext<Keyspace> keyspaceContext = new AstyanaxContext.Builder()
+ .forCluster(TEST_CLUSTER_NAME)
+ .forKeyspace(keyspaceName)
+ .withAstyanaxConfiguration(
+ new AstyanaxConfigurationImpl()
+ .setDiscoveryType(NodeDiscoveryType.NONE))
+ .withConnectionPoolConfiguration(
+ new ConnectionPoolConfigurationImpl(keyspaceName)
+ .setMaxConnsPerHost(1).setSeeds(SEEDS))
+ .buildKeyspace(ThriftFamilyFactory.getInstance());
+
+ Keyspace ks = null;
+ try {
+ keyspaceContext.start();
+ ks = keyspaceContext.getClient();
+
+ Properties props = new Properties();
+ props.setProperty("name", keyspaceName);
+ props.setProperty("strategy_class", "SimpleStrategy");
+ props.setProperty("strategy_options.replication_factor", "1");
+
+ try {
+ ks.createKeyspaceIfNotExists(props);
+
+ KeyspaceDefinition ksDef = ks.describeKeyspace();
+ Assert.assertNotNull(ksDef);
+
+ } catch (Exception e) {
+ Assert.fail(e.getMessage());
+ }
+
+
+ // NOW create is again.
+ try {
+ ks.createKeyspaceIfNotExists(props);
+ } catch (Exception e) {
+ Assert.fail(e.getMessage());
+ }
+ } finally {
+
+ try {
+ if (ks != null) {
+ ks.dropKeyspace();
+ }
+ } catch (Exception e) {
+ LOG.info(e.getMessage());
+ }
+
+ keyspaceContext.shutdown();
+ }
+ }
+
@Test
public void testGetSingleColumnNotExists() {
Please sign in to comment.
Something went wrong with that request. Please try again.