diff --git a/build.xml b/build.xml
index 9603855de7..1492d23313 100644
--- a/build.xml
+++ b/build.xml
@@ -189,6 +189,7 @@
+
@@ -830,12 +831,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -854,6 +872,12 @@
+
+
+
+
+
+
+
@@ -1551,7 +1577,7 @@
@@ -1824,6 +1850,7 @@
+
diff --git a/ide/idea-iml-file.xml b/ide/idea-iml-file.xml
index f14fe2e424..3bb51b43b7 100644
--- a/ide/idea-iml-file.xml
+++ b/ide/idea-iml-file.xml
@@ -28,6 +28,7 @@
+
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsNode.java b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsNode.java
index 89b78712e6..a081e557cd 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsNode.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsNode.java
@@ -42,9 +42,8 @@ public class SettingsNode implements Serializable
try
{
String node;
- List tmpNodes = new ArrayList();
- BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(options.file.value())));
- try
+ List tmpNodes = new ArrayList<>();
+ try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(options.file.value()))))
{
while ((node = in.readLine()) != null)
{
@@ -53,10 +52,6 @@ public class SettingsNode implements Serializable
}
nodes = Arrays.asList(tmpNodes.toArray(new String[tmpNodes.size()]));
}
- finally
- {
- in.close();
- }
}
catch(IOException ioe)
{
@@ -177,13 +172,6 @@ public class SettingsNode implements Serializable
public static Runnable helpPrinter()
{
- return new Runnable()
- {
- @Override
- public void run()
- {
- printHelp();
- }
- };
+ return SettingsNode::printHelp;
}
}
diff --git a/tools/stress/test/unit/org/apache/cassandra/stress/settings/OptionReplicationTest.java b/tools/stress/test/unit/org/apache/cassandra/stress/settings/OptionReplicationTest.java
new file mode 100644
index 0000000000..803ee18706
--- /dev/null
+++ b/tools/stress/test/unit/org/apache/cassandra/stress/settings/OptionReplicationTest.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
+ *
+ * http://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.apache.cassandra.stress.settings;
+
+import com.google.common.collect.ImmutableMap;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class OptionReplicationTest
+{
+ @Test
+ public void defaultsToReplicationFactorOfOne() throws Exception
+ {
+ OptionReplication defaults = new OptionReplication();
+ assertEquals(ImmutableMap.of("replication_factor", "1"), defaults.getOptions());
+ }
+}
diff --git a/tools/stress/test/unit/org/apache/cassandra/stress/settings/SettingsNodeTest.java b/tools/stress/test/unit/org/apache/cassandra/stress/settings/SettingsNodeTest.java
new file mode 100644
index 0000000000..ce56d27599
--- /dev/null
+++ b/tools/stress/test/unit/org/apache/cassandra/stress/settings/SettingsNodeTest.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
+ *
+ * http://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.apache.cassandra.stress.settings;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class SettingsNodeTest
+{
+ @Test
+ public void testDefaults() throws Exception
+ {
+ SettingsNode settingsNode = new SettingsNode(new SettingsNode.Options());
+ assertEquals(null, settingsNode.datacenter);
+ }
+
+ @Test
+ public void testOveridingDataCenter() throws Exception
+ {
+ SettingsNode.Options options = new SettingsNode.Options();
+ options.accept("datacenter=dc1");
+ SettingsNode settingsNode = new SettingsNode(options);
+ assertEquals("dc1", settingsNode.datacenter);
+ }
+}